{"action":"closed","issue":{"url":"https://api.github.com/repos/twisted/nevow/issues/50","labels_url":"https://api.github.com/repos/twisted/nevow/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/twisted/nevow/issues/50/comments","events_url":"https://api.github.com/repos/twisted/nevow/issues/50/events","html_url":"https://github.com/twisted/nevow/issues/50","id":51078516,"number":50,"title":"Some tests are dependant on Python's hashing randomization","user":{"login":"multani","id":65311,"avatar_url":"https://avatars.githubusercontent.com/u/65311?v=3","gravatar_id":"","url":"https://api.github.com/users/multani","html_url":"https://github.com/multani","followers_url":"https://api.github.com/users/multani/followers","following_url":"https://api.github.com/users/multani/following{/other_user}","gists_url":"https://api.github.com/users/multani/gists{/gist_id}","starred_url":"https://api.github.com/users/multani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/multani/subscriptions","organizations_url":"https://api.github.com/users/multani/orgs","repos_url":"https://api.github.com/users/multani/repos","events_url":"https://api.github.com/users/multani/events{/privacy}","received_events_url":"https://api.github.com/users/multani/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2014-12-05T09:27:33Z","updated_at":"2015-10-06T19:36:41Z","closed_at":"2015-10-06T19:36:41Z","body":"The problem basically is:\r\n\r\n```\r\ngourami:~/.../nevow$ trial nevow.test.test_flatsax.Basic.test_otherns                \r\nnevow.test.test_flatsax\r\n  Basic\r\n    test_otherns ...                                                       [OK]\r\n\r\n-------------------------------------------------------------------------------\r\nRan 1 tests in 0.017s\r\n\r\nPASSED (successes=1)\r\n\r\n\r\ngourami:~/.../nevow$ PYTHONHASHSEED=42 trial nevow.test.test_flatsax.Basic.test_otherns\r\nnevow.test.test_flatsax\r\n  Basic\r\n    test_otherns ...                                                     [FAIL]\r\n\r\n===============================================================================\r\n[FAIL]\r\nTraceback (most recent call last):\r\n  File \".../nevow/nevow/test/test_flatsax.py\", line 184, in test_otherns\r\n    self.failUnlessEqual(xml, flatten(parseString(xml)))\r\n  File \"/usr/lib/python2.7/dist-packages/twisted/trial/_synctest.py\", line 356, in assertEqual\r\n    % (msg, pformat(first), pformat(second)))\r\ntwisted.trial.unittest.FailTest: not equal:\r\na = '<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xf=\"http://www.w3.org/2002/xforms\"><p>in default namespace</p><xf:input><xf:label>in another namespace</xf:label></xf:input></html>'\r\nb = '<html xmlns:xf=\"http://www.w3.org/2002/xforms\" xmlns=\"http://www.w3.org/1999/xhtml\"><p>in default namespace</p><xf:input><xf:label>in another namespace</xf:label></xf:input></html>'\r\n\r\n\r\nnevow.test.test_flatsax.Basic.test_otherns\r\n-------------------------------------------------------------------------------\r\nRan 1 tests in 0.017s\r\n\r\nFAILED (failures=1)\r\n```\r\n\r\nThis means that some tests will break some because they depend on some ordering which is not stable . This currently blocks #47 since Tox sets a different hash seed for each run and the probability of getting the \"right\" seed is probably very low.\r\n\r\nI would propose to hunt down the places where such ordering is not guaranteed and use `sorted()` or something appropriate to fix the problem. (The fix for this test case is too wrap [this `iteritems()`](https://github.com/twisted/nevow/blob/master/nevow/flat/flatstan.py#L114) into `sorted()`). This will make the output more predictable obviously, ease the tests as the tester can expect to have a reliable output, but it has a slight cost performance though.\r\n\r\nOther possibilities that I can think of:\r\n* change the tests so they are smarter: instead of doing a basic string equality (or a ``assert expected in result`` as I saw in other failing tests where ``expected`` content is not in the same order as the one in ``result``), parse the result (they are XML-like strings each times) and assert that the structure is properly formed.\r\n* find the right hash :) (and set it somewhere once and for all, like [this for Tox](http://tox.readthedocs.org/en/latest/example/basic.html#special-handling-of-pythonhashseed)."}}