[Python-Dev] Memory tests in Unicode

Terry Reedy tjreedy at udel.edu
Sat Aug 16 21:50:23 CEST 2008



Antoine Pitrou wrote:
> 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.

In 3.0, sys.maxint is gone, only sys.maxsize remains, so that some 
change must have been made for 3.0.  Just checked: in 3.0b2 
test_unicode.py has no test_raisexxx().

> 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.



More information about the Python-Dev mailing list