Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Document why invalidate_caches needed
  • Loading branch information
thomasballinger committed Dec 6, 2015
commit 9966986583cf4de5201b34943332922f5b80bcd5
13 changes: 13 additions & 0 deletions bpython/test/test_curtsies_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,19 @@ def setUp(self):
self.open = partial(io.open, mode='wt', encoding='utf-8')
self.dont_write_bytecode = sys.dont_write_bytecode
sys.dont_write_bytecode = True

# Because these tests create Python source files at runtime,
# it's possible for the importlib.machinery.FileFinder for
# a directory to have an outdated cache in the following situation:
# * a module in that directory is imported,
# * then a new module is created in that directory,
# * then that new module is imported.
#
# invalidate_cache() is used to prevent this.
#
# see https://docs.python.org/3/library/importlib.html
# sections #importlib.machinery.FileFinder and
# #importlib.invalidate_caches
invalidate_caches()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please document why invalidate_caches is called here?


def tearDown(self):
Expand Down