[Python-Dev] Testing the tests by modifying the ordering of dict items.

Mark Shannon mark at hotpy.org
Thu Jan 5 14:46:52 CET 2012


Hi,

Python code should not depend upon the ordering of items in a dict. 
Unfortunately it seems that a number of tests in the standard library do 
just that.

Changing PyDict_MINSIZE from 8 to either 4 or 16 causes the following 
tests to fail:

test_dis test_email test_inspect test_nntplib test_packaging
test_plistlib test_pprint test_symtable test_trace

test_sys also fails, but this is a legitimate failure in sys.getsizeof()

Changing the collision resolution function from f(n) = 5n + 1 to
f(n) = n + 1 results in the same failures, except for test_packaging and 
test_symtable which pass.

Finally, changing the seed in unicode_hash() from (implicit) 0 to an 
arbitrary value (12345678) causes the above tests to fail plus:

test_json test_set test_ttk_textonly test_urllib test_urlparse

I think this is a real issue as the unicode_hash() function is likely to 
change soon due to http://bugs.python.org/issue13703.

Should I:

1. Submit one big bug report?

2. Submit a bug report for each "failing" test separately?

3. Ignore it, since the tests only fail when I start messing about?

Cheers,
Mark.


More information about the Python-Dev mailing list