A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nedbat/coveragepy/issues/900 below:

`relative_files = True` and `dynamic_context = test_function` · Issue #900 · nedbat/coveragepy · GitHub

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

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

should be using analysis.filename instead?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4