summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Yves David <pierre-yves.david@logilab.fr>2012-03-15 13:34:02 +0100
committerPierre-Yves David <pierre-yves.david@logilab.fr>2012-03-15 13:34:02 +0100
commit70683711afccf2d454b81b7903112c8f09f73fcd (patch)
tree4cd45689b91a82a70d78ad5765e8b5e8b6142958
parent3b9dd6354f85ed67ef7733b26fe87887cac49dc8 (diff)
downloadlogilab-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--ChangeLog2
-rw-r--r--testlib.py9
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index eb43a1d..108f346 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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)
diff --git a/testlib.py b/testlib.py
index da49387..ca452ca 100644
--- a/testlib.py
+++ b/testlib.py
@@ -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):