2016-03-29 17 views
2

Ben unittest yüzden ben bu hatayı alıyorum neden emin değilim için yeni:unittest piton için böyle test yöntemi

Traceback (most recent call last): 
    File "filemerge_test.py", line 98, in <module> 
    main(sys.argv) 
    File "filemerge_test.py", line 92, in main 
    filemerge_test.test_runner() 
    File "filemerge_test.py", line 19, in test_runner 
    self.addTest(TestFunctionality(self.log, self.options)) 
    File "/nfsdata/DSCluster/home/bli1/filemerge/tests/testcases.py", line 45, in __init__ 
    super(TestFunctionality, self).__init__() 
    File "/usr/local/lib/python2.7/unittest/case.py", line 191, in __init__ 
    (self.__class__, methodName)) 
ValueError: no such test method in <class 'testcases.TestFunctionality'>: runTest 

Tam kod buradadır: http://dpaste.com/0W1GEW6

ben öyle düşünüyorum çünkü ben testleri doğru şekilde kullanmıyorum. Ben sonunda

if __name__ == '__main__': 
    unittest.main() 

ekleyerek çalıştı ben TestFunctionality

class TestFunctionality(unittest.TestCase): 
    def __init__(self, log, options): 
     super(TestFunctionality, self).__init__() 
     self.options = options 
     self.log = log 
     ... 

    def test_outputs(self, test_type) 
     ... 
     ... 

    def run(self): 
     self.test_outputs("-d") 
     self.test_outputs("-f") 

ithal benim testcases.py yılında

from testcases import TestFunctionality 

class FileMergerTest(unittest.TestSuite) 
    def __init__(self, log, options): 
     super(FileMergerTest, self).__init__() 
     self.options = options 
     self.log = log 

    def test_runner(self): 
     self.addTest(TestFunctionality(self.log, self.options)) 
     self.run() 

def main() 
    ... 
    ... 
    filemerge_test = FileMergerTest(log, options) 
    filemerge_test.test_runner() 


if __name__ == "__main__": 
    main(sys.argv) 

: Burada

bir benim test şu anda yazılma biçimi özetidir benim testcases.py dosyamdan ancak benim Hata anlaşılacağı

# def run(self): # <--- remove 
def runTest(self): # <--- use this 
    self.test_outputs("-d") 
    self.test_outputs("-f") 

gibi: aynı hata

cevap