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 →

Also covered in

What to know first

Related concepts

Questions about assertEqual

What is assertEqual?

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

Which Manning books explain assertEqual?

Python How-To and Django in Action.

What should I know before learning assertEqual?

Manning books that teach assertEqual usually introduce method first.

What is assertEqual a kind of?

assertEqual is a kind of assertion method. An assertion method is a test operation that checks a stated condition and raises an exception when the condition is false.

What is assertEqual part of?

assertEqual is part of TestCase. unittest.TestCase is the Python base class that provides structure, lifecycle behavior, and assertion methods for defining test cases.

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.