Skip to content

Commit 07ded4b

Browse files
committed
fix tests for new args
1 parent 4e5fa93 commit 07ded4b

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

PyStemmusScope/stemmus_scope.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def run(self) -> str:
169169
eval_code= f'STEMMUS_SCOPE_exe({path_to_config});exit;'
170170
args = ["matlab", "-r", eval_code, "-nodisplay", "-nosplash", "-nodesktop"]
171171
# seperate args dont work on linux!
172-
if utils.os_name !="nt":
172+
if utils.os_name() !="nt":
173173
args = shlex.join(args)
174174
result = _run_sub_process(args, self.model_src)
175175
if self.sub_process=="Octave":
@@ -182,7 +182,7 @@ def run(self) -> str:
182182
eval_code = f'STEMMUS_SCOPE_exe({path_to_config});exit;'
183183
args = ["octave", "--eval", eval_code, "--no-gui", "--silent"]
184184
# seperate args dont work on linux!
185-
if utils.os_name !="nt":
185+
if utils.os_name() !="nt":
186186
args = shlex.join(args)
187187
result = _run_sub_process(args, self.model_src)
188188
return result

tests/test_stemmus_scope.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import os
2+
import shlex
3+
import subprocess
14
from pathlib import Path
25
from unittest.mock import patch
3-
46
import pytest
5-
6-
import os
7-
import subprocess
87
from PyStemmusScope import StemmusScope
98
from PyStemmusScope import config_io
9+
from PyStemmusScope import utils
1010
from . import data_folder
1111

1212

@@ -200,11 +200,14 @@ def test_run_matlab(self, mocked_popen, model_with_setup, tmp_path):
200200
result = model.run()
201201

202202
path_to_config = f"'{actual_cfg_file}'"
203-
command_line = f'matlab -r "STEMMUS_SCOPE_exe({path_to_config});exit;"'
204-
expected = [command_line, "-nodisplay", "-nosplash", "-nodesktop"]
203+
eval_code= f'STEMMUS_SCOPE_exe({path_to_config});exit;'
204+
args = ["matlab", "-r", eval_code, "-nodisplay", "-nosplash", "-nodesktop"]
205+
# seperate args dont work on linux!
206+
if utils.os_name() !="nt":
207+
args = shlex.join(args)
205208

206209
mocked_popen.assert_called_with(
207-
expected, cwd=tmp_path,
210+
args, cwd=tmp_path,
208211
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
209212
shell=True,
210213
)
@@ -248,11 +251,16 @@ def test_run_matlab(self, mocked_popen, model_with_setup, tmp_path):
248251
result = model.run()
249252

250253
path_to_config = f"'{actual_cfg_file}'"
251-
command_line = f'octave --eval "STEMMUS_SCOPE_exe({path_to_config});exit;"'
252-
expected = [command_line, "--no-gui", "--silent"]
254+
# fix for windows
255+
path_to_config = path_to_config.replace("\\", "/")
256+
eval_code = f'STEMMUS_SCOPE_exe({path_to_config});exit;'
257+
args = ["octave", "--eval", eval_code, "--no-gui", "--silent"]
258+
# seperate args dont work on linux!
259+
if utils.os_name() !="nt":
260+
args = shlex.join(args)
253261

254262
mocked_popen.assert_called_with(
255-
expected, cwd=tmp_path,
263+
args, cwd=tmp_path,
256264
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
257265
shell=True,
258266
)

0 commit comments

Comments
 (0)