Skip to content

Commit dbfba6a

Browse files
stinosdpgeorge
authored andcommitted
tests: Fix exceptions when running cmdline tests on windows
- subprocess.check_output can only handle strings on windows, not bytes, so convert the arguments as such - the pty module is for posix systems only so skip the tests needing it in case it is not available
1 parent 7ede3ec commit dbfba6a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/run-tests

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ def run_micropython(pyb, args, test_file):
3737
with open(test_file, 'rb') as f:
3838
line = f.readline()
3939
if line.startswith(b'# cmdline:'):
40-
args += line[10:].strip().split()
40+
# subprocess.check_output on Windows only accepts strings, not bytes
41+
args += [str(c, 'utf-8') for c in line[10:].strip().split()]
4142

4243
# run the test, possibly with redirected input
4344
try:
4445
if test_file.startswith('cmdline/repl_'):
4546
# Need to use a PTY to test command line editing
46-
import pty
47+
try:
48+
import pty
49+
except ImportError:
50+
# in case pty module is not available, like on Windows
51+
return b'SKIP\n'
4752
import select
4853

4954
def get():

0 commit comments

Comments
 (0)