summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2020-02-03 18:40:23 +0100
committerDaniel Hahler <git@thequod.de>2020-02-03 19:09:08 +0100
commit61f2a26675561d510ab4f736a5b3c5d4f8aa043c (patch)
tree94db397b8a07407904d169f2e49fbd27d009f181 /testing
parentb0d45267c58859bcb79f7ab980f4b410c4bbd109 (diff)
downloadpytest-61f2a26675561d510ab4f736a5b3c5d4f8aa043c.tar.gz
Code/getfslineno: keep empty co_filename
Previously this would be turned via `py.path.local("")` into the current working directory. This appears to be what `fspath = fn and py.path.local(fn) or None` tries to avoid in `getfslineno`'s `TypeError` handling already, if `Code` would raise it.
Diffstat (limited to 'testing')
-rw-r--r--testing/code/test_source.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/testing/code/test_source.py b/testing/code/test_source.py
index b5efdb317..cf0930974 100644
--- a/testing/code/test_source.py
+++ b/testing/code/test_source.py
@@ -524,6 +524,14 @@ def test_getfslineno() -> None:
B.__name__ = "B2"
assert getfslineno(B)[1] == -1
+ co = compile("...", "", "eval")
+ assert co.co_filename == ""
+
+ if hasattr(sys, "pypy_version_info"):
+ assert getfslineno(co) == ("", -1)
+ else:
+ assert getfslineno(co) == ("", 0)
+
def test_code_of_object_instance_with_call() -> None:
class A: