Skip to content

Commit b0f0496

Browse files
committed
Merge pull request #582 from bpython/fix-rutime-import-test
fix run order-dependant test failure
2 parents 9b6aa7b + 9966986 commit b0f0496

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

bpython/test/test_curtsies_repl.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
from bpython.test import (FixLanguageTestCase as TestCase, MagicIterMock, mock,
2121
builtin_target, unittest)
2222

23+
if py3:
24+
from importlib import invalidate_caches
25+
else:
26+
def invalidate_caches():
27+
"""Does not exist before Python 3.3"""
28+
2329

2430
def setup_config(conf):
2531
config_struct = config.Struct()
@@ -292,6 +298,20 @@ def setUp(self):
292298
self.dont_write_bytecode = sys.dont_write_bytecode
293299
sys.dont_write_bytecode = True
294300

301+
# Because these tests create Python source files at runtime,
302+
# it's possible for the importlib.machinery.FileFinder for
303+
# a directory to have an outdated cache in the following situation:
304+
# * a module in that directory is imported,
305+
# * then a new module is created in that directory,
306+
# * then that new module is imported.
307+
#
308+
# invalidate_cache() is used to prevent this.
309+
#
310+
# see https://docs.python.org/3/library/importlib.html
311+
# sections #importlib.machinery.FileFinder and
312+
# #importlib.invalidate_caches
313+
invalidate_caches()
314+
295315
def tearDown(self):
296316
sys.dont_write_bytecode = self.dont_write_bytecode
297317

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy