TestFixtures

Software Screenshot:
TestFixtures
Software Details:
Version: 3.0.0
Upload Date: 15 Apr 15
Developer: Chris Withers
Distribution Type: Freeware
Downloads: 0

Rating: nan/5 (Total Votes: 0)

The TestFixtures project offers a collection of helpers and mock objects that are useful when writing unit tests or doc tests.

The available helpers and mock objects are listed below, for functional examples, see the contents of the tests folder.

Comparison
 This class lets you instantiate placeholders that can be used to compared expected results with actual results where objects in the actual results do not support useful comparison. The comparision can be based just on the type of the object, which is particularly handy when comparing sequences returned from tested code.

compare
 A replacement for assertEquals and the failUnless(x() is True) pattern. Gives more useful differences when the arguments aren't the same, particularly for sequences and long strings.

diff
 This function will compare two strings and give a unified diff of their comparison. Handy as a third parameter to unittest.TestCase.assertEquals.

generator
 This function will return a generator that yields the arguments it was called with when the generator is iterated over.

LogCapture
 This helper allows you to capture log messages for specified loggers in doctests.

log_capture
 This decorator allows you to capture log messages for specified loggers for the duration of unittest methods.

replace
 This decorator enables you to replace objects such as classes and functions for the duration of a unittest method. The replacements are removed regardless of what happens during the test.

Replacer
 This helper enables you to replace objects such as classes and functions from within doctests and then restore the originals once testing is completed.

should_raise
 This is a better version of assertRaises that lets you check the exception raised is not only of the correct type but also has the correct parameters.

test_date
 This is a handy class factory that returns datetime.date replacements that have a today method that gives repeatable, specifiable, testable dates.

test_datetime
 This is a handy class factory that returns datetime.datetime replacements that have a now method that gives repeatable, specifiable, testable datetimes.

test_time
 This is a handy replacement for time.time that gives repeatable, specifiable, testable times.

wrap
 This is a generic decorator for wrapping method and function calls with a try-finally and having code executed before the try and as part of the finally.

What is new in this release:

  • fixed a bug where the @replace decorator passed a classmethod rather than the replacment to the decorated callable when replacing a classmethod
  • added set method to test_date,test_datetime and test_time to allow setting the parameters for the next instance to be returned.
  • added delta and delta_type parameters to test_date,test_datetime and test_time to control the intervals between returned instances.

What is new in version 1.6.3:

  • fixed several bugs in the instantiation of test_datetime and test_date instances which bit when type comparisons were made between instances and the class from which they were instantiated.

What is new in version 1.6.2:

  • changed Comparison to use __eq__ and __ne__ instead of the deprecated __cmp__
  • documented that order matters when using Comparisons with objects that implement __eq__ themselves, such as instances of Django models.

What is new in version 1.6.1:

  • @replace and Replacer.replace can now replace attributes that may not be present, provided the `strict` parameter is passed as False.
  • should_raise now catches BaseException rather than Exception so raising of SystemExit and KeyboardInterrupt can be tested.

What is new in version 1.6.0:

  • added support for using TempDirectory, Replacer and LogCapture as context managers for with statements
  • fixed test failure in Python 2.6

What is new in version 1.5.4:

  • fix bug where should_raise didn't complain when no exception was raised but one was expected.
  • clarified that the return of a should_raise call will be None in the event that an exception is raised by no expected exception is specified.

What is new in version 1.5.3:

  • should_raise now supports methods other than __call__

What is new in version 1.5.2:

  • added makedir and check_dir methods to TempDirectory and added support for sub directories to read and write

What is new in version 1.4.0:

  • improved representation of failed Comparison
  • improved representation of failed compare with sequences

Requirements:

  • Python

Other Software of Developer Chris Withers

Comments to TestFixtures

Comments not found
Add Comment
Turn on images!