I am coding along tutorial from django documentation site: https://docs.djangoproject.com/en/3.1/intro/tutorial05/
I got a following problem: While trying to run test on my app (with: py manage.py test polls
in Pycharm commndline) i get following error:
> ImportError: Failed to import test module: mysite.polls Traceback
> (most recent call last): File
> "C:\Users\micha\Anaconda3\envs\DjangoTutorial\lib\unittest\loader.py",
> line 470, in _find_test_path
> package = self._get_module_from_name(name) File "C:\Users\micha\Anaconda3\envs\DjangoTutorial\lib\unittest\loader.py",
> line 377, in _get_module_from_name
> __import__(name) ModuleNotFoundError: No module named 'mysite.polls'
The file structre of my project is as follwoing: link to the directory tree img
It looks like testing unit automaticcaly adds 'mysite' in front of 'polls'
What i tried: I have tried to lookup for an answer in django test documentation. Only solution that i was able to find was to change command to like like this:
py manage.py test polls.tests
Then it runs my test properely.
As far as I understand django documentation, django should automatically find every 'test*' file in polls yet in case of mine it cannot find 'polls' module.
Can you tell me why it happens?
Aucun commentaire:
Enregistrer un commentaire