Skip to content

Commit

Permalink
Fix nondeterminism in testLocate
Browse files Browse the repository at this point in the history
I've seem failures like

    Failure in test testLocate (zodbbrowser.tests.test_browser.TestZodbInfoViewWithRealDb)
    Traceback (most recent call last):
      Module unittest, line 279, in run
        testMethod()
      Module zodbbrowser.tests.test_browser, line 216, in testLocate
        "partial_oid": 1})
      Module unittest, line 350, in failUnlessEqual
        (msg or '%r != %r' % (first, second))
    AssertionError: {u'error': u'Not found: /stub/nonexistent', u'partial_oid': 2, u'partial_url': u'@@zodbbrowser?oid=0x2', u'partial_path': u'/stub'} != {'error': 'Not found: /stub/nonexistent', 'partial_oid': 1, 'partial_url': '@@zodbbrowser?oid=0x1', 'partial_path': '/stub'}

I suspect these happens because I'm adding three persistent objects to
the DB in a single transaction, and the order of OID allocation might
depend on dictionary iteration order, which is not constant.

Calling connection.add() on the /stub object should force its OID to be
0x1, which is what the test expects.
  • Loading branch information
mgedmin committed Apr 8, 2014
1 parent 7805baf commit ada78cd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/zodbbrowser/tests/test_browser.py
Expand Up @@ -112,6 +112,7 @@ def setUp(self):
self.root['stub'] = PersistentStub()
self.root['stub']['member'] = NonpersistentStub()
self.root['stub']['member']['notpersistent'] = 'string'
self.conn.add(self.root['stub']) # force oid allocation
self.root['root'] = RootFolderStub()
self.root['root']['item'] = PersistentStub()
transaction.commit()
Expand Down

0 comments on commit ada78cd

Please sign in to comment.