Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
frichtarik committed Jun 22, 2024
1 parent a071a04 commit 0771bf1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
package_dir={"": "src"},
include_package_data=True,
entry_points={},
tests_require=["pytest", "pytest-cov", "pre-commit"],
tests_require=["pytest", "pytest-cov", "pytest-mock", "pre-commit"],
)
16 changes: 15 additions & 1 deletion tests/test_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from scantree import DirEntryReplacement
from scantree.test_utils import assert_dir_entry_equal
from scantree.test_utils import assert_dir_entry_equal, convert_path


class MockStat:
Expand Down Expand Up @@ -44,3 +44,17 @@ def test_not_equal(self, kwargs):
setattr(de_different, k, v)
with pytest.raises(AssertionError):
assert_dir_entry_equal(de, de_different)

def test_convert_path_windows(self, mocker):
mocker.patch('os.name', 'nt')
self.assertEqual(convert_path("path/to/file"), "path\\to\\file")
self.assertEqual(convert_path("another/path/to/file"), "another\\path\\to\\file")
self.assertEqual(convert_path("already\\windows\\path"), "already\\windows\\path")
self.assertEqual(convert_path(""), "")

def test_convert_path_non_windows(self, mocker):
mocker.patch('os.name', 'posix')
self.assertEqual(convert_path("path\\to\\file"), "path/to/file")
self.assertEqual(convert_path("another\\path\\to\\file"), "another/path/to/file")
self.assertEqual(convert_path("already/unix/path"), "already/unix/path")
self.assertEqual(convert_path(""), "")
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ envlist = pre-commit,py{38,39,310,311,312}
deps =
pytest
pytest-cov
pytest-mock
commands =
pytest --cov=scantree --cov-report=xml --cov-report=term-missing --cov-config=.coveragerc {posargs:tests}

Expand Down

0 comments on commit 0771bf1

Please sign in to comment.