2015-11-05 41 views
1

目前我正在閱讀「使用Python學習Selenium」一書,而且我在運行套件時遇到了麻煩。下面我會發布我的兩個測試類和包含該套件的文件。Test Suite Python - issubclass()arg 1必須是類

searchproducts.py https://gist.github.com/anonymous/0a054c6c8728d91f9ad8

homepagetest.py https://gist.github.com/anonymous/5043f2432f2316345c3f

smoketest.py https://gist.github.com/anonymous/8220d861fce77d0ea197

當我嘗試運行smoketest.py文件,顯示在錯誤:

Traceback (most recent call last): 
File "smoketests.py", line 12, in <module> 
unittest.TextTestRunner(verbosity=2).run(smoke_tests) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib' /python2.7/unittest/runner.py", line 151, in run 
test(result) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib /python2.7/unittest/suite.py", line 70, in __call__ 
return self.run(*args, **kwds) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/suite.py", line 108, in run 
test(result) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 50, in loadTestsFromTestCase 
if issubclass(testCaseClass, suite.TestSuite): 
TypeError: issubclass() arg 1 must be a class 

回答

0

我無法修復loadTestsFromTestCase
但是這個改變適用於我:

search_tests = unittest.TestLoader().loadTestsFromModule(SearchTests,) 
home_page_tests = unittest.TestLoader().loadTestsFromModule(HomePageTest,) 
相關問題