A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://abseil.io/docs/python/guides/testing below:

Testing

Testing Introduction

Abseil Python’s testing library is similar to Python’s standard unittest 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:

Unit Tests Basics

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.

What is Unittest/Absltest Doing?

The pattern is simple and common to most xUnit frameworks. Basically:

Note that setUp() and tearDown() are run once for each test method, so they are a great place to put data initialization and resource cleanup.

Using Validation Methods

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 results:

The Abseil testing library contains many more methods than the five above; some are in Python’s built-in unittest.TestCase while others are in Abseil Python’s subclass absl.testing.absltest.

Example Code

More examples are forthcoming, but for now please see absl-py’s own tests for examples of how to use absltest.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4