absltest: do not fail tests on Python 3.12+ when no tests ran and:
Either test filtering is used
Or sharding is used and the shard index > 0, i.e. only the first shard will fail when no tests ran on Python 3.12+.
Context: Python 3.12 unittest will now fail when no tests ran after the change from https://github.com/python/cpython/pull/102051. Since absltest is built on top of unittest, it will follow this behavior change in Python 3.12.
However, when test filtering is used in absltest, often used via bazel test --test_filter=<my_filter>, the current user expectation is the bazel test command should NOT fail is at least one test ran. Since the test runner here has no visibility of the overall bazel invocation, we'll make the test not fail when test filtering is used via bazel's environment variable. This is the existing behavior before Python 3.12.
absltest
: do not fail tests on Python 3.12+ when no tests ran and:Context: Python 3.12 unittest will now fail when no tests ran after the change from https://github.com/python/cpython/pull/102051. Since
absltest
is built on top ofunittest
, it will follow this behavior change in Python 3.12.However, when test filtering is used in
absltest
, often used viabazel test --test_filter=<my_filter>
, the current user expectation is thebazel test
command should NOT fail is at least one test ran. Since the test runner here has no visibility of the overallbazel
invocation, we'll make the test not fail when test filtering is used via bazel's environment variable. This is the existing behavior before Python 3.12.Also test absl-py on Python 3.12.