[Python-checkins] cpython: Issue #11049: fix test_forget to work on installed Python, by using a temporary
eli.bendersky
python-checkins at python.org
Tue Aug 2 05:27:26 CEST 2011
http://hg.python.org/cpython/rev/1a978892a105
changeset: 71686:1a978892a105
parent: 71684:d168f439a14f
user: Eli Bendersky <eliben at gmail.com>
date: Tue Aug 02 06:24:31 2011 +0300
summary:
Issue #11049: fix test_forget to work on installed Python, by using a temporary module for import/forget
files:
Lib/test/test_support.py | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -55,9 +55,17 @@
support.rmtree(TESTDIRN)
def test_forget(self):
- import smtplib
- support.forget("smtplib")
- self.assertNotIn("smtplib", sys.modules)
+ mod_filename = TESTFN + '.py'
+ with open(mod_filename, 'w') as f:
+ print('foo = 1', file=f)
+ try:
+ mod = __import__(TESTFN)
+ self.assertIn(TESTFN, sys.modules)
+
+ support.forget(TESTFN)
+ self.assertNotIn(TESTFN, sys.modules)
+ finally:
+ support.unlink(mod_filename)
def test_HOST(self):
s = socket.socket()
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list