出于某种原因,我无法运行ddt.py.你能解释一下这是什么问题吗?在官方文档中,它看起来像这样。
@ddt
class TestPages(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.set_page_load_timeout(10)
self.driver.maximize_window()
@file_data('client.json')
def test_sort_by_price(self, value):
print("\n" + str(test_cases(2)))
gallerypage = GalleryPage(self.driver, value)
result = gallerypage.sort_by_price()
self.assertTrue(result)
ERROR:
Error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/loader.py", line 34, in testFailure
raise self._exception
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/loader.py", line 168, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: type object 'TestPages' has no attribute 'test_sort_by_price'
答案 0 :(得分:0)
首先,将ddt.py
重命名为test_dtt.py
以避免混淆lib
第二,find . -name "*dtt*.py*"
,正确地重命名
最后,查找并删除所有*.pyc
个文件并重新运行测试
for file in `find . -name "*.pyc"`; do rm -vf $file; done