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

chore(python): Detecting tests in nested directories. #1572

Merged
merged 3 commits into from
Sep 13, 2022

Conversation

m-strzelczyk
Copy link
Contributor

Sometimes tests are not on the same level as the current working directory. PyTest doesn't have a problem with this, neither should we.

@m-strzelczyk m-strzelczyk marked this pull request as ready for review September 8, 2022 15:22
@m-strzelczyk m-strzelczyk requested a review from a team as a code owner September 8, 2022 15:22
@parthea parthea changed the title feat(python): Detecting tests in nested directories. chore(python): Detecting tests in nested directories. Sep 8, 2022
@m-strzelczyk m-strzelczyk added the automerge Merge the pull request once unit tests and other checks pass. label Sep 9, 2022
Copy link
Contributor

@parthea parthea left a comment

Choose a reason for hiding this comment

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

Please could you revert this commit f1140c0 ? Only the first commit is needed based on my testing. Please could you share more information?

@gcf-merge-on-green
Copy link
Contributor

Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, one of your required reviews was not approved, or there is a do not merge label. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot.

@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Sep 9, 2022
@m-strzelczyk
Copy link
Contributor Author

Please could you revert this commit f1140c0 ? Only the first commit is needed based on my testing. Please could you share more information?

According to my tests, the version I suggest with that commit works better, finds tests that are nested deeper. Please see this short test script:

import tempfile
import glob
import os
import pathlib

if __name__ == '__main__':
    tmp_dir = tempfile.mkdtemp()
    os.chdir(tmp_dir)
    pathlib.Path('l1/l2/tests/some_test.txt').mkdir(parents=True, exist_ok=True)
    pathlib.Path('l1/l2/something_else').mkdir(parents=True, exist_ok=True)
    pathlib.Path('l1-bis/tests').mkdir(parents=True, exist_ok=True)

    print('glob.glob("tests"): ', glob.glob("tests"))
    print('glob.glob("**/tests"): ', glob.glob("**/tests"))
    print('glob.glob("tests", recursive=True): ', glob.glob("tests", recursive=True))
    print('glob.glob("**/tests", recursive=True): ', glob.glob("**/tests", recursive=True))

My output:

glob.glob("tests"):  []
glob.glob("**/tests"):  ['l1-bis/tests']
glob.glob("tests", recursive=True):  []
glob.glob("**/tests", recursive=True):  ['l1-bis/tests', 'l1/l2/tests']

Copy link
Contributor

@parthea parthea left a comment

Choose a reason for hiding this comment

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

LGTM

@parthea parthea merged commit 7d86a9b into master Sep 13, 2022
@parthea parthea deleted the python-test-check-recursive branch September 13, 2022 15:02
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.

2 participants