【发布时间】:2012-05-16 02:34:13
【问题描述】:
当我尝试在我的 Django (1.4) 项目中运行 python manage.py test 时,出现错误:
ERROR: test_site_profile_not_available (django.contrib.auth.tests.models.ProfileTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-packages/django/contrib/auth/tests/models.py", line 29, in test_site_profile_not_available
del settings.AUTH_PROFILE_MODULE
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 215, in __delattr__
delattr(self._wrapped, name)
AttributeError: AUTH_PROFILE_MODULE
这是 Django 错误中的 documented,建议仅测试特定应用程序而不是全部。但是我的项目没有应用程序,models.py 只是驻留在项目根目录中。要在 Django 中测试特定的 app,它看起来像 this:
$ ./manage.py test animals
Note that we used animals, not myproject.animals.
表示不能指定要测试的根目录。如何只测试我的项目目录?
请注意,此错误是 larger discussion on unit testing discovery 的一部分。
【问题讨论】:
标签: django django-testing django-1.4 django-contrib django-contenttypes