fix(py_test): Support target names with a test_
prefix
#607
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.
Adds a
test_main
argument topy_pytest_main
and propagates it frompy_test
. Uses a leading "." in the filename to suppress pytest collection.In the current implementation, when
pytest_main = True
, the generated test entry file is named after the target with a.pytest_main.py
extension. If the target name starts withtest_
, pytest may mistakenly collect the file as a test module, leading to confusing import errors.Alternatively, if this naming convention is decided to not be supported, we could maybe warn the user in a more friendly way when
py_test
is used with a name that may trigger this issue.Changes are visible to end-users: yes
fix(py_test): Target names with a
test_
prefix do not generate an import error when specifyingpytest_main = True
.Test plan