Tests in Python -
so question pretty general. starting learn how use tests in python. based off research found couple great blogs walk through testing in python. 1 of them test-driven development jason diamond. long story short copied code recommended python. here's code:
class datepattern: def __init__(self, year, month, day): pass def matches(self, date): return true class datepattern(unittest.testcase): def testmatches(self): p=datepattern(2015,5,14) d=datetime.date(2015,5,14) self.failunless(p.matches(d)) def main(): unittest.main() if __name__ == '__main__': main()
according him test supposed pass. when run it, type error shows explaining __init__
takes 1 2 positional arguments , have four. , not pass? can explain issue is? , along way explain best technique finding bugs when issues arise constructor?
you define class named "datepattern", , define second class named "datepattern". second overwrites first. give them different names.
Comments
Post a Comment