How do I use PyMock and Nose with Django models?
-
18-09-2019 - |
Question
I'm trying to do TDD with PyMock, but I keep getting error when I use Nose and execute core.py from command line:
"ERROR: Failure: ImportError (Settings cannot be imported, because environment variable DJA NGO_SETTINGS_MODULE is undefined.)"
If I remove "from cms.models import Entry" from the unit test module I created, everything works fine, but I need to mock functionality in django module cms.models.Entry that I created.
What am I doing wrong? Can this be done?
Solution
You do need DJANGO_SETTINGS_MODULE
defined in order to run core.py
-- why don't you just export DJANGO_SETTINGS_MODULE=whatever
in your bash session before starting nose?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow