So my question is pretty general. I am starting to learn how to use tests in Python. Based off my research I found a couple great blogs that walk through testing in Python. One of them is Test-Driven Development by Jason Diamond. Long story short I copied the code he recommended into Python. Here's the 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 to him this test is supposed to pass. However when I run it, a type error shows up explaining that __init__ only takes one to two positional arguments and you have four. And it does not pass? Can someone help explain what the issue is? And along the way explain the best technique to finding bugs when issues arise with the constructor?
TestCase, I have found pytest to be much easier to use.