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

Running programmatically with .pyw files #290

Closed
nedbat opened this issue Mar 2, 2014 · 3 comments
Closed

Running programmatically with .pyw files #290

nedbat opened this issue Mar 2, 2014 · 3 comments
Labels
bug Something isn't working

Comments

@nedbat
Copy link
Owner

nedbat commented Mar 2, 2014

Originally reported by Okko Willeboordse (Bitbucket: owillebo, GitHub: owillebo)


I have two files;

test.py;

#!python
import coverage
cov = coverage.coverage(source = ['target'])
cov.start()
import target
cov.stop()
print cov.html_report()

and target.py(w);

#!python
def foo():
  pass

When I run test.py with target.py it outputs, as expected;
50.0
But when I rename target.py in to target.pyw, test.py outputs;

#!python

Coverage.py warning: Module target has no Python source.
Coverage.py warning: No data was collected.
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    print cov.html_report()
  File "c:\Python27\lib\site-packages\coverage\control.py", line 662, in html_report
    return reporter.report(morfs)
  File "c:\Python27\lib\site-packages\coverage\html.py", line 113, in report
    self.report_files(self.html_file, morfs, self.config.html_dir)
  File "c:\Python27\lib\site-packages\coverage\report.py", line 76, in report_files
    raise CoverageException("No data to report.")
coverage.misc.CoverageException: No data to report.

How do I run coverage programmatically with .pyw files?

Note that Python imports both target.py and with .pyw just the same.


@nedbat
Copy link
Owner Author

nedbat commented Jan 19, 2015

This is fixed as of 666c65a26ee27d072823234befa8701967e82149 (bb)

@nedbat nedbat closed this as completed Jan 19, 2015
@nedbat nedbat added minor bug Something isn't working labels Jun 23, 2018
@owillebo
Copy link

owillebo commented Jun 8, 2021

Please adjust the documentation. https://coverage.readthedocs.io/en/coverage-5.5/source.html says;

"You can specify source to measure with the --source command-line switch, or the [run] source configuration value. ... Files that do not end with .py or .pyo or .pyc will also be skipped.

Please add .pyw to this list.

@nedbat
Copy link
Owner Author

nedbat commented Jun 8, 2021

Done: 4401a6c

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

No branches or pull requests

2 participants