# HG changeset patch # User Julien Cristau # Date 1435589923 -7200 # Node ID 9add9b7f9df7f8fb956d9db6c1e360d0a9e58655 # Parent bd2a14d3de1592a858b2c05f613dfc5baa10a71f [server/test] fix random error in unittest_security When entering a new Connection, we cache the user and its 'login' attribute (with no permissions checking). This test makes 'CWUser.login' unreadable by guests, and then proceeds to make sure the 'anon' user can actually not read any 'login' attribute. However, due to the above cnx initialization, anon's login is actually cached, hence readable. This happens to make the test fail sometimes depending on the order in which CWUser entities are returned, because one of them has .complete() called, which as a side effect sets the attribute cache to None for unreadable attributes. Call .complete() on both entities to reset the login cache. While this is still highly debatable, at least it's consistent. diff -r bd2a14d3de15 -r 9add9b7f9df7 server/test/unittest_security.py --- a/server/test/unittest_security.py Mon Jun 29 16:41:36 2015 +0200 +++ b/server/test/unittest_security.py Mon Jun 29 16:58:43 2015 +0200 @@ -500,6 +500,7 @@ rset = cnx.execute('CWUser X') self.assertTrue(rset) x = rset.get_entity(0, 0) + x.complete() self.assertEqual(x.login, None) self.assertTrue(x.creation_date) x = rset.get_entity(1, 0)