Skip to content

Commit e4ccac4

Browse files
committed
test(utils): Add test for filename_for_module
Fixes: GH-3515
1 parent 202caa3 commit e4ccac4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/utils/test_general.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,26 @@ def test_filename():
7474

7575
assert x("bogus", "bogus") == "bogus"
7676

77+
assert x("bogus", "bogus.pyc") == "bogus.py"
78+
7779
assert x("os", os.__file__) == "os.py"
7880

81+
assert x("foo.bar", "path/to/foo/bar.py") == "path/to/foo/bar.py"
82+
7983
import sentry_sdk.utils
8084

8185
assert x("sentry_sdk.utils", sentry_sdk.utils.__file__) == "sentry_sdk/utils.py"
8286

8387

88+
def test_filename_module_file_is_none():
89+
class DummyModule:
90+
__file__ = None
91+
92+
os.sys.modules["foo"] = DummyModule()
93+
94+
assert filename_for_module("foo.bar", "path/to/foo/bar.py") == "path/to/foo/bar.py"
95+
96+
8497
@pytest.mark.parametrize(
8598
"given,expected_envelope",
8699
[

0 commit comments

Comments
 (0)