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
This commit is contained in:
parent
7ede3ec4b1
commit
dbfba6a20e
|
@ -37,13 +37,18 @@ def run_micropython(pyb, args, test_file):
|
||||||
with open(test_file, 'rb') as f:
|
with open(test_file, 'rb') as f:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
if line.startswith(b'# cmdline:'):
|
if line.startswith(b'# cmdline:'):
|
||||||
args += line[10:].strip().split()
|
# subprocess.check_output on Windows only accepts strings, not bytes
|
||||||
|
args += [str(c, 'utf-8') for c in line[10:].strip().split()]
|
||||||
|
|
||||||
# run the test, possibly with redirected input
|
# run the test, possibly with redirected input
|
||||||
try:
|
try:
|
||||||
if test_file.startswith('cmdline/repl_'):
|
if test_file.startswith('cmdline/repl_'):
|
||||||
# Need to use a PTY to test command line editing
|
# Need to use a PTY to test command line editing
|
||||||
|
try:
|
||||||
import pty
|
import pty
|
||||||
|
except ImportError:
|
||||||
|
# in case pty module is not available, like on Windows
|
||||||
|
return b'SKIP\n'
|
||||||
import select
|
import select
|
||||||
|
|
||||||
def get():
|
def get():
|
||||||
|
|
Loading…
Reference in New Issue