diff options
author | Arthur Rio <arthurio@users.noreply.github.com> | 2022-08-06 13:06:25 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-06 12:06:25 -0700 |
commit | 41602b5ecfe602c53cef84fec249ed07dbd89538 (patch) | |
tree | 77c6066c147f274d257906e70109ed2366cfd040 /coverage/files.py | |
parent | eaf55921248211a81be231d7d20d73460cb369fb (diff) | |
download | python-coveragepy-git-41602b5ecfe602c53cef84fec249ed07dbd89538.tar.gz |
fix: paths were wrong when running from root (#1403)
* Fix paths when running coverage from root
* Add simple tests
* Use nested pattern for older python versions
Diffstat (limited to 'coverage/files.py')
-rw-r--r-- | coverage/files.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/coverage/files.py b/coverage/files.py index 507496ff..b5895cfc 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -24,8 +24,14 @@ def set_relative_directory(): """Set the directory that `relative_filename` will be relative to.""" global RELATIVE_DIR, CANONICAL_FILENAME_CACHE + # The current directory + abs_curdir = abs_file(os.curdir) + if not abs_curdir.endswith(os.sep): + # Suffix with separator only if not at the system root + abs_curdir = abs_curdir + os.sep + # The absolute path to our current directory. - RELATIVE_DIR = os.path.normcase(abs_file(os.curdir) + os.sep) + RELATIVE_DIR = os.path.normcase(abs_curdir) # Cache of results of calling the canonical_filename() method, to # avoid duplicating work. |