def clean_local_file_imports(self): """Clean up the results of calls to `import_local_file`. Use this if you need to `import_local_file` the same file twice in one test. """ # So that we can re-import files, clean them out first. self.cleanup_modules() # Also have to clean out the .pyc file, since the timestamp # resolution is only one second, a changed file might not be # picked up. for pyc in glob.glob('*.pyc'): os.remove(pyc) if os.path.exists("__pycache__"): shutil.rmtree("__pycache__") invalidate_import_caches()
def clean_local_file_imports(self): """Clean up the results of calls to `import_local_file`. Use this if you need to `import_local_file` the same file twice in one test. """ # So that we can re-import files, clean them out first. self.cleanup_modules() # Also have to clean out the .pyc file, since the timestamp # resolution is only one second, a changed file might not be # picked up. remove_files("*.pyc", "*$py.class") if os.path.exists("__pycache__"): shutil.rmtree("__pycache__") invalidate_import_caches()