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

pytest not finding any tests under module #1978

Closed
grantmcconnaughey opened this issue Oct 3, 2016 · 4 comments
Closed

pytest not finding any tests under module #1978

grantmcconnaughey opened this issue Oct 3, 2016 · 4 comments

Comments

@grantmcconnaughey
Copy link

I am working on a Django 1.9 application. When I run pytest it picks up tests in all the directories except the build directory. The build directory has a tests directory just like all of the other modules. Inside of tests is test_models.py, test_utils.py, and test_views.py.

When I run pytest myapp/apps/build/ then it picks up the tests just fine. But when I simply run pytest (or pytest myapp/apps/) then the build directory is completely excluded.

myapp.apps.build is in my INSTALLED_APPS setting, so that is not the issue. I've tried removing the __init__.py file from the build/tests/ and that did not work. Is the name "build" reserved to pytest or something?

Here is the output:

=== test session starts ===
platform linux2 -- Python 2.7.12, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
Django settings: myapp.settings.testing (from ini file)
rootdir: /code, inifile: pytest.ini
plugins: django-3.0.0
collected 66 items

myapp/apps/authentication/tests/test_models.py ......
myapp/apps/core/tests/test_core_tags.py ...........
myapp/apps/core/tests/test_validators.py ........
myapp/apps/hooks/tests/test_utils.py ............
myapp/apps/hooks/tests/test_views.py ....
myapp/apps/issues/tests/test_models.py .
myapp/apps/issues/tests/test_views.py ..
myapp/apps/notifications/tests/test_models.py ........
myapp/apps/project/tests/test_decorators.py ....
myapp/apps/project/tests/test_models.py ...
myapp/apps/project/tests/test_views.py .......

Here is my project structure. I've truncated all of the apps except build.

├── myapp
│   ├── __init__.py
│   ├── apps
│   │   ├── __init__.py
│   │   ├── authentication
│   │   │   ├── __init__.py
│   │   │   ├── tests
│   │   ├── build
│   │   │   ├── __init__.py
│   │   │   ├── admin.py
│   │   │   ├── constants.py
│   │   │   ├── factories.py
│   │   │   ├── managers.py
│   │   │   ├── tests
│   │   │   │   ├── __init__.py
│   │   │   │   ├── test_models.py
│   │   │   │   ├── test_utils.py
│   │   │   │   └── test_views.py
│   │   │   ├── urls.py
│   │   │   ├── utils.py
│   │   │   ├── views.py
│   │   ├── core
│   │   │   ├── __init__.py
│   │   │   ├── tests
│   │   ├── hooks
│   │   │   ├── __init__.py
│   │   │   ├── tests
│   │   ├── issues
│   │   │   ├── __init__.py
│   │   │   ├── tests
│   │   ├── notifications
│   │   │   ├── __init__.py
│   │   │   ├── tests
│   │   ├── project
│   │   │   ├── __init__.py
│   │   │   ├── tests
@nicoddemus
Copy link
Member

Hi,

That's strange, it should be picking up the tests. Could you please show the contents of your pytest.ini file? Also, can you provide a reproducible example or a public repository which exhibits the problem?

@tomviner
Copy link
Contributor

tomviner commented Oct 4, 2016

build is in the default norecursedirs setting:

Default patterns are '._', 'build', 'dist', 'CVS', 'darcs', '{arch}', '.egg'

See http://doc.pytest.org/en/latest/customize.html#confval-norecursedirs

@grantmcconnaughey you can override this with a pytest.ini file containing, for example just the other default directories not to recurse into, but without "build":

[pytest]
norecursedirs = .* dist CVS _darcs {arch} *.egg

@grantmcconnaughey
Copy link
Author

@tomviner Thank you, that fixed it!

@tomviner
Copy link
Contributor

tomviner commented Oct 4, 2016

@grantmcconnaughey \0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants