mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
Issue #11049: fix test_forget to work on installed Python, by using a temporary module for import/forget
This commit is contained in:
parent
d9c665b60e
commit
8db645f722
1 changed files with 11 additions and 3 deletions
|
|
@ -55,9 +55,17 @@ def test_rmtree(self):
|
|||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue