Skip to content

Commit

Permalink
Normalize paths
Browse files Browse the repository at this point in the history
Fixes #364.

Signed-off-by: Stephen Finucane <stephen@that.guru>
  • Loading branch information
stephenfin committed Aug 28, 2024
1 parent 3862766 commit ce6550a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stestr/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import functools
import io
import os
import os.path
import subprocess
import sys

Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions stestr/tests/test_return_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ce6550a

Please sign in to comment.