2015-04-15 38 views
2

我根據這個documentation在plone 5中運行單元測試。然而,當我執行此命令:ImportError:沒有名爲PloneTestCase的模塊

bin/test 

我得到了下面的導入錯誤:

Test-module import failures: 

Module: nti.content.tests 

    Traceback (most recent call last): 
     File "/Users/ega/CMS/PloneCourseContentCMF/PloneCourseContentCMF-Buildout/sources/nti.content/nti/content/tests.py", line 8, in <module> 
     from Products.PloneTestCase import PloneTestCase as ptc 
    ImportError: No module named PloneTestCase 

    Test-modules with import problems: 
     nti.content.tests 
    Total: 0 tests, 0 failures, 0 errors in 0.000 seconds. 

我怎樣才能解決這個問題呢?

+0

請提供完整的錯誤跟蹤。 – tisto

+0

重要的是要認識到Plone 5處於beta 1階段。或者,您可能正在使用核心簽出。這樣的問題最好在開發列表中提出,因爲答案不可能具有任何長期價值 - 並且不太適合於計算器。 – SteveM

+0

@tisto我只是編輯我的問題上面。 – ega

回答

8

Plone recently removed它對PloneTestCase的依賴。

所以您應該做同樣的端口plone.app.testing或對您的[測試]演員在setup.py添加PloneTestCase,即

setup(
    ... 
    extras_require=dict(
     test=[ 
      'Products.PloneTestCase', 
     ] 
    ), 
) 
+0

我試着按照上面的建議添加PloneTestCase,但是在運行buildout之後,我仍然得到了同樣的錯誤。 – ega

+1

確保在buildout.cfg中添加 [test]以實際加載您已定義的測試附加組件。 – tisto

+1

太棒了!在setup.py中添加extra_require,在buildout.cfg中添加 [test]解決此導入錯誤。謝謝 – ega

相關問題