Tests in subdirectory

In Django 1.8, I have an app with this setting:

app
 |- tests/
 |   |- test_ook.py
 |   |- __init__.py
 |- models.py
 |- __init__.py
 ...

When I run python manage.py test -v 2 app, I get this error:

ImportError: 'tests' module incorrectly imported from '/home/.../site/app/tests'. Expected '/home/.../site/app'. Is this module globally installed?

Why is this?

How can I fix it?

Upvotes: 0

Views: 558

Answers (1)

Rahul Gupta
Rahul Gupta

Reputation: 47876

This error generally occurs if you have tests.py or a tests.pyc file present in the app i.e. at the same level as tests module.

Remove those files and it should work perfectly.

Upvotes: 6

Related Questions