ImportError:没有名为django.utils的模块

时间:2013-11-11 08:04:24

标签: django django-views integration-testing django-testing

我有一个使用Tastypie在django webFrameWork中编写的integrationTest案例。

test_file.py

  from django.utils import unittest

  @unittest.skip('skipping')
  def test_admission(self):
  self.check_entity('admission',admission,'Not validate ')

在终端上运行集成测试用例的命令:

(/home/arya/trunk/integrationtests) arya-$ nosetests  -v  test_file.py

在导入django.utils以跳过此integrationTest案例时,以下错误抛出终端:

ERROR OUPUT:

Failure: ImportError (No module named django.utils) ... ERROR

======================================================================
ERROR: Failure: ImportError (No module named django.utils)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/arya/trunk/integrationtests/test_file.py", line 1, in <module>
    from django.utils import unittest
ImportError: No module named django.utils

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

设置或其他原因是否有任何错误?

1 个答案:

答案 0 :(得分:2)

尝试使用

import unittest

而不是

from django.utils import unittest