Python Forum

Full Version: Problem with Unittest
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.