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

bpo-32071: Add unittest -k option #4496

Merged
merged 4 commits into from
Nov 25, 2017
Merged

Conversation

jonashaag
Copy link
Contributor

@jonashaag jonashaag commented Nov 21, 2017

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

Thanks again to your contribution and we look forward to looking at it!

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

Thank you for posting this PR. In addition to the review comments I posted, there are two points to address:

  • sign the contributor's agreement, if you haven't already done so
  • add documentation for the new command-line option and the TestLoader addition; the docs are Doc/library/unittest.rst

@@ -225,8 +241,7 @@ def _do_discovery(self, argv, Loader=None):
self._initArgParsers()
self._discovery_parser.parse_args(argv, self)

loader = self.testLoader if Loader is None else Loader()
self.test = loader.discover(self.start, self.pattern, self.top)
self.createTests(from_discovery=True, Loader=Loader)
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious, why was this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This refactoring was necessary because I didn't want to repeat the code that sets loader.testNamePatterns from the CLI options. That code has to be executed BEFORE loader.discover. Besides, I believe it makes sense to have a single place where self.test is set.

@@ -409,6 +409,15 @@ def testParseArgsAbsolutePathsThatCannotBeConverted(self):
# for invalid filenames should we raise a useful error rather than
# leaving the current error message (import of filename fails) in place?

def testParseArgsSelectedTestNames(self):
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for adding these tests. Do you think you could also create a small functional test? There is an example of such a test (using subprocess) in Test_TextTestRunner.test_warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a functional test but I'm not sure if that's the right place to put it.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@warsaw
Copy link
Member

warsaw commented Nov 22, 2017

There really should be both an issue opened and a NEWS item for this. These should not be skipped. Otherwise, I have to read the diff to infer what -k is supposed to do.

@pitrou pitrou changed the title Add unittest -k option bpo-32071: Add unittest -k option Nov 22, 2017
@pitrou
Copy link
Member

pitrou commented Nov 22, 2017

I fixed the title to refer to the issue on the bug tracker.
As for the NEWS entry, you're right, I forgot this. @jonashaag, you can add one using the blurb utility.

@jonashaag
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@pitrou: please review the changes made to this pull request.

@jonashaag
Copy link
Contributor Author

I'm not sure what the Sphinx error means.

List of Unix shell-style wildcard test name patterns that test methods
have to match to be included in test suites (see ``-v`` option).

If this attribute is not `None` (the default), all test methods to be
Copy link
Member

Choose a reason for hiding this comment

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

The sphinx build says:
[2] library/unittest.rst:1772: default role used
It points to line 1772 of unittest.rst.
I think it's because single backticks was used around None.
Try using double backticks instead.

@@ -229,6 +245,9 @@ Command-line options
.. versionadded:: 3.5
The command-line option ``--locals``.

.. versionadded:: 3.7
The command-line option ``-k``.
Copy link
Member

Choose a reason for hiding this comment

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

Add one more space before "The command-line .. ".

imported by the test loader.

For example, ``-k foo`` matches ``foo_tests.SomeTest.test_something``,
``bar_tests.SomeTest.test_foo``, but not `bar_tests.FooTest.test_something``.
Copy link
Member

Choose a reason for hiding this comment

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

Mismatched number of backticks in bar_tests.FooTest.test_something.

@jonashaag
Copy link
Contributor Author

Not sure why CLA not signed label is still there; I signed it on 2017-11-21.

@pitrou
Copy link
Member

pitrou commented Nov 24, 2017

Not sure why CLA not signed label is still there; I signed it on 2017-11-21.

Hmm... I've tried to reach to some people who might have a clue about that :-)

@vstinner
Copy link
Member

@vstinner vstinner removed the CLA not signed label just now

and

@the-knights-who-say-ni ay-ni the-knights-who-say-ni added the CLA not signed label just now

@jonashaag: If the bot adds again "not signed", it means that you forgot to fill your GitHub account login in your bugs.python.org profile.

@vstinner
Copy link
Member

Read also the @the-knights-who-say-ni message which explains that ;-) #4496 (comment)

@jonashaag
Copy link
Contributor Author

@vstinner It's there, I added it on 2017-11-21.

@jonashaag
Copy link
Contributor Author

Screenshots of signed CLA as received from Adobe sign (?)

Is there a manual check by a human involved in the process? If so, maybe the person simply hasn't found the time to process it.

bildschirmfoto 2017-11-24 um 14 35 59

bildschirmfoto 2017-11-24 um 14 36 09

@vstinner
Copy link
Member

On bugs.python.org, I still see "Contributor Form Received: No".

Yeah, I think that a human process is required somewhere.

@ejodlowska
Copy link

@vstinner bugs account has been updated. For whatever reason, the email notification never came through.

@vstinner
Copy link
Member

Ok, the CLA signed label is now here :-) Thank you Ewa.

@pitrou
Copy link
Member

pitrou commented Nov 25, 2017

The PR now looks good to me, I'm going to merge.

@pitrou pitrou merged commit 5b48dc6 into python:master Nov 25, 2017
slawqo added a commit to slawqo/ryu that referenced this pull request Jul 25, 2018
Due to change [1] in python 3.7 one of ryu's unit tests
was failing with this version of interpreter. It was like that
because of missing __qualname__ attribute in functools.partial
object.
This patch fixes it by adding such attribute if it's not
set already.

[1] python/cpython#4496
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.

8 participants