#2736 closed defect (fixed)

test_numdict fails: repr is not sorted

Reported by: warner Owned by: Brian Warner <warner@…>
Priority: normal Milestone: 1.11.0
Component: code Version: 1.10.2
Keywords: Cc:
Launchpad Bug:

Description

While setting up a windows unit test machine on Appveyor (#2344), I saw a consistent unit test failure:

[FAIL] 
Traceback (most recent call last):
  File "C:\projects\tahoe-lafs\.tox\py\lib\site-packages\allmydata\test\test_util.py", line 1356, in test_numdict
    self.failUnlessEqual(repr(d), "{'a': 1, 'b': 2}")
  File "C:\projects\tahoe-lafs\.tox\py\lib\site-packages\twisted\trial\_synctest.py", line 437, in assertEqual
    super(_Assertions, self).assertEqual(first, second, msg)
  File "C:\Python27-x64\Lib\unittest\case.py", line 513, in assertEqual
    assertion_func(first, second, msg=msg)
  File "C:\Python27-x64\Lib\unittest\case.py", line 506, in _baseAssertEqual
    raise self.failureException(msg)
twisted.trial.unittest.FailTest: "{'b': 2, 'a': 1}" != "{'a': 1, 'b': 2}"
 
allmydata.test.test_util.DictUtil.test_numdict

It looks like this test is inappropriately requiring that the repr of a dictutil.NumDict is sorted, when the implementation delegates __repr__ directly to the underlying (normal) dictionary, which of course makes no guarantees about ordering.

I think that assertion should just be deleted, but maybe you want to change the implementation to provide a stable repr instead. Or maybe we should delete NumDict.. it only appears to be used in one obscure logging tool.

Change History (3)

comment:1 Changed at 2016-02-23T18:52:17Z by Brian Warner <warner@…>

  • Owner set to Brian Warner <warner@…>
  • Resolution set to fixed
  • Status changed from new to closed

In 28f2a0f/trunk:

test_util: tolerate unordered repr of NumDict?

NumDict? does not make any claims about the order of its repr(), so the
test needs to be prepared for it to be stringified in any order. On unix
the old test happened to pass, but on certain windows boxes (maybe
certain versions of python?), it failed. Fixes ticket:2736.

comment:2 Changed at 2016-02-23T18:53:23Z by warner

  • Milestone changed from undecided to 1.10.3

comment:3 Changed at 2016-03-22T05:03:36Z by warner

  • Milestone changed from 1.10.3 to 1.11.0

Milestone renamed

Note: See TracTickets for help on using tickets.