NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #2763 most downloaded on PyPI
A collection of helpers and mock objects for unit tests and doc tests.
Last release 2 days ago
02 Oct 2026
Ships unpredictably
gaps range from 9 days to 13 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
18 years old
148 releases · first in 2008
Prepare for 12.4.0 release
Prepare for 12.4.0 release
Support Python 3.15
Speed up the common cases for Replacer.on_class.
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
One column per quarter.
Added pydantic support: a comparer for ~pydantic.BaseModel is automatically registered, and the testfixtures[pydantic] extra installs a compatible version.
Added ReprComparison and repr_like for asserting an object's type along with its repr.
Added StrComparison and str_like for asserting an object's type along with its str.
Added mapping, the typed helper for MappingComparison.
like now accepts a regular expression, as a string or a compiled re.Pattern, returning a TextComparison typed as a str. TextComparison can also now be built directly from a compiled re.Pattern.
ShouldRaise now accepts repr_like and str_like matchers, so a raised exception's type and rendering can be checked without constructing the exception instance.
Renamed !StringComparison to TextComparison. !StringComparison remains as a deprecated alias.
Fixed a bug where comparing two matcher instances directly, such as two SequenceComparison objects, could produce a confusing diff instead of comparing them for equality.
Prepare for 12.2.0 release
Prepare for 12.2.0 release
Added LogCapture.check_empty.
Added LogCapture.disabled context manager.
Added level and predicate parameters to LogCapture.check.
Prepare for 12.1.0 release
Prepare for 12.1.0 release
compare now supports numpy arrays.
Added a helper for testing command-line scripts.
Prepare for 12.0.1 release
Prepare for 12.0.1 release
Fix bug where frozensets would not compare equal when a library requiring ignore_eq for its types, such as polars, was present.
Prepare for 12.0.0 release
Prepare for 12.0.0 release
Warning
Breaking changes:
Comparers have moved from !testfixtures.comparison to testfixtures.comparers.
!django_compare has been removed, compare now works with Django models.
Refactoring of LogCapture to introduce support for loguru, structlog and similar support for twisted by way of the new ~testfixtures.logcapture.CaptureSource architecture.
compare now supports per-type ignore_eq.
compare now supports both polars and pandas dataframes.
compare now provides better feedback when objects being compared raised exceptions in their str or repr.
Added raises parameter to OutputCapture.compare, LogCapture.check and LogCapture.check_present to they can be more easily used in compositions.
Prepare for 11.0.0 release
Prepare for 11.0.0 release
Moved to a uv-based, pyproject.toml-driven project layout, with main replacing master as the default git branch.
Move from Circle CI to Github Actions for continuous integration and releasing.
Lots of documentation has been refreshed.
Python versions between 3.11 and 3.14, inclusive, are now supported.
Python versions 3.10 and earlier are no longer supported.
TempDir is now introduced as a ~pathlib.Path-based alternative to TempDirectory.
TempDir and TempDirectory have grown support for dumping and parsing JSON, YAML and TOML natively by way of the ~TempDir.dump and TempDir.parse methods.
TempDir and TempDirectory now have ~TempDir.read_text and TempDir.read_bytes methods that mirror the behaviour of their ~pathlib.Path equivalents.
TempDir and TempDirectory now support ~pathlib.Path objects anywhere they previously supported string and sequences of strings.
TempDir and TempDirectory now have a ~TempDir.clone method for copying existing files or directories into themselves for using during testing.
None can now be passed to ShouldRaise to check that no exception is raised. This is useful for parameterised tests where some cases may expect an exception to be raised while others do not.
ShouldRaise now has a match parameter to bring feature parity with pytest.raises.
Comparison now shows the wrong type when it is compared against a wrong type.
Comparison no longer spuriously reports ~testfixtures.comparers.AlreadySeen as the wrong type.
Fixed a bug where comparing parameterised generic type objects resulted in an infinite loop.
Prepare for 10.0.0 release
Prepare for 10.0.0 release
Fixed a bug in the warning issued when a Replacer is deleted with replacements still in place.
Reworked compare options so that typos and the like will now result in an exception being raised. This ended up being a breaking change if you use custom comparers that take options as this now has a different API.
Reworked the compare documentation to explain why you should be using it as well as updating the examples and explaining more fully how to configure and customise it.
Prepare for 9.2.0 release
Prepare for 9.2.0 release
Implement like, sequence, contains, unordered for strictly typed comparisons.
Correctly type ShouldRaise.raised.
Prepare for 9.1.0 release
Prepare for 9.1.0 release
Add support for passing StringComparison instances as parameters to OutputCapture.compare.
Prepare for 9.0.1 release
Prepare for 9.0.1 release
ShouldRaise.raised is now always an exception instance. If no exception has been raised, it will be a ~testfixtures.shouldraise.NoException instance. This prevents typing complaints around using an attribute that might be None.
mock_time has been reworked to return an instance of ~testfixtures.datetime.MockTime rather than the class itself. ~testfixtures.datetime.MockTime has also been reworked such that it can no longer be instantiated with the same parameters as ~datetime.datetime - this edge case was never supported, but is highlighted here in case folks were using it.
Python 3.11 is now the minimum supported version.
Python 3.11 is now the minimum supported version.
A show_whitespace parameter has been added to ShouldAssert.
testfixtures is now fully typed, checked with mypy and is distributed with a py.typed marker file.
ShouldRaise now supports ExceptionGroup.
ShouldRaise now supports ExceptionGroup.
Fixed bug where ~testfixtures.comparers.compare_generator did not respect strict=True.
Fixed bug in the type annotations for ShouldRaise and ~testfixtures.comparers.compare_exception.
LogCapture will now raise an exception if closed while still installed. This can be a source of particularly confusing bugs.
The strict option is now correctly respected when comparing nested objects.
The strict option is now correctly respected when comparing nested objects.
When comparing ~datetime.datetime or ~datetime.time instances, if the fold is the only thing that's different, it's now shown in the output.
A more detailed exception is now raised when resolving a replacement doesn't give what's expected.
Replacement of methods on instances is now prevented when strict=True.
An exception is now raised when mocking and the original is not in the __dict__ of its containing objects.
Fix bug where replacement of methods on subclasses failed when using Replacer.on_class.
Fix bug where replacement of methods on subclasses failed when using Replacer.on_class.
Implement strict comparison as an option for ~datetime.datetime and ~datetime.time.
Support bytes in popen.MockPopen commands.
Retire zope.component helpers.
Support bytes in popen.MockPopen commands.
Allow TempDirectory instances to be traversed as ~pathlib.Path objects.
Use the system default encoding where possible in TempDirectory.
Add TempDirectory option to manage current working directory.
Allow string class attributes to be replaced with Replacer and friends.
Fix nasty bug meaning some ~Replacer.on_class and ~Replacer.in_module replacements weren't restored.
Allow an alternative separator to be used for traversal during replacement with Replacer and friends.
Officially support Python 3.12.
Drop support Python 3.6.
Fix bug in support for os.PathLike arguments to popen.MockPopen.
Fix bug in support for os.PathLike arguments to popen.MockPopen.
Added missing support for os.PathLike arguments to popen.MockPopen.
Added missing support for os.PathLike arguments to popen.MockPopen.
Add order_matters parameter to ShouldWarn.
Add order_matters parameter to ShouldWarn.
Thanks to Jan Musílek for the implementation!
Implement new IDE and static-analysis ways of mocking including additional parameters to ~Replacer.replace along with the replace_on_class, replace_in
Implement new IDE and static-analysis ways of mocking including additional parameters to ~Replacer.replace along with the replace_on_class, replace_in_module and replace_in_environ context managers.
Remove py.typed file: neither mypy nor testfixtures are ready for this file to be present.
Remove py.typed file: neither mypy nor testfixtures are ready for this file to be present.
Further bugfixes around self-referential datastructures and compare.
Further bugfixes around self-referential datastructures and compare.
Reinstate support for self-referential data structures in compare. The new implementation provides more clarity about what's going on and also ignores
Reinstate support for self-referential data structures in compare. The new implementation provides more clarity about what's going on and also ignores more immutable data types.
Remove non-functional support for self-referential data structures in compare. The functionality didn't work but did cause erroneous reported equality
Remove non-functional support for self-referential data structures in compare. The functionality didn't work but did cause erroneous reported equality of values in dictionaries that were actually not equal.
test_date , test_datetime and test_time are still present as aliases but are now deprecated.
Refresh documentation.
Add type annotations.
Drop support for Python 2. The minimum supported Python version is now 3.6.
Sybil 3 is now the minimum supported version if you use ~.sybil.FileParser.
Rename and refactor the date and time mocks, they are now mock_date, mock_datetime and mock_time. test_date, test_datetime and test_time are still present as aliases but are now deprecated.
Add TempDirectory.as_string, TempDirectory.as_path and TempDirectory.as_local. TempDirectory.getpath is now deprecated.
TempDirectory can now be used to wrap existing directories.
Fixed a bug where OutputCapture.captured returned bytes instead of a string with fd=True.
The deprecated strict option to Comparison has been removed, use the partial option instead.
The deprecated TempDirectory.check, TempDirectory.check_dir and TempDirectory.check_all methods have been removed.
Fix bug in detection of Mock backport.
Fix bug in detection of Mock backport.
Ensure compatibility with Sybil 2 and Sybil 3 along with pytest 6 and pytest 7.
Ensure compatibility with Sybil 2 and Sybil 3 along with pytest 6 and pytest 7.
Fix bug when using compare on two regular expressions that have very long patterns.
Fix bug when using compare on two regular expressions that have very long patterns.
Thanks to Christoph Ludwig for the report.
Fix bug that meant LogCapture didn't preserve or provide a clean testing environment for filters.
Fix bug that meant LogCapture didn't preserve or provide a clean testing environment for filters.
Thanks to Jesse Rittner for the fix.
Fix bug when showing differences between mappings found by compare when mismatching values contained the same number more than once.
Fix bug when showing differences between mappings found by compare when mismatching values contained the same number more than once.
Add support for lazy resolution of prefix and suffix when using compare.
Add support for lazy resolution of prefix and suffix when using compare.
Fix bug where bug where duplicated entries in an ordered but partial SequenceComparison could result in a failed match.
Fix bug where bug where duplicated entries in an ordered but partial SequenceComparison could result in a failed match.
Fix deprecation warning about invalid escape sequence.
Add simpler flag support to StringComparison.
Fix deprecation warning about invalid escape sequence.
Thanks to Wim Glenn for the deprecation warning fix.
The strict parameter to Comparison has been deprecated in favour of partial.
Simplify and clarify the documentation of timezones when using test_datetime .
api has been re-arranged to make it easier to browse.
The strict parameter to Comparison has been deprecated in favour of partial.
Add SequenceComparison, Subset and Permutation objects.
Add MappingComparison objects.
Officially support Python 3.9.
Add support to LogCapture for making sure log entries above a specified level have been checked.
Add support to LogCapture for making sure log entries above a specified level have been checked.
Thanks to Zoltan Farkas for the implementation.
Fix bug where ignore_eq had no effect on nested objects when using compare.
Fix bug where ignore_eq had no effect on nested objects when using compare.
Thanks to Grégoire Payen de La Garanderie for the fix.
Fix bugs in comparison of ~unittest.mock.call objects where the repr of the ~unittest.mock.call arguments were the same even when their attributes wer
Fix bugs in comparison of ~unittest.mock.call objects where the repr of the ~unittest.mock.call arguments were the same even when their attributes were not.
Fix bugs in comparison of call() objects where the repr() of the call() arguments were the same even when their attributes were not.
Add support for non-deterministic logging order when using twisted.LogCapture.
Add support for non-deterministic logging order when using twisted.LogCapture.
Fix for using compare to compare two-element ~unittest.mock.call objects.
Fix for using compare to compare two-element ~unittest.mock.call objects.
Thanks to Daniel Fortunov for the fix.
Fix for using compare() to compare two-element call() objects.
Thanks to Daniel Fortunov for the fix.
Allow any attributes that need to be ignored to be specified directly when calling ~testfixtures.comparers.compare_object. This is handy when writing
Allow any attributes that need to be ignored to be specified directly when calling ~testfixtures.comparers.compare_object. This is handy when writing comparers for compare.
Fix a bug that occured when using compare to compare a string with a slotted object that had the same repr as the string.
Fix a bug that occured when using compare to compare a string with a slotted object that had the same repr as the string.
Add support for universal_newlines, text, encoding and errors to popen.MockPopen, but only for Python 3.
Add support for universal_newlines, text, encoding and errors to popen.MockPopen, but only for Python 3.
decimal.Decimal now has better representation when compare displays a failed comparison, particularly on Python 2.
decimal.Decimal now has better representation when compare displays a failed comparison, particularly on Python 2.
Add support to compare for explicitly naming objects to be compared as x and y. This allows symmetry with the x_label and y_label parameters that are now documented.
Restore ability for Comparison to compare properties and methods, although these uses are not recommended.
Thanks to Daniel Fortunov for all of the above.
Fix bug where new-style classes had their attributes checked with compare even when they were of different types.
Fix bug where new-style classes had their attributes checked with compare even when they were of different types.
Fix bugs in compare when comparing objects which have both __slots__ and a __dict__.
Fix bugs in compare when comparing objects which have both __slots__ and a __dict__.
Fix edge case where string interning made dictionary comparison output much less useful.
Fix edge case where string interning made dictionary comparison output much less useful.
Better feedback where objects do not compare equal but do have the same representation.
Better feedback where objects do not compare equal but do have the same representation.
Fix deprecation warning relating to getargspec.
Fix deprecation warning relating to getargspec.
Improve mocking docs.
Added strip_whitespace option to OutputCapture.
When separate is used with OutputCapture, differences in stdout and stderr are now given in the same AssertionError.
ShouldRaise no longer catches exceptions that are not of the required type.
Fixed a problem that resulted in unhelpful compare failures when ~unittest.mock.call was involved and Python 3.6.7 was used.
Thanks to Łukasz Rogalski for the deprecation warning fix.
Thanks to Wim Glenn for the ShouldRaise idea.
Fix handling of the latest releases of the mock backport.
Fix handling of the latest releases of the mock backport.
Fix bogus import in OutputCapture.
Fix bogus import in OutputCapture.
Allow OutputCapture to capture the underlying file descriptors for sys.stdout and sys.stderr.
Allow OutputCapture to capture the underlying file descriptors for sys.stdout and sys.stderr.
Silence DeprecationWarning relating to collections.abc on Python 3.7.
Silence DeprecationWarning relating to collections.abc on Python 3.7.
Thanks to Tom Hendrikx for the fix.
Add twisted.LogCapture.raise_logged_failure debugging helper.
Add twisted.LogCapture.raise_logged_failure debugging helper.
popen.MockPopen.set_command is now symmetrical with popen.MockPopen process instantiation in that both can be called with either lists or strings, in
popen.MockPopen.set_command is now symmetrical with popen.MockPopen process instantiation in that both can be called with either lists or strings, in the same way as subprocess.Popen.
Fixed bugs where using not_there to ensure a key or attribute was not there but would be set by a test would result in the test attribute or key being
Fixed bugs where using not_there to ensure a key or attribute was not there but would be set by a test would result in the test attribute or key being left behind.
Add support for comparing ~functools.partial instances and fix comparison of functions and other objects where vars() returns an empty dict.
Add the ability to ignore attributes of particular object types when using compare.
Add the ability to ignore attributes of particular object types when using compare.
Fix bug when compare was used with objects that had __slots__ inherited from a base class but where their __slots__ was an empty sequence.
Fix bug when compare was used with objects that had __slots__ inherited from a base class but where their __slots__ was an empty sequence.
Fix bug when compare was used with objects that had __slots__ inherited from a base class.
Fix bug when compare was used with objects that had __slots__ inherited from a base class.
Experimental support for making assertions about events logged with Twisted's logging framework.
Experimental support for making assertions about events logged with Twisted's logging framework.
Fix problems on Python 2 when the rolling backport of mock__ was not installed.
Fix problems on Python 2 when the rolling backport of mock was not installed.
Your coding agent can read these notes before it upgrades. Set up the MCP server →