Skip to content

Commit

Permalink
receives the current active interpreter from main_interpreter.executable
Browse files Browse the repository at this point in the history
- needs the spyder upstream fixes
  • Loading branch information
maurerle committed May 17, 2022
1 parent b788ad9 commit ab3429a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions spyder_unittest/backend/pytestrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def create_argument_list(self):
pyfile = os.path.join(os.path.dirname(__file__), 'pytestworker.py')
return [pyfile, str(self.reader.port)]

def start(self, config, pythonpath):
def start(self, config, executable, pythonpath):
"""Start process which will run the unit test suite."""
self.config = config
self.reader = ZmqStreamReader()
self.reader.sig_received.connect(self.process_output)
RunnerBase.start(self, config, pythonpath)
super().start(self, config, executable, pythonpath)

def process_output(self, output):
"""
Expand Down
4 changes: 1 addition & 3 deletions spyder_unittest/backend/runnerbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from qtpy.QtCore import (QObject, QProcess, QProcessEnvironment, QTextCodec,
Signal)
from spyder.py3compat import to_text_string
from spyder.utils.misc import get_python_executable

try:
from importlib.util import find_spec as find_spec_or_loader
Expand Down Expand Up @@ -189,7 +188,7 @@ def _prepare_process(self, config, pythonpath):
process.setProcessEnvironment(env)
return process

def start(self, config, pythonpath):
def start(self, config, executable, pythonpath):
"""
Start process which will run the unit test suite.
Expand All @@ -212,7 +211,6 @@ def start(self, config, pythonpath):
If process failed to start.
"""
self.process = self._prepare_process(config, pythonpath)
executable = get_python_executable()
p_args = self.create_argument_list()
try:
os.remove(self.resultfilename)
Expand Down
4 changes: 2 additions & 2 deletions spyder_unittest/backend/tests/test_pytestrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def test_pytestrunner_start(monkeypatch):

runner = PyTestRunner(None, 'results')
config = Config()
runner.start(config, ['pythondir'])
runner.start(config, 'python', ['pythondir'])
assert runner.config is config
assert runner.reader is mock_reader
runner.reader.sig_received.connect.assert_called_once_with(
runner.process_output)
MockRunnerBase.start.assert_called_once_with(runner, config, ['pythondir'])
MockRunnerBase.start.assert_called_once_with(runner, config, 'python', ['pythondir'])


def test_pytestrunner_process_output_with_collected(qtbot):
Expand Down
6 changes: 1 addition & 5 deletions spyder_unittest/backend/tests/test_runnerbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,13 @@ def test_runnerbase_start(monkeypatch):
monkeypatch.setattr('spyder_unittest.backend.runnerbase.os.remove',
mock_remove)

monkeypatch.setattr(
'spyder_unittest.backend.runnerbase.get_python_executable',
lambda: 'python')

runner = RunnerBase(None, 'results')
runner._prepare_process = lambda c, p: mock_process
runner.create_argument_list = lambda: ['arg1', 'arg2']
config = Config('pytest', 'wdir')
mock_process.waitForStarted = lambda: False
with pytest.raises(RuntimeError):
runner.start(config, ['pythondir'])
runner.start(config, 'python', ['pythondir'])

mock_process.start.assert_called_once_with('python', ['arg1', 'arg2'])
mock_remove.assert_called_once_with('results')
4 changes: 2 additions & 2 deletions spyder_unittest/widgets/unittestgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ def run_tests(self, config=None):
self.testrunner.sig_starttest.connect(self.tests_started)
self.testrunner.sig_testresult.connect(self.tests_yield_result)
self.testrunner.sig_stop.connect(self.tests_stopped)

executable = self.get_conf('executable', section='main_interpreter')
try:
self.testrunner.start(config, pythonpath)
self.testrunner.start(config, executable, pythonpath)
except RuntimeError:
QMessageBox.critical(self,
_("Error"), _("Process failed to start"))
Expand Down

0 comments on commit ab3429a

Please sign in to comment.