Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix nondeterministic test failures on Python 3.3
See http://docs.python.org/3/library/importlib#importlib.invalidate_caches:

  "This function should be called if any modules are created/installed
  while your program is running to guarantee all finders will notice the
  new module’s existence."
  • Loading branch information
mgedmin committed Jun 6, 2013
1 parent 5abbe6d commit 4345fdc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Expand Up @@ -9,6 +9,11 @@ Post-mortem debugging also works when there is an import failure.
>>> def write_file(filename, body):
... with open(os.path.join(dir, filename), 'w') as f:
... f.write(body)
... try:
... # Need to do this on Python 3.3 after creating new modules
... import importlib; importlib.invalidate_caches()
... except (ImportError, AttributeError):
... pass

>>> write_file('tests.py',
... '''
Expand Down
Expand Up @@ -8,6 +8,11 @@ setup.
>>> def write_file(filename, body):
... with open(os.path.join(dir, filename), 'w') as f:
... f.write(body)
... try:
... # Need to do this on Python 3.3 after creating new modules
... import importlib; importlib.invalidate_caches()
... except (ImportError, AttributeError):
... pass

>>> write_file('tests.py',
... '''
Expand Down

0 comments on commit 4345fdc

Please sign in to comment.