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 tests from wheel package with --pyargs ignores custom arguments #3517

Closed
fkromer opened this issue May 28, 2018 · 4 comments
Closed
Labels
type: question general question, might be closed after 2 weeks of inactivity

Comments

@fkromer
Copy link

fkromer commented May 28, 2018

I created a test only package like described here (wheel, tests deployed via data_package=). I noticed that if the tests are run on Ubuntu with pytest --pyargs <package-name> <custom-arguments> the tests are detected and run but they fail during setup because the custom command line arguments are not recognized from conftest.py. I found a workaround for this issue. Is this the recommended way to handle this my use case (deploy test only package with custom command line arguments)?

@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #821 (Running py.test without arguments raises missing argument error), #3198 (Ignore individual tests), #1484 (running py.test), #2371 (Running tests inside namespace packages ?), and #2544 (Run tests truly programmatically).

@pytestbot pytestbot added platform: mac mac platform-specific problem type: bug problem that needs to be addressed labels May 28, 2018
@RonnyPfannschmidt
Copy link
Member

those need to be an actual pytest plugin in that case - early conftests are not discovered in packages

@RonnyPfannschmidt RonnyPfannschmidt added type: question general question, might be closed after 2 weeks of inactivity and removed platform: mac mac platform-specific problem type: bug problem that needs to be addressed labels May 28, 2018
@fkromer
Copy link
Author

fkromer commented May 28, 2018

@RonnyPfannschmidt Thx for saving me time otherwise wasted for unsuccessful exploration 🙂

I know about pytest-dev/cookiecutter-pytest-plugin which creates a structure like this (only files relevant for this issue shown):

pytest-awesome/
├── pytest_awesome.py
├── setup.py
├── tests
│   ├── conftest.py
│   └── test_awesome.py
└── tox.ini

If I consider the exemplary test only package structure (inclusive their utilities, ideally importable by other packages/pytest-plugins, etc.):

  • Can I place fixtures into some other file(s) instead of pytest-awesome/pytest_awesome.py as well? What's best practice for their location?
  • Where should I place utilities e.g. utils.py and other_utils.py into the cookiecutter skeleton? What's best practice for their location?
  • Where should I put tests for utilities e.g. test_utils.py and other_utils.py into the cookiecutter skeleton?

In essence: Is there something preventing me from structuring the package like following for a "easy" and a "full-blown" case?

Easy case with separate fixtures and utils:

pytest-awesome/
├── pytest_awesome.py
├── setup.py
├── fixtures.py
├── test_fixtures.py
├── utils.py
├── test_utils.py
├── tests
│   ├── conftest.py
│   └── test_awesome.py
└── tox.ini

Full-blown case with separate fixtures and utils:

pytest-awesome/
├── pytest_awesome.py
├── setup.py
├── fixtures
│   ├── fixtures_a.py
│   └── fixtures_b.py
├── utils
│   ├── utils_a.py
│   └── utils_b.py
├── plugin_tests
├──── fixtures
│        ├── test_fixtures_a.py
│        └── test_fixtures_b.py
├──── utils
│        ├── test_utils_a.py
│        └── test_utils_b.py
├── tests
│   ├── conftest.py
│   └── test_awesome.py
└── tox.ini

@Zac-HD
Copy link
Member

Zac-HD commented Dec 9, 2018

Closing as inactive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

4 participants