-
-
Notifications
You must be signed in to change notification settings - Fork 610
generate py_test without __test__ #999
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know at least a few repositories that this will be a breaking change. I've seen files using these patterns to contain test utilities and be reused by multiple tests. Ideally, those should be renamed to adhere to better practices. Having said that, we will need warning notes on the next release. cc @groodt @rickeylev
Since #999, gazelle can generate multiple `py_test` rules in a single package (when it finds multiple `*_test.py` or `test_*.py` files and no `__test__.py` file). In this case, adding new test files to a package with pre-existing `py_test` rules is not handled properly due to the `MatchAny` property on the `py_test` kind - it will match the existing `py_test` rule and edit it instead of adding a new test rule. This PR disables the matching so that new `py_test` rules are properly generated.
…les (#2998) Remove entry point file requirements when generating rules. Enable python rule generation as long as there are .py source files under the directory so all new packages will have python rules generated in the package. The extension used to require entrypoints for generation but: - entry point for tests (i.e., `__test__.py` ) is no longer required after #999 and #2044 - entry point for binaries (i.e., `__main__.py` ) is no longer required after #1584 The entry point for libraries (`__init__.py` ) shouldn't be required either, especially for Python 3.3 and after when namespace packages are supported. --------- Co-authored-by: yushan <yushan@uber.com> Co-authored-by: Douglas Thor <dougthor42@users.noreply.github.com>
…les (bazel-contrib#2998) Remove entry point file requirements when generating rules. Enable python rule generation as long as there are .py source files under the directory so all new packages will have python rules generated in the package. The extension used to require entrypoints for generation but: - entry point for tests (i.e., `__test__.py` ) is no longer required after bazel-contrib#999 and bazel-contrib#2044 - entry point for binaries (i.e., `__main__.py` ) is no longer required after bazel-contrib#1584 The entry point for libraries (`__init__.py` ) shouldn't be required either, especially for Python 3.3 and after when namespace packages are supported. --------- Co-authored-by: yushan <yushan@uber.com> Co-authored-by: Douglas Thor <dougthor42@users.noreply.github.com>
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The Gazelle extension requires the existence of
__test__.py
or a target named__test__
to generatepy_test
targets. Otherwise, all_test.py
andtest_*.py
will be included intopy_library
.Issue Number: #714
What is the new behavior?
__test__.py
is not part of official Python specification. In fact, it is rarely used in existing open source Python projects. A more common scenario is to have_test.py
ortest_*.py
files, each with something like:This PR creates a
py_test
target per test Python file when neither__test__.py
or a target named__test__
exists.Does this PR introduce a breaking change?
Other information