<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Dec 30, 2012 at 6:06 AM, Eli Bendersky <span dir="ltr"><<a href="mailto:eliben@gmail.com" target="_blank">eliben@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On Sun, Dec 30, 2012 at 5:54 AM, Stefan Krah <span dir="ltr"><<a href="mailto:stefan@bytereef.org" target="_blank">stefan@bytereef.org</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Eli Bendersky <<a href="mailto:eliben@gmail.com" target="_blank">eliben@gmail.com</a>> wrote:<br>



> Yes, this is the solution currently used in test_xml_etree. However, once<br>
> pickling tests are added things stop working. Pickle uses __import__ to import<br>
> the module a class belongs to, bypassing all such trickery. So if test___all__<br>
> got _elementtree into sys.modules, pickle's __import__ finds it even if all the<br>
> tests in test_xml_etree manage to ignore it for the Python version because they<br>
> use import_fresh_module.<br>
<br>
</div>I ran into the same problem for test_decimal. The only thing that appears<br>
to work is to set sys.modules['decimal'] explicitly before calling<br>
dumps()/loads(). See:<br>
<br>
   PythonAPItests.test_pickle()<br>
   ContextAPItests.test_pickle()<br>
<br>
<br>
test_decimal ruthlessly switches sys.modules['decimal'] many times. At the<br>
end of all tests there is a sanity check that asserts that the number of<br>
changes were in fact balanced.</blockquote><div><br></div></div><div>Thank you, I'll try this. I'm also experimenting with other approaches.<br><br>By the way, from clean default checkout:<br><br>$ ./python -mtest test___all__ test_int<br>


[1/2] test___all__<br>[2/2] test_int<br>test test_int failed -- Traceback (most recent call last):<br>  File "/home/eliben/python-src/default/Lib/test/test_int.py", line 236, in test_keyword_args<br>    self.assertRaises(TypeError, int, base=10)<br>


AssertionError: TypeError not raised by int<br><br>1 test OK.<br>1 test failed:<br>    test_int<br><br></div><div>Should this really fail? [I haven't investigated the root cause yet]<span class="HOEnZb"></span></div>

</div></div></div></blockquote><div><br></div><div>This is a false alarm, sorry. Please ignore this report (I had some stale build artifacts).<br><br>Eli<br><br></div><div> </div></div></div></div>