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

coverage.exceptions.NoSource for temporary files since 4.0.0 #440

Closed
icemac opened this issue May 15, 2024 · 2 comments
Closed

coverage.exceptions.NoSource for temporary files since 4.0.0 #440

icemac opened this issue May 15, 2024 · 2 comments
Assignees

Comments

@icemac
Copy link
Contributor

icemac commented May 15, 2024

Describe the Bug

Updating from version 3.3.1 to 4.0.0 leads to coverage.exceptions.NoSource for temporary Python files created and executed during test runs.

To Reproduce
Steps to reproduce the behavior:

  1. Repository: https://github.com/zopefoundation/zope.deprecation
  2. The temporary python file is created here: https://github.com/zopefoundation/zope.deprecation/blob/80d6a8f3d8d231af6df69e14bfd1078549f32eff/docs/api.rst?plain=1#L40-L41
  3. Running tox -ecoverage followed by coveralls --service=github in GitHub Actions.
  4. I get this result:
Submitting coverage to coveralls.io...
Error running coveralls: Got coverage library error: No source for code: '/tmp/tmpr9lzq4ehdeprecation/doctest_ex.py'.
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coveralls/reporter.py", line 44, in report
    for (fr, analysis) in get_analysis_to_report(cov, None):
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage/report_core.py", line 100, in get_analysis_to_report
    analysis = coverage._analyze(fr)
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage/control.py", line 949, in _analyze
    return Analysis(data, self.config.precision, fr, self._file_mapper)
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage/results.py", line 35, in __init__
    self.statements = self.file_reporter.lines()
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage/python.py", line 193, in lines
    return self.parser.statements
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage/python.py", line 184, in parser
    self._parser = PythonParser(
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage/parser.py", line [58](https://github.com/zopefoundation/zope.deprecation/actions/runs/9051201049/job/24984861083#step:7:59), in __init__
    self.text = get_python_source(self.filename)
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage/python.py", line 63, in get_python_source
    raise NoSource(f"No source for code: '{filename}'.")
coverage.exceptions.NoSource: No source for code: '/tmp/tmpr9lzq4ehdeprecation/doctest_ex.py'.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coveralls/cli.py", line 98, in main
    result = coverallz.wear()
  File "/opt/hostedtoolcache/Python/3.9.19/x[64](https://github.com/zopefoundation/zope.deprecation/actions/runs/9051201049/job/24984861083#step:7:65)/lib/python3.9/site-packages/coveralls/api.py", line 272, in wear
    json_string = self.create_report()
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coveralls/api.py", line 344, in create_report
    data = self.create_data()
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coveralls/api.py", line 403, in create_data
    self._data = {'source_files': self.get_coverage()}
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coveralls/api.py", line 425, in get_coverage
    return CoverallReporter(work, base_dir, src_dir).coverage
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coveralls/reporter.py", line 32, in __init__
    self.report(cov)
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coveralls/reporter.py", line 51, in report
    raise CoverallsException(f'Got coverage library error: {e}') from e
coveralls.exception.CoverallsException: Got coverage library error: No source for code: '/tmp/tmpr9lzq4ehdeprecation/doctest_ex.py'.

Expected Behavior
Not existing files should be ignored like in version 3.x

Package Versions

  • coveralls [4.0.0], version of last successful run: 3.3.1
  • coverage [7.4.4] , version of last successful run: 6.5.0
  • Python 3.9

Trace Logs
Provide coverage logs w/ DEBUG logging enabled (run coverage debug ...)

Broken run: https://github.com/zopefoundation/zope.deprecation/actions/runs/9051201049/job/24984861083

Last successful run: https://github.com/zopefoundation/zope.deprecation/actions/runs/8867417029/job/24345951564

@TheKevJames
Copy link
Owner

This was an intentional breaking change in v4, with the intent being to match coverage-py behaviour. Setting ignore_errors = True in your coverage.py config (docs) should return you to the behaviour you're expecting.

@icemac
Copy link
Contributor Author

icemac commented May 17, 2024

@TheKevJames Thank you for the pointer. Using ignore_errors = True fixed the problem in my end.

@icemac icemac closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants