File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,16 +9,10 @@ It runs unittest testcases on local machines and via Github Actions.
99It also supports testing syntax_test files for the new [ sublime-syntax] ( https://www.sublimetext.com/docs/3/syntax.html )
1010format and sublime-color-scheme files.
1111
12-
1312## Sublime Text 4
1413
1514Sublime Text 4 is now supported and testing works for Python 3.8 packages.
1615
17- > [ !NOTE]
18- >
19- > coverage 7.x is currently skipped for python 3.8 plugins on MacOS,
20- > because ST4 is missing a required core module.
21-
2216## Preparation
2317
24181 . Install [ UnitTesting] ( https://github.com/SublimeText/UnitTesting ) via Package Control.
Original file line number Diff line number Diff line change 88from unittest import TestSuite
99from unittest import TextTestRunner
1010
11- try :
12- if sys .platform == "darwin" :
13- raise ImportError ("unsupported" )
14- import coverage
15- except Exception :
16- coverage = False
17-
1811from .base import BaseUnittestingCommand
1912from .base import DONE_MESSAGE
2013from .core import DeferrableTestCase
2417from .utils import reload_package
2518from .utils import StdioSplitter
2619
20+ try :
21+ import coverage
22+
23+ # ST4 does not ship `_sysconfigdata__darwin_darwin` module, required by
24+ # coverage 7.x on MacOS, which causes `sysconfig.add_paths()` to fail.
25+ # On other OSs it returns potentially unwanted paths outside of ST ecosystem.
26+ # Thus monkey patch it.
27+ try :
28+ import coverage .inorout
29+
30+ def __add_third_party_paths (paths ):
31+ """Return $data/Lib/pythonXY as 3rd-party path."""
32+ libs_path = os .path .join (
33+ os .path .dirname (sublime .packages_path ()),
34+ "Lib" ,
35+ "python{}{}" .format (sys .version_info .major , sys .version_info .minor )
36+ )
37+ paths .add (libs_path )
38+
39+ coverage .inorout .add_third_party_paths = __add_third_party_paths
40+ except :
41+ pass
42+ except Exception :
43+ coverage = False
44+
2745
2846class UnitTestingCommand (BaseUnittestingCommand ):
2947
You can’t perform that action at this time.
0 commit comments