Skip to content

Conversation

@Skeen
Copy link
Contributor

@Skeen Skeen commented Mar 12, 2017

This pull-request utilizes the API extension provided by:

To solve the challenge presented in:

Essentially, it now reports coverage for all *.html files in the subtree it's run, which is arguably too wide, but a start for testing and discussion.

@Skeen
Copy link
Contributor Author

Skeen commented Mar 12, 2017

Excuse my briefness, pull requests were made from my phone, as I was leaving the train I was in.

Copy link
Collaborator

@PamelaM PamelaM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a reasonable first pass at the proposed coverage.py plugin api.

I think the performance requirements of this code are pretty minimal, so future maintainability (i.e. simplicity) suggests dropping the regex

res = []
for i, (dirpath, dirnames, filenames) in enumerate(os.walk(src_dir)):
for filename in filenames:
if re.match(r"^[^.#~!$@%^&*()+=,]+\.html?$", filename):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the complicated regex? Yes, this would slightly be slower, but also more readable:

ignored, ext = os.path.splitext(filename)
if ext in (".htm", ".html"):
    ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I expect to make a comment in the coverage.py PR that find_unexcuted_files() should be a generator, so it should yield the matching files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complicated regex was derived from here, in the find_python_files function.

I tried to keep the code corresponding with the rest of the code base, but I agree that the suggestion you make is a lot more readable, and to me atleast; preferable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the explanation in find_python_files for the regex, so (and I am sorry about this), you should probably put the regex back, but also include the comment from find_python_files as well.

@Skeen
Copy link
Contributor Author

Skeen commented Mar 13, 2017

I have incorporated the changes you suggested.

return FileReporter(filename)

def find_executable_files(self, src_dir):
for i, (dirpath, dirnames, filenames) in enumerate(os.walk(src_dir)):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any reason to use enumerate here if you're not using i later on.

from __future__ import print_function

import os.path
import re
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now unused.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, I've just suggested putting it back (wince)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Missed that conversation, sorry! 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, my conversation came after your reasonable comment. :)

@Skeen
Copy link
Contributor Author

Skeen commented Mar 13, 2017

I have incorporated the changes you suggested.

@PamelaM
Copy link
Collaborator

PamelaM commented Mar 28, 2017

I'll integrate this into my fork tonight (since my fork is connected to travis-ci) and assuming the tests pass, we'll merge this in.

Before we can release it, we'll have to write a test. The unittest shouldn't be that hard, but an integration test might be tricky since the dj-coverage test suite isn't set up to test against the unreleased version of coverage.py. And since the feature isn't available in a released coverage.py, there's no immediate need to create a new release of dj-coverage (yet)

@Skeen
Copy link
Contributor Author

Skeen commented Mar 29, 2017

Hi,

Getting this upstream quickly isn't a priority for me. I'm currently just utilizing my own forks for my use, so take you time :)

@nedbat
Copy link
Member

nedbat commented Apr 5, 2017

The new plugin method is in coverage.py 4.4b1.

@Skeen
Copy link
Contributor Author

Skeen commented Apr 7, 2017

Shall we close the pull request then?

@PamelaM
Copy link
Collaborator

PamelaM commented Apr 7, 2017

I'd like to see a unit test for find_executable_files, before we officially support this in a pypi release, but I'll want to add a get_plugin_object() method to DjangoPluginTestCase to facilitate unit-testing the plugin methods.

I'll merge this PR if you could add your name to AUTHORS.txt first.

Then I'll update and increase the testing framework a bit.

@Skeen
Copy link
Contributor Author

Skeen commented Apr 7, 2017

Hi @PamelaM,

I added myself to the AUTHORS.txt file.

Is the unit test something you will do, or do you expect me to do it, after you add the get_plugin_object() method? - I just need to make sure I understand your intent clearly.

@PamelaM
Copy link
Collaborator

PamelaM commented Apr 7, 2017

@Skeen

Sorry - I was figuring out my intent as I typed and didn't re-read before I hit comment. It's not my best habit.

I'll handle the unit test, though I'll poke you to review the PR, if that's okay.

@PamelaM
Copy link
Collaborator

PamelaM commented Apr 7, 2017

Thanks for the PR!

@PamelaM PamelaM merged commit fa2c606 into coveragepy:master Apr 7, 2017
@Skeen
Copy link
Contributor Author

Skeen commented Apr 7, 2017

Okay excellent.

Just poke me to review whatever you'd like :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants