Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running py.test without arguments raises missing argument error #821

Closed
asfaltboy opened this issue Jul 8, 2015 · 4 comments
Closed

Running py.test without arguments raises missing argument error #821

asfaltboy opened this issue Jul 8, 2015 · 4 comments
Labels
type: enhancement new feature or API change, should be merged into features branch type: question general question, might be closed after 2 weeks of inactivity

Comments

@asfaltboy
Copy link

I simply run py.test in a fresh env with pytest 2.7.2, without any config or tox files. Environment variables don't seem to mention anything relates to reuse or db or test for that matter...

py.test
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --reuse-db

One thing I would not is that this behavior is recent, sometime after installing pytest-django for another project/venv.

This is obviously a local/environment issue since, and running py.test on a separate machine works fine.

Anything else I can look for as to what adds this argument?

@nicoddemus
Copy link
Member

A couple of things come to mind:

  • Perhaps py.test is aliased to something else in this system?

  • Check if there's a pytest.ini in the folder you are running py.test, or in parent folders (recursively);

  • If py.test is not even displaying any output, you can use this code snippet to find which plugins are installed:

    from pkg_resources import iter_entry_points
    for entry in iter_entry_points('pytest11'):
        print(entry.module_name)

@asfaltboy
Copy link
Author

Interestingly this was a pytest.ini file a couple of parents up in my file system (outside of my project dir), which has addopts = --reuse-db. I must have mistakenly created it when working with pytest-django.

It seems all paths are tried up to root (local('/')), and this is indeed mentioned in the docs.

Perhaps it would be useful if the arg parser could report which args it used and where it came from on fail, maybe point to docs? I believe this would entail passing information on ini/root dir from Config to MyOptionParser (where error is called). Not sure I see an elegant way of outputting an error without changing arguments or settings toggles and checking for them later on.

@nicoddemus
Copy link
Member

Created PR #822 which does that... review and comments are welcome! 😄

@nicoddemus nicoddemus added type: question general question, might be closed after 2 weeks of inactivity type: enhancement new feature or API change, should be merged into features branch labels Jul 9, 2015
@asfaltboy
Copy link
Author

Thanks, good job, works very elegantly:

$ py.test
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --reuse-db
  inifile: /Users/big/dev/pytest.ini
  rootdir: /Users/big/dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants