Skip to content

Commit 705f32f

Browse files
committed
unif-ffi/unittest: Make path handling compatible with backslashes.
1 parent d03a6db commit 705f32f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

unix-ffi/unittest/unittest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,14 @@ def discover(runner: TestRunner):
481481
return discover(runner=runner)
482482

483483

484+
def split_path(path):
485+
path = path.replace("\\", "/")
486+
if "/" in path:
487+
return path.rsplit("/", 1)
488+
else:
489+
return ".", path
490+
491+
484492
def main(module="__main__", testRunner=None):
485493
if testRunner:
486494
if isinstance(testRunner, type):
@@ -500,16 +508,12 @@ def main(module="__main__", testRunner=None):
500508
result = discover(runner)
501509
# If there's one argument assume it's the path to the script which called main(), so run its tests.
502510
elif argn == 1:
503-
result = run_module(runner, module, sys.argv[0].rsplit("/", 1)[0], None)
511+
result = run_module(runner, module, split_path(sys.argv[0])[0], None)
504512
else:
505513
for test_spec in sys.argv[1:]:
506514
try:
507515
uos.stat(test_spec)
508-
# test_spec is a local file, run it directly
509-
if "/" in test_spec:
510-
path, fname = test_spec.rsplit("/", 1)
511-
else:
512-
path, fname = ".", test_spec
516+
path, fname = split_path(test_spec)
513517
modname = fname.rsplit(".", 1)[0]
514518
result = run_module(runner, modname, path, None)
515519

0 commit comments

Comments
 (0)