liveBook · Manning

assertEqual

assertEqual is a Python unittest assertion method that fails a test when two supplied values are not equal.

How 2 Manning books explain it

Python How-To

assertEqual is a unittest assertion method that checks whether two values are equal and reports a test failure otherwise.

How it is used
Evaluates whether generated results match expected results in unittest test cases.
How deep it goes
Explains equality checks, successful runs, and AssertionError diagnostics, while deferring other TestCase assertions to documentation.
Examples
Compares Task objects through their attribute dictionaries and detects a missing space in formatted task output.
What you can do after
Diagnose test failures by reading AssertionError output and comparing expected values with generated values.

Read how Python How-To explains assertEqual →

Django in Action

assertEqual is a Python test method that checks whether two values are equal and reports a failed assertion otherwise.

How it is used
Checks expected values in Django view tests after simulated browser requests.
How deep it goes
Explains equality assertions, argument order, exceptions, tracebacks, and failed test output without surveying every assertion method.
Examples
Tests the credits view at /credits/ by comparing response.status_code with 200, then demonstrates failure with 42.
What you can do after
Diagnose view-test failures by comparing expected values with response data and reading the resulting traceback.

Read how Django in Action explains assertEqual →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.