This software provides utilities like helpers and mock objects that are useful for both unit tests and doc tests.
One of the useful classes available in TestFixtures is the Comparison class that allows users to instantiate placeholders to compare expected results with actual results when objects in the actual results do not support useful comparison. This class can make comparisons based only on object type, which is particularly advantageous for comparing sequences returned from tested code.
The compare class is another useful tool that replaces assertEquals and the failUnless(x() is True) pattern. It offers more useful differences between arguments, especially for sequences and long chains.
The diff function is another useful feature in the TestFixtures project that compares two strings and shows a unified diff of the comparison. It is handy as a third parameter to unittest.TestCase.assertEquals.
The generator function is also included in the TestFixtures package. It returns a generator that yields the arguments it was called with when the generator is iterated over.
Users can also utilize the LogCapture helper available in TestFixtures to capture log messages for specific loggers in doctests. The log_capture decorator is an alternative that allows users to capture log messages for specified loggers during unittest methods.
The replace decorator is another useful tool that enables users to replace objects such as classes and functions for the duration of a unittest approach. Importantly, the replacements are removed regardless of what happens during the test.
The Replacer helper in TestFixtures allows users to replace objects such as classes and functions within doctests and then restore the originals once testing is completed.
should_raise is another useful alternative to assertRaises that lets users verify that the exception raised is not only of the correct type but also has the correct parameters.
TestFixtures also offers test_date, test_datetime, and test_time classes that provide replacements for datetime that have a today, now, and time method, respectively. These features give repeatable, specifiable, testable dates and times.
Finally, the wrap decorator is a generic tool for wrapping method and function calls with a try-finally block, executing code before the try block and during the finally block.
Overall, TestFixtures is an excellent project with an array of useful tools that make writing unit tests or doc tests much more manageable, efficient and effective. It is highly recommended for developers that want to elevate their testing strategy.
Version 1.6.2: N/A