Problem with Unittest - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Problem with Unittest (/thread-30904.html) |
Problem with Unittest - mhanusek - Nov-12-2020 Hello! I have a problem with calling method - assertTrue. My code: #!/usr/bin/env python3 import unittest class MyTest(unittest.TestCase): @classmethod def setUp(self): cond = True self.assertTrue(self, expr=cond) # its working self.assertTrue(cond) # its not working - TypeError: assertTrue() missing 1 required positional argument: 'expr def test_1(self): pass if __name__ == '__main__': unittest.main(failfast=True)Playground : https://repl.it/join/aidyjhhn-michahanusek RE: Problem with Unittest - Gribouillis - Nov-12-2020 Don't decorate setUp as a classmethod. That's not the way it is supposed to work. Also normally assertions belong to the test methods not the setUp method. |