diff options
author | Pierre-Yves David <pierre-yves.david@logilab.fr> | 2012-03-15 13:34:02 +0100 |
---|---|---|
committer | Pierre-Yves David <pierre-yves.david@logilab.fr> | 2012-03-15 13:34:02 +0100 |
commit | 70683711afccf2d454b81b7903112c8f09f73fcd (patch) | |
tree | 4cd45689b91a82a70d78ad5765e8b5e8b6142958 | |
parent | 3b9dd6354f85ed67ef7733b26fe87887cac49dc8 (diff) | |
download | logilab-common-70683711afccf2d454b81b7903112c8f09f73fcd.tar.gz |
testlib: ensure DocTest does not alter __builtins__
The DocTest Safety seems to fails and we need our own overlay. Maybe we are
using it wrong?
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | testlib.py | 9 |
2 files changed, 9 insertions, 2 deletions
@@ -3,7 +3,7 @@ ChangeLog for logilab.common -- * new `registry` module containing a backport of CubicWeb selectable objects registry (closes #84654) - + * testlib: DocTestCase fix builtins pollution after doctest execution. 2011-10-28 -- 0.57.1 * daemon: change $HOME after dropping privileges (closes #81297) @@ -1214,7 +1214,14 @@ class DocTest(TestCase): suite = doctest.DocTestSuite(self.module) except AttributeError: suite = SkippedSuite() - return suite.run(result) + # doctest may gork the builtins dictionnary + # This happen to the "_" entry used by gettext + old_builtins = __builtins__.copy() + try: + return suite.run(result) + finally: + __builtins__.clear() + __builtins__.update(old_builtins) run = __call__ def test(self): |