Skip to content

Commit

Permalink
Fix incorrect usage of os.path.sep in rewrite.py
Browse files Browse the repository at this point in the history
os.path.sep is not an official API, and is probably result of it being imported (and so available), however it seems that is not the case on all systems,

I git blamed this on me, and I'm sure it was an accident (I probably meant `os.sep.join`), but let's go with `os.path.join` as that's the sane thing to do.

Fix pytest-dev#9791
  • Loading branch information
nicoddemus committed Jun 26, 2022
1 parent 11fb5cd commit 6951af3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/9791.bugfix.rst
@@ -0,0 +1 @@
Fixed a path handling code in ``rewrite.py`` that seems to work fine, but was incorrect and fails in some systems.
2 changes: 1 addition & 1 deletion src/_pytest/assertion/rewrite.py
Expand Up @@ -190,7 +190,7 @@ def _early_rewrite_bailout(self, name: str, state: "AssertionState") -> bool:
return False

# For matching the name it must be as if it was a filename.
path = PurePath(os.path.sep.join(parts) + ".py")
path = PurePath(os.path.join(*parts) + ".py")

for pat in self.fnpats:
# if the pattern contains subdirectories ("tests/**.py" for example) we can't bail out based
Expand Down

0 comments on commit 6951af3

Please sign in to comment.