Skip to content

Commit b11d9c4

Browse files
author
deathaxe
committed
Monkey patch coverage on MacOS
1 parent 500ad5a commit b11d9c4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

unittesting/unit.py

+21
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@
1010

1111
try:
1212
import coverage
13+
14+
# ST4 does not ship `_sysconfigdata__darwin_darwin` module, required by
15+
# coverage 7.x on MacOS, which causes `sysconfig.add_paths()` to fail.
16+
# On other OSs it returns potentially unwanted paths outside of ST ecosystem.
17+
# Thus monkey patch it.
18+
try:
19+
import coverage.inorout
20+
21+
def __add_third_party_paths(paths):
22+
"""Return $data/Lib/pythonXY as 3rd-party path."""
23+
libs_path = os.path.join(
24+
os.path.dirname(sublime.packages_path()),
25+
"Lib",
26+
"python{}{}".format(sys.version_info.major, sys.version_info.minor)
27+
)
28+
paths.add(libs_path)
29+
30+
coverage.inorout.add_third_party_paths = __add_third_party_paths
31+
except:
32+
pass
33+
1334
except Exception:
1435
coverage = False
1536

0 commit comments

Comments
 (0)