commit | ec7892ca08da797885db0982e79b9cceffa7684f | [log] [tgz] |
---|---|---|
author | Stephen Thorne <sthorne@google.com> | Mon Apr 12 03:07:44 2021 -0700 |
committer | Copybara-Service <copybara-worker@google.com> | Mon Apr 12 03:08:07 2021 -0700 |
tree | f0690524abebaeefabe832e52dff2546e730fd6c | |
parent | 1c62d88d4fb1ad903f298190dfb52f364d546ec2 [diff] |
Add `@absltest.skipThisClass` to skip specific classes during testing. This decorator marks a test in a way that it will be skipped, but none of its subclasses are. Suggested usage is for where you want to share functionality between tests, by having an 'abstract' base class: ``` @absltest.skipThisClass class _BaseTestCase(absltest.TestCase): def test_foo(self): self.assertEqual(self.object_under_test.method() class FooTest(_BaseTestCase): def setUp(self): self.object_under_test = Foo() class BarTest(_BaseTestCase): def setUp(self): self.object_under_test = Bar() ``` There are alternatives, but they have drawbacks: * Having `_BaseTestCase` subclass object, and `FooTest` multiple-inherit from both `absltest.TestCase` and `_BaseTestCase`. However, this ends up being problematic for type checking. * Repeating the same logic in `absltest.skipThisClass` within `setUpClass` for every class to skip. However, that is repetitive logic that is best put into a utility function. While `skipThisClass` is similar to `@unittest.skip`, it has an important distinction: regular `skip` will skip the decorated class and all subclasses; `skipThisClass` only skips the decorated class, allowing base classes to be correctly skipped while sub-classes are run as tests. PiperOrigin-RevId: 367965048 Change-Id: Ie050c43c7f2e5dbc5af731171259c27084d1ba12
This repository is a collection of Python library code for building Python applications. The code is collected from Google's own Python code base, and has been extensively tested and used in production.
To install the package, simply run:
pip install absl-py
Or install from source:
python setup.py install
To run Abseil tests, you can clone the git repo and run bazel:
git clone https://github.com/abseil/abseil-py.git cd abseil-py bazel test absl/...
Please refer to smoke_tests/sample_app.py as an example to get started.
See the Abseil Python Developer Guide.
The current repository includes an initial set of libraries for early adoption. More components and interoperability with Abseil C++ Common Libraries will come in future releases.
The Abseil Python library is licensed under the terms of the Apache license. See LICENSE for more information.