As part of some Python tests using the unittest
framework, I need to compare two relatively short text files, where the one is a test output file and the other is a reference file.
The immediate approach is:
import filecmp
...
self.assertTrue(filecmp.cmp(tst_path, ref_path, shallow=False))
It works fine if the test passes, but in the even of failure, there is not much help in the output:
AssertionError: False is not true
Is there a better way of comparing two files as part of the unittest
framework, so some useful output is generated in case of mismatch?