summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxBo <max.bohnet@tuhh.de>2017-09-30 15:23:19 +0200
committerMaxBo <max.bohnet@tuhh.de>2017-09-30 15:23:19 +0200
commit84a6a39bda9fc734d96f240afe643b374efefbcd (patch)
tree1af9f939d278c24a48cbb0bfa7876f07bc2d3362
parentf6736838959ad4277bc47ee3bbacb1a50319ba4b (diff)
downloadcython-84a6a39bda9fc734d96f240afe643b374efefbcd.tar.gz
use canonical_filename from coverage.files
-rw-r--r--Cython/Coverage.py38
1 files changed, 5 insertions, 33 deletions
diff --git a/Cython/Coverage.py b/Cython/Coverage.py
index 79aa10a58..ee921c118 100644
--- a/Cython/Coverage.py
+++ b/Cython/Coverage.py
@@ -13,6 +13,7 @@ import glob
from collections import defaultdict
from coverage.plugin import CoveragePlugin, FileTracer, FileReporter # requires coverage.py 4.0+
+from coverage.files import canonical_filename
from .Utils import find_root_package_dir, is_package_dir, open_source_file
@@ -42,37 +43,8 @@ def _find_dep_file_path(main_file, file_path):
for sys_path in sys.path:
test_path = os.path.realpath(os.path.join(sys_path, file_path))
if os.path.exists(test_path):
- return _get_actual_filename(test_path)
- return _get_actual_filename(abs_path)
-
-
-def _get_actual_filename(filepath):
- """
- on windows:
- search the file `filepath' on the file system
- and return it with the correct upper/lowercases
- on linux: return the filepath unmodified
-
- Parameters
- ----------
- filepath : str
-
- Returns
- -------
- filepath : str
- """
- if not sys.platform.startswith('win'):
- return filepath
- dirs = filepath.split('\\')
- # disk letter
- test_name = [dirs[0].upper()]
- for d in dirs[1:]:
- test_name.append("{}[{}]".format(d[:-1], d[-1]))
- res = glob.glob('\\'.join(test_name))
- if not res:
- #File not found
- return filepath
- return res[0]
+ return canonical_filename(test_path)
+ return canonical_filename(abs_path)
class Plugin(CoveragePlugin):
@@ -93,7 +65,7 @@ class Plugin(CoveragePlugin):
if filename.startswith('<') or filename.startswith('memory:'):
return None
c_file = py_file = None
- filename = _get_actual_filename(os.path.abspath(filename))
+ filename = canonical_filename(os.path.abspath(filename))
if self._c_files_map and filename in self._c_files_map:
c_file = self._c_files_map[filename][0]
@@ -121,7 +93,7 @@ class Plugin(CoveragePlugin):
# from coverage.python import PythonFileReporter
# return PythonFileReporter(filename)
- filename = _get_actual_filename(os.path.abspath(filename))
+ filename = canonical_filename(os.path.abspath(filename))
if self._c_files_map and filename in self._c_files_map:
c_file, rel_file_path, code = self._c_files_map[filename]
else: