Test Suite Python - issubclass()arg 1必须是一个类

时间:2015-11-05 04:01:09

标签: python selenium-webdriver python-unittest test-suite

目前我正在阅读使用Python学习Selenium这本书,但我在运行套件时遇到了麻烦。下面我将发布我的两个测试类和包含该套件的文件。

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

1 个答案:

答案 0 :(得分:0)

我无法修复loadTestsFromTestCase 但这种变化对我有用:

search_tests = unittest.TestLoader().loadTestsFromModule(SearchTests, )
home_page_tests = unittest.TestLoader().loadTestsFromModule(HomePageTest, )