PyCharm show full diff when unittest fails for multiline string?

后端 未结 2 1931
故里飘歌
故里飘歌 2021-02-15 09:04

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 09:55

    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

提交回复
热议问题