From ce6550a7fecbba6ef88164ce6f66891db37cfa30 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 28 Aug 2024 11:55:13 +0100 Subject: [PATCH] Normalize paths Fixes #364. Signed-off-by: Stephen Finucane --- stestr/commands/run.py | 2 ++ stestr/tests/test_return_codes.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/stestr/commands/run.py b/stestr/commands/run.py index 8c02b24..61e464d 100644 --- a/stestr/commands/run.py +++ b/stestr/commands/run.py @@ -16,6 +16,7 @@ import functools import io import os +import os.path import subprocess import sys @@ -524,6 +525,7 @@ def run_command( if "::" in ids: ids = ids.replace("::", ".") if ids.find("/") != -1: + ids = os.path.normpath(ids) root = ids.replace(".py", "") ids = root.replace("/", ".") stestr_python = sys.executable diff --git a/stestr/tests/test_return_codes.py b/stestr/tests/test_return_codes.py index 99c1e3c..bea8a70 100644 --- a/stestr/tests/test_return_codes.py +++ b/stestr/tests/test_return_codes.py @@ -500,6 +500,22 @@ def test_run_no_discover_file_path_failing(self): self.assertIn(" - Failed: 2", lines) self.assertIn(" - Unexpected Success: 1", lines) + def test_run_no_discover_unnormalized_file_path(self): + passing_string = "tests//test_passing.py" + out, err = self.assertRunExit("stestr run -n %s" % passing_string, 0) + lines = out.decode("utf8").splitlines() + self.assertIn(" - Passed: 2", lines) + self.assertIn(" - Failed: 0", lines) + self.assertIn(" - Expected Fail: 1", lines) + + def test_run_no_discover_unnormalized_file_path_failing(self): + passing_string = "tests//test_failing.py" + out, err = self.assertRunExit("stestr run -n %s" % passing_string, 1) + lines = out.decode("utf8").splitlines() + self.assertIn(" - Passed: 0", lines) + self.assertIn(" - Failed: 2", lines) + self.assertIn(" - Unexpected Success: 1", lines) + class TestReturnCodesToxIni(TestReturnCodes): def setUp(self):