Skip to content

Commit cff4414

Browse files
Copilotasfaltboy
andauthored
fix: resolve all CI test failures for Python 3.11+ compatibility
Agent-Logs-Url: https://github.com/asfaltboy/SublimeTestPlier/sessions/1fd285bd-0c6a-4000-8a65-599b99bf602d Co-authored-by: asfaltboy <321520+asfaltboy@users.noreply.github.com>
1 parent 83a88e9 commit cff4414

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

=7

Whitespace-only changes.

python_test_plier.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88

99
from . import utils
1010

11-
MYPY = False
12-
if MYPY:
13-
from typing import Optional
14-
1511

1612
class RunPythonTestsCommand(sublime_plugin.WindowCommand):
1713
external_runner = None
@@ -129,7 +125,10 @@ def get_command_kwargs(self, **addl_kwargs):
129125
venv_bin_path = '%s/bin' % venv_path
130126
kwargs['env']['PATH'] = venv_bin_path
131127
# merge path with Sublime's env PATH
132-
kwargs['env']['PATH'] = '%s:%s' % (kwargs['env'].get('PATH', ''), os.environ["PATH"])
128+
os_path = os.environ.get("PATH", "")
129+
combined_path = ':'.join(p for p in [kwargs['env'].get('PATH', ''), os_path] if p)
130+
if combined_path:
131+
kwargs['env']['PATH'] = combined_path
133132
utils._log("Current PATH is %s" % os.getenv("PATH"))
134133

135134
if 'working_dir' in kwargs:

test_parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ def parse(self, line):
112112

113113
def should_stop(self, node):
114114
assert self.lineno, 'line number required'
115-
if node.lineno > self.lineno:
115+
first_lineno = node.lineno
116+
if getattr(node, 'decorator_list', None):
117+
first_lineno = node.decorator_list[0].lineno
118+
if first_lineno > self.lineno:
116119
self._log("Stop parsing node lineno %s / our lineno %s" % (
117120
node.lineno, self.lineno))
118121
return True

tests/test_command.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from unittest import TestCase, mock
2+
import os
23
import sys
34

45
from .sublime_mock import sublime, known_commands
@@ -43,6 +44,9 @@ def setUp(self):
4344
self.debug_patcher = mock.patch.object(utils, 'DEBUG', return_value=True)
4445
self.debug_patcher.start()
4546
self.addCleanup(self.debug_patcher.stop)
47+
self.path_patcher = mock.patch.dict(os.environ, {'PATH': ''})
48+
self.path_patcher.start()
49+
self.addCleanup(self.path_patcher.stop)
4650

4751
def tearDown(self):
4852
exec_cmd.reset_mock()
@@ -109,7 +113,8 @@ def test_custom_cmd_without_file(self):
109113
exec_cmd.assert_called_once_with(dict(
110114
working_dir='', env={}, cmd=['nosetests', '-k ']))
111115

112-
def test_custom_unittest_module_relative_to_project(self):
116+
@mock.patch('os.listdir', return_value=[])
117+
def test_custom_unittest_module_relative_to_project(self, listdir):
113118
self.view.file_name = mock.Mock(return_value='/SublimeTestPlier/tests/file.py')
114119
self.view.substr.return_value = self.mock_selection(2, 2)
115120
custom_kwargs = self.custom_kwargs.copy()
@@ -125,7 +130,8 @@ def test_custom_unittest_module_relative_to_project(self):
125130
working_dir='', env={},
126131
cmd=['unittest', 'tests.file.TestCase.test_fail', ]))
127132

128-
def test_custom_unittest_module_relative_to_working_dir(self):
133+
@mock.patch('os.listdir', return_value=[])
134+
def test_custom_unittest_module_relative_to_working_dir(self, listdir):
129135
self.view.file_name = mock.Mock(return_value='/SublimeTestPlier/tests/file.py')
130136
self.view.substr.return_value = self.mock_selection(2, 2)
131137
custom_kwargs = self.custom_kwargs.copy()

0 commit comments

Comments
 (0)