SmrtGrunt
SmrtGrunt

Reputation: 919

Automatically return verbose results in Python unittest?

I know that I can add the "-v" to the command line when running a unit test in Python, but how can I modify the following code so that the output is automatically verbose? I tried several variations of adding -v to the unittest.main() call, with no success.

Python documentation was also unhelpful.

import unittest
from TestCalculator import sub

class TestStringMethods(unittest.TestCase):
    def test_Sub1(self):
        self.assertEqual(sub(2,4), 2, 'Subtraction test one broke')


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

Thanks.

Upvotes: 0

Views: 2176

Answers (1)

Thom Wiggers
Thom Wiggers

Reputation: 7052

Use

unittest.main(verbosity=2)

https://docs.python.org/3/library/unittest.html#unittest.main

Upvotes: 2

Related Questions