Skip to content

bpo-46421: Fix unittest filename evaluation when called as a module #30654

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

Merged
merged 11 commits into from
Mar 17, 2022

Conversation

BaderSZ
Copy link
Contributor

@BaderSZ BaderSZ commented Jan 18, 2022

See issue: https://bugs.python.org/issue46421

I stumbled across this issue when writing my own tests. I tried to run the tests as python -m unittest ./tests/*.py but failed. This surprisingly worked later when I removed the ./ from the beginning of the filename/directory.

Some investigation showed that the variable parts in Lib/unittest/loader.py:125 had a '.' in the beginning. Removing that fixed the issue.

  • make patchcheck passed
  • blurb added
  • ACKS added
  • Contributor agreement signed

https://bugs.python.org/issue46421

Sorry, something went wrong.

@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 this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@BaderSZ

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@BaderSZ
Copy link
Contributor Author

BaderSZ commented Jan 18, 2022

Our records indicate the following people have not signed the CLA:
...
If you have recently signed the CLA, please wait at least one business day before our records are updated.

I guess we'll wait the few business days.. :)

This is a better solution to the unittest fix that passes its own unit tests.
Instead of filtering for ``None`` types, I just tear off the first dots in ``name``
@BaderSZ
Copy link
Contributor Author

BaderSZ commented Jan 18, 2022

The latest commit fixes the pipelines.

Copy link
Contributor

@kumaraditya303 kumaraditya303 left a comment

Choose a reason for hiding this comment

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

LGTM but a test would be required here. See https://devguide.python.org/runtests/

@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.

And if you don't make the requested changes, you will be poked with soft cushions!

@JelleZijlstra JelleZijlstra self-assigned this Mar 16, 2022
@BaderSZ
Copy link
Contributor Author

BaderSZ commented Mar 16, 2022

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

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

@BaderSZ
Copy link
Contributor Author

BaderSZ commented Mar 16, 2022

Good thing I read the contribution docs. I was about to squash the commits. 😃 make, patchcheck, and unit tests pass on my end (GNU/Linux).

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks! Going to try this out myself later today and then hopefully merge it.

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Tried it locally and it works great!

I noticed it also fixes invocations like ./python.exe -m unittest Lib/test/../test/test_longexp.py. We could add a test for that, but it's not particularly useful so I won't insist on it.

I'll merge this in the next few days and backport to 3.9 and 3.10.

@JelleZijlstra
Copy link
Member

JelleZijlstra commented Mar 17, 2022

(MacOS CI is failing, but it looks unrelated to this change and didn't reproduce locally on my Mac.)

@JelleZijlstra JelleZijlstra merged commit a0db11b into python:main Mar 17, 2022
@miss-islington
Copy link
Contributor

Thanks @BaderSZ for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-31969 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Mar 17, 2022
@bedevere-bot
Copy link

GH-31970 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 17, 2022
…ythonGH-30654)

(cherry picked from commit a0db11b)

Co-authored-by: Bader Zaidan <bader@zaidan.pw>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 17, 2022
…ythonGH-30654)

(cherry picked from commit a0db11b)

Co-authored-by: Bader Zaidan <bader@zaidan.pw>
miss-islington added a commit that referenced this pull request Mar 18, 2022
…H-30654)

(cherry picked from commit a0db11b)

Co-authored-by: Bader Zaidan <bader@zaidan.pw>
JelleZijlstra pushed a commit that referenced this pull request Mar 18, 2022
…dule (GH-30654) (GH-31970)

(cherry picked from commit a0db11b)

Co-authored-by: Bader Zaidan <bader@zaidan.pw>
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…dule (pythonGH-30654) (pythonGH-31970)

(cherry picked from commit a0db11b)

Co-authored-by: Bader Zaidan <bader@zaidan.pw>
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.

None yet

7 participants