Skip to content

Commit

Permalink
Fix path manipulations on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jitseniesen committed Jun 21, 2023
1 parent 5bc58b9 commit 0496dd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ jobs:
shell: bash
command: |
. ~/.profile
pytest spyder_unittest -x -vv
pytest spyder_unittest -vv
- name: Run tests (Windows)
if: matrix.OS == 'windows'
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: pytest spyder_unittest -x -vv
command: pytest spyder_unittest -vv
4 changes: 2 additions & 2 deletions spyder_unittest/backend/pytestrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def normalize_module_name(self, name: str) -> str:

if name.endswith('.py'):
name = name[:-3]
return name.replace('/', '.')
return name.replace(osp.sep, '.')

def convert_nodeid_to_testname(self, nodeid: str) -> str:
"""Convert a nodeid to a test name."""
Expand All @@ -192,7 +192,7 @@ def convert_testname_to_nodeid(self, testname: str) -> str:
"""
*path_parts, last_part = testname.split('.')
path_parts[-1] += '.py'
nodeid = '/'.join(path_parts) + '::' + last_part
nodeid = osp.join(*path_parts) + '::' + last_part
return nodeid

def logreport_collecterror_to_tuple(
Expand Down
10 changes: 5 additions & 5 deletions spyder_unittest/backend/tests/test_pytestrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def test_pytestrunner_finished(qtbot, exitcode, normal_exit):

@pytest.mark.parametrize('wdir, expected', [
('ham', 'spam.eggs'),
('ham/spam', 'eggs'),
('link-to-ham/spam', 'eggs')])
(osp.join('ham', 'spam'), 'eggs'),
(osp.join('link-to-ham', 'spam'), 'eggs')])
def test_normalize_module_name(runner, wdir, expected):
def new_realpath(name):
"""Simulate link from `link-to-ham` to `ham`"""
Expand All @@ -133,19 +133,19 @@ def new_realpath(name):
with patch('spyder_unittest.backend.pytestrunner.osp.realpath',
side_effect=new_realpath):
runner.config = Config(wdir=wdir)
result = runner.normalize_module_name('spam/eggs.py')
result = runner.normalize_module_name(osp.join('spam', 'eggs.py'))
assert result == expected


def test_convert_nodeid_to_testname(runner):
nodeid = 'spam/eggs.py::test_foo'
nodeid = osp.join('spam', 'eggs.py') + '::test_foo'
testname = 'spam.eggs.test_foo'
result = runner.convert_nodeid_to_testname(nodeid)
assert result == testname


def test_convert_testname_to_nodeid(runner):
nodeid = 'spam/eggs.py::test_foo'
nodeid = osp.join('spam', 'eggs.py') + '::test_foo'
testname = 'spam.eggs.test_foo'
result = runner.convert_testname_to_nodeid(testname)
assert result == nodeid
Expand Down

0 comments on commit 0496dd8

Please sign in to comment.