Skip to content

Avoid passing __init__.py files to pytest to mitigate bug#3

Merged
caseyduquettesc merged 1 commit intocaseyduquettesc:mainfrom
amartani:main
Jun 16, 2023
Merged

Avoid passing __init__.py files to pytest to mitigate bug#3
caseyduquettesc merged 1 commit intocaseyduquettesc:mainfrom
amartani:main

Conversation

@amartani
Copy link
Contributor

@amartani amartani commented Jun 16, 2023

We sometimes use py_pytest_test passing srcs = glob(["*.py"]) to run every python test in the folder in a single pytest run. This triggers a pytest bug that causes all tests to be run twice due to the inclusion of __init__.py, which is expanded to include the entire directory: pytest-dev/pytest#9313

To avoid this, filter any __init__.py file when computing the arguments passed to pytest.

I decided to do the filtering in Python rather than in Starlark since we would need to expand labels (ie. resolve $(location :%s)) to determine basename, which I believe is not possible to do on a bazel macro.

Copy link
Owner

@caseyduquettesc caseyduquettesc left a comment

Choose a reason for hiding this comment

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

Makes sense, thanks!

@caseyduquettesc caseyduquettesc merged commit 9800fd8 into caseyduquettesc:main Jun 16, 2023
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