У меня много проблем с написанием юнит-тестов для моего решения для исправления ядра приложения.
Я задал этот вопрос по обмену экспертами (http://www.experts -exchange.com / Программирование / Языки / Скрипты/Python/Q_26509115.html) но он был там в течение двух недель без ответа - надеюсь, команда SO сможет улучшить это !!
Я перепробовал все, что нашел в Интернете, мои текущие настройкииспользует переносной нос, но я также попробовал стандартную среду модульного тестирования, но она дает примерно ту же проблему (проблема, кажется, патч движка приложения, но не ясно, как это исправить).
Используя самый простой тест:
def test():
#pass
assert False
И проход, и неудача выполняются, как и ожидалось, но я получаю исключение, которое не влияет на результат:
Exception exceptions.AttributeError: "'NoneType' object has no attribute 'print_exc'" in <bound method Signal._remove_receiver of <django.dispatch.dispatcher.Signal object at 0x22da290>> ignored
Как толькоЯ импортирую модели или любой другой файл, который ссылается на модели, например,
from application.models import *
. Я получаю сообщение об ошибке, которое указывает на неправильную установку исправления ядра приложения.Я включил вывод журнала ниже.
Любая помощь приветствуется !!
При использовании Aep-Aep ошибка:
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 /Applications/PyCharm-96.1063.app/helpers/pydev/pydevd.py --client 127.0.0.1 --port 61552 --file /usr/local/bin/nosetests-script.py --with-gae --without-sandbox -w tests/
Connected to pydevd (version 1.1)
pydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)
pydev debugger: starting
nose.config: INFO: Set working dir to /Users/craigedmunds/Documents/Source/reciply/webapplication/trunk/tests
Running on app-engine-patch 1.1
Failure: AttributeError ('module' object has no attribute 'User') ... ERROR
======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'User')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.5/site-packages/nose-0.11.4-py2.5.egg/nose/loader.py", line 382, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Python/2.5/site-packages/nose-0.11.4-py2.5.egg/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Python/2.5/site-packages/nose-0.11.4-py2.5.egg/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/craigedmunds/Documents/Source/reciply/webapplication/trunk/tests/tests.py", line 5, in <module>
from application.models import *
File "/Users/craigedmunds/Documents/Source/reciply/webapplication/trunk/application/models.py", line 4, in <module>
from ragendja.auth.hybrid_models import User
File "/Users/craigedmunds/Documents/Source/reciply/webapplication/trunk/common/appenginepatch/ragendja/auth/hybrid_models.py", line 3, in <module>
from ragendja.auth.google_models import GoogleUserTraits
File "/Users/craigedmunds/Documents/Source/reciply/webapplication/trunk/common/appenginepatch/ragendja/auth/google_models.py", line 5, in <module>
from ragendja.auth.models import EmailUserTraits
File "/Users/craigedmunds/Documents/Source/reciply/webapplication/trunk/common/appenginepatch/ragendja/auth/models.py", line 1, in <module>
from django.contrib.auth.models import *
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/dist/py_zipimport.py", line 213, in load_module
exec code in mod.__dict__
File "/Users/craigedmunds/Documents/source/reciply/webapplication/trunk/common/zip-packages/django-1.1.zip/django/contrib/auth/models.py", line 457, in <module>
User = cache.app_models['auth']['user'] = module.User
AttributeError: 'module' object has no attribute 'User'
-------------------- >> begin captured logging << --------------------
root: WARNING: Can't open zipfile /Users/craigedmunds/Documents/source/reciply/webapplication/trunk/common/zip-packages/.DS_Store: BadZipfile: File is not a zip file
root: INFO: zipimporter('/Users/craigedmunds/Documents/source/reciply/webapplication/trunk/common/zip-packages/django-1.1.zip', '')
root: WARNING: Could not read datastore data from /var/folders/yb/yb1f3LPqE50UqVxSbqvYN++++TI/-Tmp-/django_reciply.datastore
root: WARNING: Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
root: WARNING: Could not read datastore data from /var/folders/yb/yb1f3LPqE50UqVxSbqvYN++++TI/-Tmp-/nosegae.datastore
root: WARNING: Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
--------------------- >> end captured logging << ---------------------
----------------------------------------------------------------------
Ran 1 test in 0.102s
FAILED (errors=1)
Exception exceptions.AttributeError: "'NoneType' object has no attribute 'print_exc'" in <bound method Signal._remove_receiver of <django.dispatch.dispatcher.Signal object at 0x23da290>> ignored
При использовании стандартной среды модульного тестирования Python:
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 /Applications/PyCharm-97.8.app/helpers/pycharm/utrunner.py /Users/craigedmunds/Documents/source/reciply/webapplication/trunk/tests//
Testing started at 9:22 PM ...
Traceback (most recent call last):
File "/Applications/PyCharm-97.8.app/helpers/pycharm/utrunner.py", line 58, in <module>
modules = loadModulesFromFolderRec(a[0])
File "/Applications/PyCharm-97.8.app/helpers/pycharm/utrunner.py", line 42, in loadModulesFromFolderRec
os.path.walk(folder, walkModules, modules)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/posixpath.py", line 290, in walk
func(arg, top, names)
File "/Applications/PyCharm-97.8.app/helpers/pycharm/utrunner.py", line 38, in walkModules
modules.append(loadSource(os.path.join(dirname, name)))
File "/Applications/PyCharm-97.8.app/helpers/pycharm/utrunner.py", line 31, in loadSource
module = imp.load_source(moduleName, fileName)
File "/Users/craigedmunds/Documents/source/reciply/webapplication/trunk/tests//tests.py", line 6, in <module>
from application.models import *
File "/Users/craigedmunds/Documents/Source/reciply/webapplication/trunk/application/models.py", line 4, in <module>
from ragendja.auth.hybrid_models import User
ImportError: No module named ragendja.auth.hybrid_models
Process finished with exit code 1
Empty test suite.