skillfed

unittest2

The new features in unittest backported to Python 2.4+.

unittest2 v1.1.0 1.3M downloads/30d#4,101 on PyPI
Permissive license UNKNOWN Abandoned released

What it is and what it does

unittest2 is a backport of unittest improvements introduced in Python 2.7 and later versions, designed to run on older Python releases. It provides a drop-in replacement for the standard unittest module by allowing you to import unittest2 instead of unittest, giving access to modern testing features on legacy Python versions.

The package includes enhancements such as additional assert methods with better comparison defaults, assertRaises as a context manager, test discovery, class and module-level fixtures (setUpClass, tearDownClass, setUpModule, tearDownModule), test skipping, and improved command-line tools via the unit2 script. It has no runtime dependencies and installs as a pure Python wheel.

Use it for:

  • Maintaining test suites on Python 2.6 systems that need modern assertion methods without upgrading the Python version.
  • Running test discovery on legacy Python versions before 2.7 introduced the feature natively.
  • Using assertRaises as a context manager on Python 2.6 codebases.
  • Accessing class-level and module-level test fixtures on older Python releases.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Backports unittest features from Python 2.7 and later versions to earlier Python releases, allowing use of modern testing assertions and test discovery on older Python versions.

No. The package has been abandoned since 2015 and targets Python versions that reached end-of-life over a decade ago. Modern Python includes all these features natively. Install only if you are maintaining a legacy codebase stuck on Python 2.6 or earlier that cannot be upgraded; otherwise, use the standard unittest module.

Install

unittest2 on PyPI

pip

pip install unittest2

uv

uv add unittest2

poetry

poetry add unittest2

Installing unittest2

Before you install

Installation is straightforward with no runtime dependencies. However, the package has been abandoned since 2015 and is no longer maintained.

License in practice

Licensed under BSD (permissive), so there are no restrictions on use in proprietary or open-source projects.

Quickstart

pip install unittest2

import unittest2

class TestExample(unittest2.TestCase):
    def test_something(self):
        self.assertEqual(1, 1)

Targets Python 2.4, 2.5, 2.6, 2.7, 3.2, 3.3, 3.4 and pypy; modern Python versions include these features natively.

Verify before relying

  • Whether unittest2 remains compatible with modern Python tooling and CI/CD systems despite its age.
  • Current state of the mercurial repository and whether it is still accessible or archived.

Package facts

License UNKNOWN (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 4,063 days since the last release
First released
Downloads 1,292,386/month — #4,101 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: unittest2-1.1.0-py2.py3-none-any.whl

Keywords: unittest, testing, tests

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2.4Programming Language :: Python :: 2.5Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Topic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Testing

Tags

unittest backportpython 2.6 testingunittest2 assertionstest discovery python 2unittest context managerlegacy python testing
legacy-pythonabandoned

More Libraries packages