Skip to content

Commit 2dca6e5

Browse files
voidusblueyed
authored andcommitted
Avoid OSError during django path detection
See #641
1 parent b7c7c1c commit 2dca6e5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pytest_django/plugin.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,14 @@ def _add_django_project_to_path(args):
122122
def is_django_project(path):
123123
return path.is_dir() and (path / 'manage.py').exists()
124124

125+
def arg_to_path(arg):
126+
# Test classes or functions can be appended to paths separated by ::
127+
arg = arg.split("::", 1)[0]
128+
return pathlib.Path(arg)
129+
125130
def find_django_path(args):
126-
args = [pathlib.Path(x) for x in args if not str(x).startswith("-")]
131+
args = map(str, args)
132+
args = [arg_to_path(x) for x in args if not x.startswith("-")]
127133
args = [p for p in args if p.is_dir()]
128134

129135
if not args:

0 commit comments

Comments
 (0)