Wednesday, December 24, 2008

Testing AppEngine django application with Nose

Here Shlomo gives a basic example of creating unit tests for AppEngine application.

I tried to adopt this method in my project and it gave me a strange trace:

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/nose-0.10.4-py2.5.egg/nose/", line 364, in loadTestsFromName
    addr.filename, addr.module)
  File "/Library/Python/2.5/site-packages/nose-0.10.4-py2.5.egg/nose/", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/Library/Python/2.5/site-packages/nose-0.10.4-py2.5.egg/nose/", line 84, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
ImportError: Loaded module game.test_models not found in sys.modules

First I thought that nosegae installation is invalid. But then I found out that nose --with-gae does not like when a test module is not in a root directory of the project. So I moved from game package into the root package and it worked as expected.

No comments: