summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-06-27 08:32:32 -0700
committerAnthony Sottile <asottile@umich.edu>2019-06-27 08:32:32 -0700
commit3e0e31a3647760f05b4f546a829240686bacef83 (patch)
tree5404024b64831fa210a7bcf63800e8c9a84b1106 /src
parentc9923a3a5ce7e1af7e4662608fdd0fec16c78481 (diff)
downloadpytest-3e0e31a3647760f05b4f546a829240686bacef83.tar.gz
Don't crash with --pyargs and a filename that looks like a module
Diffstat (limited to 'src')
-rw-r--r--src/_pytest/main.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/_pytest/main.py b/src/_pytest/main.py
index 73648557e..f28bc68db 100644
--- a/src/_pytest/main.py
+++ b/src/_pytest/main.py
@@ -631,7 +631,10 @@ class Session(nodes.FSCollector):
"""Convert a dotted module name to path."""
try:
spec = importlib.util.find_spec(x)
- except (ValueError, ImportError):
+ # AttributeError: looks like package module, but actually filename
+ # ImportError: module does not exist
+ # ValueError: not a module name
+ except (AttributeError, ImportError, ValueError):
return x
if spec is None or spec.origin in {None, "namespace"}:
return x