我正在尝试运行Django测试(版本1.8)
但是我收到了这个错误
from django.test import TestCase
class JobTypesResourceTest (TestCase):
def setUp(self):
TestCase.setUp(self)
def test_basicGet(self):
return True
Traceback (most recent call last):
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\runfiles.py", line 234, in <module>
main()
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\runfiles.py", line 78, in main
return pydev_runfiles.main(configuration) # Note: still doesn't return a proper value.
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\pydev_runfiles.py", line 835, in main
PydevTestRunner(configuration).run_tests()
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\pydev_runfiles.py", line 793, in run_tests
MyDjangoTestSuiteRunner(run_tests).run_tests([])
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\pydev_runfiles.py", line 813, in run_tests
raise AssertionError("Unable to run suite with DjangoTestSuiteRunner because it couldn't be imported.")
AssertionError: Unable to run suite with DjangoTestSuiteRunner because it couldn't be imported.
我错过了一个python库吗?
答案 0 :(得分:1)
感谢您的帮助。看起来我运行的测试错了。我正在使用Eclipse-&gt;运行pyunit选项看起来像是使用旧代码。我在使用to find-hi
ask turtles [
foreach sort link-neighbors [
ask ? [
if count [my-links] of self > 1 and count [my-links] of myself > 1 [
let hi ( calc-HI self myself )
run-procedure ] ] ] ]
end
to-report calc-HI [ XX YY ]
let sizeX count [my-links] of XX
let sizeY count [my-links] of YY
let sizeXY count (turtle-set [link-neighbors] of XX [link-neighbors] of YY)
report (sizeX + sizeY - sizeXY) / sizeY
end
答案 1 :(得分:1)
不要使用上下文菜单&#39;运行为&#39; - &GT; &#39; Python单元测试&#39;。使用项目的上下文菜单&#39; Django&#39; - &GT; &#39;运行Django测试(manage.py测试)&#39;代替。
创建运行Django项目的Django Tests复制启动配置的启动配置(在&#39; Run as&#39; - &gt;&#39; PyDev:Django&#39;之后自动创建) 并从&#39; runserver&#39;更改程序参数到&#39;测试&#39;。
答案 2 :(得分:0)
您的TEST_RUNNER
设置已设置为django.test.simple.DjangoTestSuiteRunner
或其子类。
django.test.simple.DjangoTestSuiteRunner
是deprecated in Django 1.6和removed in Django 1.8。
由于您使用的是Eclipse,我认为this对您来说是准确的。