Add support for copying references to use with nose #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for making this convenient plugin! One of the projects I work on uses nose as its test framework, and the path format for selecting specific classes/tests to run is different from what exists in this plugin currently. Notably, nose is no longer maintained but pynose is a drop-in replacement that supports the same format (see the
Selecting Tests
on the homepage).In summary, when targeting specific tests in nose, there are two path options:
some.package.path:SomeClass.some_function
some/package/path.py:SomeClass.some_function
I have a personal preference for option 1, but tried supporting both options to see if one was less invasive than the other. For both formats, I found that an additional separator had to be introduced, whether it was to separate the module from the attributes, or the attributes themselves.
Given this, I went with option 1. I liked the idea of refactoring
_get_attribute_parts
to_get_attributes
which accepts a separator and returns a string, behaving similarly to_get_module
. The alternative was to keep the logic for building the attributes string in_get_reference
which also works, but felt a bit less elegant.Tests
I added
tests/nose.vader
to ensure this behaves as expected for both copying references to modules as well as attributes within a module.I also updated the
tests/pytest.vader
to include a test for attributes as well, as it seemed like this was missing from the existing test suite sincetests/attribute.vader
only covers dotted behavior. It may be out of scope of this PR, but rather than have a separatetests/attribute.vader
file, I think it makes sense to have an attribute test for each copy format in the relevant test file.I've been using this locally with no issues, but mainly rely on nose and import references. If you're happy with this solution, I can also update the readme to mention this format as well.