Abseil Python’s testing library is similar to Python’s standard
module (sometimes referred to as PyUnit) but offers some additional useful
features on top of the standard library, such as interfacing with Abseil Flags.
To use the Abseil testing library, do the following in your unit tests:
flags module, which gives you access to the variables
absltest.main() instead of
Within a unit test class, any method name starting with ‘test’ will be run automatically as part of the unit test. Test names should describe the particular case being tested.
The pattern is simple and common to most xUnit frameworks. Basically:
main() scans the current file for classes derived from
main() then scans each class for methods prefixed by
setUp() method, if one exists
tearDown() method, if one exists
tearDown() are run once for each test method, so they
are a great place to put data initialization and resource cleanup.
Validation methods such as
assertEqual() raise an exception on failure,
which terminates the current test method. Unit test execution will continue with
the remaining test methods.
Additional methods, inherited from
absltest, are available to validate
More examples are forthcoming, but for now please see absl-py’s own tests for
examples of how to use