Skip to content

Commit

Permalink
A file disappeared after it's source has bean read should also be han…
Browse files Browse the repository at this point in the history
…dled gracefully.
  • Loading branch information
tarpas committed Jul 13, 2023
1 parent 043096e commit 93456ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion testmon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""PYTEST_DONT_REWRITE"""
VERSION = "2.0.11"
VERSION = "2.0.12"
21 changes: 12 additions & 9 deletions testmon/testmon_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,18 @@ def get_file(self, filename):
if filename not in self.cache:
code, fsha = get_source_sha(directory=self.rootdir, filename=filename)
if fsha:
fs_mtime = os.path.getmtime(os.path.join(self.rootdir, filename))
self.cache[filename] = Module(
source_code=code,
mtime=fs_mtime,
ext=filename.rsplit(".", 1)[1],
fs_fsha=fsha,
filename=filename,
rootdir=self.rootdir,
)
try:
fs_mtime = os.path.getmtime(os.path.join(self.rootdir, filename))
self.cache[filename] = Module(
source_code=code,
mtime=fs_mtime,
ext=filename.rsplit(".", 1)[1],
fs_fsha=fsha,
filename=filename,
rootdir=self.rootdir,
)
except FileNotFoundError:
self.cache[filename] = None
else:
self.cache[filename] = None
return self.cache[filename]
Expand Down

0 comments on commit 93456ed

Please sign in to comment.