|
5 | 5 |
|
6 | 6 | import os
|
7 | 7 | import os.path
|
| 8 | +from unittest import mock |
8 | 9 |
|
9 | 10 | import pytest
|
10 | 11 |
|
11 |
| -from coverage import env |
12 |
| -from coverage import files |
| 12 | +from coverage import env, files |
13 | 13 | from coverage.exceptions import ConfigError
|
14 |
| -from coverage.files import ( |
15 |
| - TreeMatcher, FnmatchMatcher, ModuleMatcher, PathAliases, |
16 |
| - find_python_files, abs_file, actual_path, flat_rootname, fnmatches_to_regex, |
17 |
| -) |
18 |
| - |
| 14 | +from coverage.files import (FnmatchMatcher, ModuleMatcher, PathAliases, TreeMatcher, abs_file, |
| 15 | + actual_path, find_python_files, flat_rootname, fnmatches_to_regex) |
19 | 16 | from tests.coveragetest import CoverageTest
|
20 | 17 |
|
21 | 18 |
|
@@ -67,6 +64,19 @@ def test_canonical_filename_ensure_cache_hit(self):
|
67 | 64 | assert 'sub/proj1/file1.py' in files.CANONICAL_FILENAME_CACHE
|
68 | 65 | assert files.canonical_filename('sub/proj1/file1.py') == self.abs_path('file1.py')
|
69 | 66 |
|
| 67 | + @pytest.mark.parametrize( |
| 68 | + ["curdir", "sep"], [ |
| 69 | + ("/", "/"), |
| 70 | + ("X:\\", "\\"), |
| 71 | + ] |
| 72 | + ) |
| 73 | + def test_relative_dir_for_root(self, curdir, sep): |
| 74 | + with mock.patch.object(files.os, 'curdir', new=curdir): |
| 75 | + with mock.patch.object(files.os, 'sep', new=sep): |
| 76 | + with mock.patch('coverage.files.os.path.normcase', return_value=curdir): |
| 77 | + files.set_relative_directory() |
| 78 | + assert files.relative_directory() == curdir |
| 79 | + |
70 | 80 |
|
71 | 81 | @pytest.mark.parametrize("original, flat", [
|
72 | 82 | ("abc.py", "abc_py"),
|
|
0 commit comments