[Python-Dev] Memory tests in Unicode

Antoine Pitrou solipsis at pitrou.net
Sat Aug 16 17:50:34 CEST 2008


Facundo Batista <facundobatista <at> gmail.com> writes:
> 
> The test_raiseMemError() in test_unicode.py is complicating me the
> regression tests: tries to use all the memory in my system, which
> starts to swap as crazy, and almost freezes everything. When the test
> finishes (always pass ok), I have all the memory flushed so it take a
> few seconds to go back to the normal system.

If the test does allocate the very large string, it means MemoryError isn't
raised, which defeats the purpose of the test.
I think that:
    u"a" * (sys.maxint // 2 - 100)
should be replaced with:
    u"a" * (sys.maxsize - 100)
The latter raises MemoryError reliably here, while the former doesn't.

An assertRaises could also be used in place of the try/except, it would ensure
the test does exercise what it is meant to exercise.

Regards

Antoine.




More information about the Python-Dev mailing list