Fix assertion rewriter crash if cwd changes mid-testing
Unfortunately we need to get a `py.path.local` object to perform the fnmatch operation, it is different from the standard `fnmatch` module because it implements its own custom logic. So we need to use `py.path` to perform the fnmatch for backward compatibility reasons. Ideally we should be able to use a "pure path" in `pathlib` terms (a path not bound to the file system), but we don't have those in pylib. Fix #3973
This commit is contained in:
@@ -199,7 +199,11 @@ class AssertionRewritingHook(object):
|
||||
|
||||
# For matching the name it must be as if it was a filename.
|
||||
parts[-1] = parts[-1] + ".py"
|
||||
fn_pypath = py.path.local(os.path.sep.join(parts))
|
||||
try:
|
||||
fn_pypath = py.path.local(os.path.sep.join(parts))
|
||||
except EnvironmentError:
|
||||
return False
|
||||
|
||||
for pat in self.fnpats:
|
||||
# if the pattern contains subdirectories ("tests/**.py" for example) we can't bail out based
|
||||
# on the name alone because we need to match against the full path
|
||||
|
||||
Reference in New Issue
Block a user