Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relative_files = True and dynamic_context = test_function #900

Closed
davidszotten opened this issue Dec 20, 2019 · 2 comments · Fixed by #902
Closed

relative_files = True and dynamic_context = test_function #900

davidszotten opened this issue Dec 20, 2019 · 2 comments · Fixed by #902
Labels
bug Something isn't working fixed
Milestone

Comments

@davidszotten
Copy link
Contributor

davidszotten commented Dec 20, 2019

Describe the bug
setting relative_files = True, i don't get any contexts listed in my html reports

To Reproduce

`versions`
$ python -V
Python 3.7.2

$ coverage --version
Coverage.py, version 5.0 with C extension
Full documentation is at https://coverage.readthedocs.io

$ pip freeze
attrs==19.3.0
coverage==5.0
importlib-metadata==1.3.0
more-itertools==8.0.2
packaging==19.2
pluggy==0.13.1
py==1.8.0
pyparsing==2.4.5
pytest==5.3.2
pytest-cov==2.8.1
six==1.13.0
wcwidth==0.1.7
zipp==0.6.0

$ coverage debug sys
-- sys -------------------------------------------------------
                   version: 5.0
                  coverage: /Users/david/environments/coverage/lib/python3.7/site-packages/coverage/__init__.py
                    tracer: -none-
                   CTracer: available
      plugins.file_tracers: -none-
       plugins.configurers: -none-
 plugins.context_switchers: -none-
         configs_attempted: .coveragerc
              configs_read: .coveragerc
               config_file: .coveragerc
           config_contents: '[run]\nbranch = True\ndynamic_context = test_function\n#relative_files = True\n'
                 data_file: -none-
                    python: 3.7.2 (default, Dec  5 2019, 09:13:08) [Clang 10.0.1 (clang-1001.0.46.4)]
                  platform: Darwin-18.7.0-x86_64-i386-64bit
            implementation: CPython
                executable: /Users/david/environments/coverage/bin/python
              def_encoding: utf-8
               fs_encoding: utf-8
                       pid: 33092
                       cwd: /Users/david/dev/coverage-bug
                      path: /Users/david/environments/coverage/bin
                            /Users/david/environments/coverage/lib/python37.zip
                            /Users/david/environments/coverage/lib/python3.7
                            /Users/david/environments/coverage/lib/python3.7/lib-dynload
                            /Users/david/.pyenv/versions/3.7.2/lib/python3.7
                            /Users/david/environments/coverage/lib/python3.7/site-packages
               environment: PYTHONSTARTUP = /Users/david/.pystartup.py
                            VIRTUALENVWRAPPER_PYTHON = /Users/david/.pyenv/versions/3.7.2/bin/python
              command_line: /Users/david/environments/coverage/bin/coverage debug sys
           sqlite3_version: 2.6.0
    sqlite3_sqlite_version: 3.24.0
$ cat test_foo.py
def test_foo():
    assert True


$ cat .coveragerc
[run]
branch = True
dynamic_context = test_function
#relative_files = True


$ pytest --cov=test_foo --cov-context=test; coverage report --contexts=test_foo; coverage html --show-contexts

Expected behavior
context info in the html report

i get context when commenting out relative_files as in the example output above, but it disappears when i uncomment that line

update

i think the json reporter has the same issue (not checked others)
for the json report, i wonder if

file_reporter.filename

reported_file['contexts'] = analysis.data.contexts_by_lineno(
                file_reporter.filename
            )

should be using analysis.filename instead?

@davidszotten davidszotten added the bug Something isn't working label Dec 20, 2019
davidszotten added a commit to davidszotten/coveragepy that referenced this issue Dec 20, 2019
fix reporting of contexts when `relative_files = True`

fixes nedbat#900
nedbat pushed a commit that referenced this issue Dec 21, 2019
fix reporting of contexts when `relative_files = True`

fixes #900
nedbat added a commit that referenced this issue Dec 21, 2019
@nedbat nedbat added the fixed label Dec 22, 2019
@nedbat nedbat added this to the 5.0.1 milestone Dec 22, 2019
@nedbat
Copy link
Owner

nedbat commented Dec 22, 2019

This is now available in coverage==5.0.1

@davidszotten
Copy link
Contributor Author

🎉 you are amazing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants