Skip to main content

unittest2 is a backport of the new features added to the unittest testing framework in Python 2.7. It is tested to run on Python 2.4 - 2.6.

To use unittest2 instead of unittest simply replace import unittest with import unittest2.

Classes in unittest2 derive from the equivalent classes in unittest, so it should be possible to use the unittest2 test running infrastructure without having to switch all your tests to using unittest2 immediately. Similarly you can use the new assert methods on unittest2.TestCase with the standard unittest test running infrastructure. Not all of the new features in unittest2 will work with the standard unittest test loaders and runners however.

New features include:

  • addCleanups - better resource management

  • many new assert methods including better defaults for comparing lists, sets, dicts unicode strings etc and the ability to specify new default methods for comparing specific types

  • assertRaises as context manager, with access to the exception afterwards

  • test discovery and new command line options for python -m unittest2

  • test skipping and expected failures * load_tests protocol for loading tests from modules or packages

  • startTestRun and stopTestRun methods on TestResult

  • various other API improvements and fixes

Until I write proper documentation, the best information on all the new features is the development version of the Python documentation for Python 2.7:

Look for notes about features added or changed in Python 2.7.

Release files for unittest2 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unittest2 0.1.2
File Size Uploaded
unittest2-0.1.2.tar.gz 38.5 kB Details

Release files / unittest2-0.1.2.tar.gz

Download URL unittest2-0.1.2.tar.gz
Size 38.5 kB
Tags Source
SHA-256 checksum
How to use checksums
768dc144ab260867455544d11e517ca2a72bad94d7a2bf51861aa2c216abacb6
BLAKE2b-256 checksum
How to use checksums
36d7ec09fd715f2df315aeab044f080b28e4ca5919a9cf929dc6de64fab0d3b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

3 release files

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page