0

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.

Marcellinov
  • 311
  • 7
  • 18
SmrtGrunt
  • 869
  • 12
  • 25

1 Answers1

2

Use

unittest.main(verbosity=2)

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

Thom Wiggers
  • 6,938
  • 1
  • 39
  • 65