<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Eli Bendersky <<a href="mailto:eliben@gmail.com">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>
<span class="HOEnZb"><font color="#888888"></font></span><br></blockquote></div><br></div><div class="gmail_extra">Yes, this seems to have done the trick. Thanks for the suggestion.<br><br>I'm still curious about the test-in-clean-env question though.<br>

<br>Eli<br><br></div></div>