summaryrefslogtreecommitdiff
path: root/tests/test_files.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_files.py')
-rw-r--r--tests/test_files.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/test_files.py b/tests/test_files.py
index 5588c373..28a98fb8 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -5,17 +5,14 @@
import os
import os.path
+from unittest import mock
import pytest
-from coverage import env
-from coverage import files
+from coverage import env, files
from coverage.exceptions import ConfigError
-from coverage.files import (
- TreeMatcher, FnmatchMatcher, ModuleMatcher, PathAliases,
- find_python_files, abs_file, actual_path, flat_rootname, fnmatches_to_regex,
-)
-
+from coverage.files import (FnmatchMatcher, ModuleMatcher, PathAliases, TreeMatcher, abs_file,
+ actual_path, find_python_files, flat_rootname, fnmatches_to_regex)
from tests.coveragetest import CoverageTest
@@ -67,6 +64,19 @@ class FilesTest(CoverageTest):
assert 'sub/proj1/file1.py' in files.CANONICAL_FILENAME_CACHE
assert files.canonical_filename('sub/proj1/file1.py') == self.abs_path('file1.py')
+ @pytest.mark.parametrize(
+ ["curdir", "sep"], [
+ ("/", "/"),
+ ("X:\\", "\\"),
+ ]
+ )
+ def test_relative_dir_for_root(self, curdir, sep):
+ with mock.patch.object(files.os, 'curdir', new=curdir):
+ with mock.patch.object(files.os, 'sep', new=sep):
+ with mock.patch('coverage.files.os.path.normcase', return_value=curdir):
+ files.set_relative_directory()
+ assert files.relative_directory() == curdir
+
@pytest.mark.parametrize("original, flat", [
("abc.py", "abc_py"),