[New-bugs-announce] [issue18106] There are unused variables in Lib/test/test_collections.py

Vajrasky Kok report at bugs.python.org
Fri May 31 10:13:32 CEST 2013


New submission from Vajrasky Kok:

In two "test_copying" methods in Lib/test/test_collections.py, variable i is never used. My guess is the original test writer forgot to utilize the variable i.

For example, in test_copying method in TestOrderedDict class:

    def test_copying(self):
        # Check that ordered dicts are copyable, deepcopyable, picklable,
        # and have a repr/eval round-trip
        pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
        od = OrderedDict(pairs)
        update_test = OrderedDict()
        update_test.update(od)
        for i, dup in enumerate([
                    od.copy(),
                    copy.copy(od),
                    copy.deepcopy(od),
                    pickle.loads(pickle.dumps(od, 0)),
                    pickle.loads(pickle.dumps(od, 1)),
                    pickle.loads(pickle.dumps(od, 2)),
                    pickle.loads(pickle.dumps(od, 3)),
                    pickle.loads(pickle.dumps(od, -1)),
                    eval(repr(od)),
                    update_test,
                    OrderedDict(od),
                    ]):
            self.assertTrue(dup is not od)
            self.assertEqual(dup, od)
            self.assertEqual(list(dup.items()), list(od.items()))
            self.assertEqual(len(dup), len(od))
            self.assertEqual(type(dup), type(od))

The variable i in "for i, dup in enumerate" is never used.

The test_copying method in TestCounter class has the same problem.

In my opinion, we need to put variable i inside the message in the assert functions to detect which place inside the iteration the test fails.

----------
components: Tests
files: test_copying.patch
keywords: patch
messages: 190393
nosy: vajrasky
priority: normal
severity: normal
status: open
title: There are unused variables in Lib/test/test_collections.py
versions: Python 3.4
Added file: http://bugs.python.org/file30432/test_copying.patch

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


More information about the New-bugs-announce mailing list