Skip to content

Make coverage testing work for affiliated packages#2132

Merged
astrofrog merged 1 commit intoastropy:masterfrom
mdboom:testing/coverage-in-affiliated-packages
Mar 1, 2014
Merged

Make coverage testing work for affiliated packages#2132
astrofrog merged 1 commit intoastropy:masterfrom
mdboom:testing/coverage-in-affiliated-packages

Conversation

@mdboom
Copy link
Contributor

@mdboom mdboom commented Feb 27, 2014

At the moment, coverage testing does not work properly for affiliated packages:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.4.dev7527-py2.7-macosx-10.8-x86_64.egg/astropy/tests/helper.py", line 292, in _save_coverage
    cov.html_report(directory=os.path.join(rootdir, 'htmlcov'))
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/coverage/control.py", line 615, in html_report
    return reporter.report(morfs)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/coverage/html.py", line 90, in report
    self.report_files(self.html_file, morfs, self.config.html_dir)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/coverage/report.py", line 84, in report_files
    report_fn(cu, self.coverage._analyze(cu))
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/coverage/control.py", line 545, in _analyze
    return Analysis(self, it)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/coverage/results.py", line 28, in __init__
    exclude=self.coverage._exclude_regex('exclude')
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/coverage/parser.py", line 35, in __init__
    "No source for code: '%s': %s" % (self.filename, err)
coverage.misc.NoSource: No source for code: '/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.4.dev7527-py2.7-macosx-10.8-x86_64.egg/astropy/extern/pytest.pyc/_pytest.helpconfig': [Errno 20] Not a directory: '/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.4.dev7527-py2.7-macosx-10.8-x86_64.egg/astropy/extern/pytest.pyc/_pytest.helpconfig'

I think the culprit is that astropy_test.run uses the coveragerc file bundled with Astropy:

                coveragerc = os.path.join(
                    os.path.dirname(__file__), 'coveragerc')

which contains a hard-coded reference to astropy as being the source directory.

We should look into a way to make this more general so as to work with affiliated packages.

cc @mdboom @wkerzendorf

@embray
Copy link
Member

embray commented Feb 25, 2014

I think this needs mostly be a matter of using a coveragerc relative to the package's path rather than just __file__ (which of course will always be relative to astropy)

@cdeil
Copy link
Member

cdeil commented Feb 26, 2014

Same issue?
astropy/package-template#25

@mdboom
Copy link
Contributor

mdboom commented Feb 27, 2014

This, in conjunction with astropy/package-template#39 should hopefully resolve this.

@cdeil
Copy link
Member

cdeil commented Mar 1, 2014

Is this ready to be merged?
(I'd like to use it for gammapy, gammapy/gammapy#12)

@astrofrog astrofrog added this to the v0.3.2 milestone Mar 1, 2014
@astrofrog
Copy link
Member Author

Yes - it seems to work correctly. I've tagged this as 0.3.2 since it can be considered a bug.

astrofrog added a commit that referenced this pull request Mar 1, 2014
…ackages

Make coverage testing work for affiliated packages
@astrofrog astrofrog merged commit ac5192a into astropy:master Mar 1, 2014
astrofrog added a commit that referenced this pull request Mar 27, 2014
…ackages

Make coverage testing work for affiliated packages
Conflicts:

	astropy/tests/helper.py
embray added a commit that referenced this pull request Apr 24, 2014
…erge of the fix for issue #2132 into the 0.3.x branch.
@mdboom mdboom deleted the testing/coverage-in-affiliated-packages branch May 21, 2014 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants