PyCharm show full diff when unittest fails for multiline string?

后端 未结 2 1358
天命终不由人
天命终不由人 2021-02-15 09:10

I am writing some Python unit tests using the \"unittest\" framework and run them in PyCharm. Some of the tests compare a long generated string to a reference value read from a

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-15 10:02

    The TestCase.maxDiff=None answers given in many places only make sure that the diff shown in the unittest output is of full length. In order to also get the full diff in the <Click to see difference> link you have to set MAX_LENGTH.

    import unittest
    
    # Show full diff in unittest
    unittest.util._MAX_LENGTH=2000
    

    Source: https://stackoverflow.com/a/23617918/1878199

提交回复
热议问题