views:

294

answers:

1

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?

+3  A: 

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?

Alex Martelli
Got it working doing just that with one small difference:I'm using Windows Vista x64 (don't know how much difference that makes?) so I ran:"Set DJANGO_SETTINGS_MODULE=myblog.settings" in at the command line.Thanks for the suggestion!
mkelley33
@mkelley33, you're welcome -- sure, ways to set environment variables differ by OS (and actually by shell within a single OS;-).
Alex Martelli