Skip to content

Commit 9966986

Browse files
Document why invalidate_caches needed
1 parent a108ee1 commit 9966986

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

bpython/test/test_curtsies_repl.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,19 @@ def setUp(self):
297297
self.open = partial(io.open, mode='wt', encoding='utf-8')
298298
self.dont_write_bytecode = sys.dont_write_bytecode
299299
sys.dont_write_bytecode = True
300+
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
300313
invalidate_caches()
301314

302315
def tearDown(self):

0 commit comments

Comments
 (0)