[issue18106] There are unused variables in Lib/test/test_collections.py

Terry J. Reedy report at bugs.python.org
Sat Jun 1 20:12:39 CEST 2013


Terry J. Reedy added the comment:

To me, there are two independent improvements: using i and hence msg to identify the erroneous dup, and using .subTest to test all dups. I would combine ideas from both the first two patches to do both.

1. a fancy formatted message would be more useful with less fluff and the two displays each on their own line.

msg = "iteration %s\ncopy: %s\norig: %s" % (i, dup, words)
# or od for OrderedDict test

2. within both loops, add msg to all asserts as in the first patch. If there is a failure, one would want to know both the source of the dup (indicated by i) and the content, and how it differed from the model.

3. wrap the bodies of both loops with 'with self.subTest():' to always test all dups. Unrolling the loops prevents doing this.

Test the revised tests by temporarily adding both the original (failing the 'is' test) and a partial and therefore faulty copy of the original to both list of dups. Verify that both errors are reported for each and that the message formatting looks ok.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18106>
_______________________________________


More information about the Python-bugs-list mailing list