10 * The timestamps generated by ``TestResult`` objects when no timing data has
11 been received are now datetime-with-timezone, which allows them to be
12 sensibly serialised and transported. (Robert Collins, #692297)
17 * ``MultiTestResult`` now forwards the ``time`` API. (Robert Collins, #692294)
22 In this release we bring some very interesting improvements:
24 * new matchers for exceptions, sets, lists, dicts and more.
26 * experimental (works but the contract isn't supported) twisted reactor
29 * The built in runner can now list tests and filter tests (the -l and
35 * addUnexpectedSuccess is translated to addFailure for test results that don't
36 know about addUnexpectedSuccess. Further, it fails the entire result for
37 all testtools TestResults (i.e. wasSuccessful() returns False after
38 addUnexpectedSuccess has been called). Note that when using a delegating
39 result such as ThreadsafeForwardingResult, MultiTestResult or
40 ExtendedToOriginalDecorator then the behaviour of addUnexpectedSuccess is
41 determined by the delegated to result(s).
42 (Jonathan Lange, Robert Collins, #654474, #683332)
44 * startTestRun will reset any errors on the result. That is, wasSuccessful()
45 will always return True immediately after startTestRun() is called. This
46 only applies to delegated test results (ThreadsafeForwardingResult,
47 MultiTestResult and ExtendedToOriginalDecorator) if the delegated to result
48 is a testtools test result - we cannot reliably reset the state of unknown
49 test result class instances. (Jonathan Lange, Robert Collins, #683332)
51 * Responsibility for running test cleanups has been moved to ``RunTest``.
52 This change does not affect public APIs and can be safely ignored by test
53 authors. (Jonathan Lange, #662647)
58 * ``assertIsInstance`` supports a custom error message to be supplied, which
59 is necessary when using ``assertDictEqual`` on Python 2.7 with a
60 ``testtools.TestCase`` base class. (Jelmer Vernooij)
62 * Experimental support for running tests that return Deferreds.
63 (Jonathan Lange, Martin [gz])
65 * Provide a per-test decorator, run_test_with, to specify which RunTest
66 object to use for a given test. (Jonathan Lange, #657780)
68 * Fix the runTest parameter of TestCase to actually work, rather than raising
69 a TypeError. (Jonathan Lange, #657760)
71 * New matcher ``EndsWith`` added to complement the existing ``StartsWith``
72 matcher. (Jonathan Lange, #669165)
74 * Non-release snapshots of testtools will now work with buildout.
75 (Jonathan Lange, #613734)
77 * Malformed SyntaxErrors no longer blow up the test suite. (Martin [gz])
79 * ``MatchesException`` added to the ``testtools.matchers`` module - matches
80 an exception class and parameters. (Robert Collins)
82 * ``MismatchesAll.describe`` no longer appends a trailing newline.
83 (Michael Hudson-Doyle, #686790)
85 * New ``KeysEqual`` matcher. (Jonathan Lange)
87 * New helpers for conditionally importing modules, ``try_import`` and
88 ``try_imports``. (Jonathan Lange)
90 * ``Raises`` added to the ``testtools.matchers`` module - matches if the
91 supplied callable raises, and delegates to an optional matcher for validation
92 of the exception. (Robert Collins)
94 * ``raises`` added to the ``testtools.matchers`` module - matches if the
95 supplied callable raises and delegates to ``MatchesException`` to validate
96 the exception. (Jonathan Lange)
98 * Tests will now pass on Python 2.6.4 : an ``Exception`` change made only in
99 2.6.4 and reverted in Python 2.6.5 was causing test failures on that version.
100 (Martin [gz], #689858).
102 * ``testtools.TestCase.useFixture`` has been added to glue with fixtures nicely.
105 * ``testtools.run`` now supports ``-l`` to list tests rather than executing
106 them. This is useful for integration with external test analysis/processing
107 tools like subunit and testrepository. (Robert Collins)
109 * ``testtools.run`` now supports ``--load-list``, which takes a file containing
110 test ids, one per line, and intersects those ids with the tests found. This
111 allows fine grained control of what tests are run even when the tests cannot
112 be named as objects to import (e.g. due to test parameterisation via
113 testscenarios). (Robert Collins)
115 * Update documentation to say how to use testtools.run() on Python 2.4.
116 (Jonathan Lange, #501174)
118 * ``text_content`` conveniently converts a Python string to a Content object.
119 (Jonathan Lange, James Westby)
126 Lots of little cleanups in this release; many small improvements to make your
127 testing life more pleasant.
132 * Cleanups can raise ``testtools.MultipleExceptions`` if they have multiple
133 exceptions to report. For instance, a cleanup which is itself responsible for
134 running several different internal cleanup routines might use this.
136 * Code duplication between assertEqual and the matcher Equals has been removed.
138 * In normal circumstances, a TestCase will no longer share details with clones
139 of itself. (Andrew Bennetts, bug #637725)
141 * Less exception object cycles are generated (reduces peak memory use between
142 garbage collection). (Martin [gz])
144 * New matchers 'DoesNotStartWith' and 'StartsWith' contributed by Canonical
145 from the Launchpad project. Written by James Westby.
147 * Timestamps as produced by subunit protocol clients are now forwarded in the
148 ThreadsafeForwardingResult so correct test durations can be reported.
149 (Martin [gz], Robert Collins, #625594)
151 * With unittest from Python 2.7 skipped tests will now show only the reason
152 rather than a serialisation of all details. (Martin [gz], #625583)
154 * The testtools release process is now a little better documented and a little
155 smoother. (Jonathan Lange, #623483, #623487)
161 Nothing major in this release, just enough small bits and pieces to make it
162 useful enough to upgrade to.
164 In particular, a serious bug in assertThat() has been fixed, it's easier to
165 write Matchers, there's a TestCase.patch() method for those inevitable monkey
166 patches and TestCase.assertEqual gives slightly nicer errors.
171 * 'TestCase.assertEqual' now formats errors a little more nicely, in the
174 * Added `PlaceHolder` and `ErrorHolder`, TestCase-like objects that can be
175 used to add results to a `TestResult`.
177 * 'Mismatch' now takes optional description and details parameters, so
178 custom Matchers aren't compelled to make their own subclass.
180 * jml added a built-in UTF8_TEXT ContentType to make it slightly easier to
181 add details to test results. See bug #520044.
183 * Fix a bug in our built-in matchers where assertThat would blow up if any
184 of them failed. All built-in mismatch objects now provide get_details().
186 * New 'Is' matcher, which lets you assert that a thing is identical to
189 * New 'LessThan' matcher which lets you assert that a thing is less than
192 * TestCase now has a 'patch()' method to make it easier to monkey-patching
193 objects in tests. See the manual for more information. Fixes bug #310770.
195 * MultiTestResult methods now pass back return values from the results it
201 This release fixes some obscure traceback formatting issues that probably
202 weren't affecting you but were certainly breaking our own test suite.
207 * Jamu Kakar has updated classes in testtools.matchers and testtools.runtest
208 to be new-style classes, fixing bug #611273.
213 * Martin[gz] fixed traceback handling to handle cases where extract_tb returns
214 a source line of None. Fixes bug #611307.
216 * Martin[gz] fixed an unicode issue that was causing the tests to fail,
219 * testtools now handles string exceptions (although why would you want to use
220 them?) and formats their tracebacks correctly. Thanks to Martin[gz] for
226 This release overhauls the traceback formatting layer to deal with Python 2
227 line numbers and traceback objects often being local user encoded strings
228 rather than unicode objects. Test discovery has also been added and Python 3.1
229 is also supported. Finally, the Mismatch protocol has been extended to let
230 Matchers collaborate with tests in supplying detailed data about failures.
235 * testtools.utils has been renamed to testtools.compat. Importing
236 testtools.utils will now generate a deprecation warning.
241 * Add machinery for Python 2 to create unicode tracebacks like those used by
242 Python 3. This means testtools no longer throws on encountering non-ascii
243 filenames, source lines, or exception strings when displaying test results.
244 Largely contributed by Martin[gz] with some tweaks from Robert Collins.
246 * James Westby has supplied test discovery support using the Python 2.7
247 TestRunner in testtools.run. This requires the 'discover' module. This
250 * Python 3.1 is now supported, thanks to Martin[gz] for a partial patch.
251 This fixes bug #592375.
253 * TestCase.addCleanup has had its docstring corrected about when cleanups run.
255 * TestCase.skip is now deprecated in favour of TestCase.skipTest, which is the
256 Python2.7 spelling for skip. This closes bug #560436.
258 * Tests work on IronPython patch from Martin[gz] applied.
260 * Thanks to a patch from James Westby testtools.matchers.Mismatch can now
261 supply a get_details method, which assertThat will query to provide
262 additional attachments. This can be used to provide additional detail
263 about the mismatch that doesn't suite being included in describe(). For
264 instance, if the match process was complex, a log of the process could be
265 included, permitting debugging.
267 * testtools.testresults.real._StringException will now answer __str__ if its
268 value is unicode by encoding with UTF8, and vice versa to answer __unicode__.
269 This permits subunit decoded exceptions to contain unicode and still format
275 More matchers, Python 2.4 support, faster test cloning by switching to copy
276 rather than deepcopy and better output when exceptions occur in cleanups are
277 the defining characteristics of this release.
282 * New matcher "Annotate" that adds a simple string message to another matcher,
283 much like the option 'message' parameter to standard library assertFoo
286 * New matchers "Not" and "MatchesAll". "Not" will invert another matcher, and
287 "MatchesAll" that needs a successful match for all of its arguments.
289 * On Python 2.4, where types.FunctionType cannot be deepcopied, testtools will
290 now monkeypatch copy._deepcopy_dispatch using the same trivial patch that
291 added such support to Python 2.5. The monkey patch is triggered by the
292 absence of FunctionType from the dispatch dict rather than a version check.
295 * On windows the test 'test_now_datetime_now' should now work reliably.
297 * TestCase.getUniqueInteger and TestCase.getUniqueString now have docstrings.
299 * TestCase.getUniqueString now takes an optional prefix parameter, so you can
300 now use it in circumstances that forbid strings with '.'s, and such like.
302 * testtools.testcase.clone_test_with_new_id now uses copy.copy, rather than
303 copy.deepcopy. Tests that need a deeper copy should use the copy protocol to
304 control how they are copied. Bug #498869.
306 * The backtrace test result output tests should now pass on windows and other
307 systems where os.sep is not '/'.
309 * When a cleanUp or tearDown exception occurs, it is now accumulated as a new
310 traceback in the test details, rather than as a separate call to addError /
311 addException. This makes testtools work better with most TestResult objects
312 and fixes bug #335816.
318 Python 3 support, more matchers and better consistency with Python 2.7 --
319 you'd think that would be enough for a point release. Well, we here on the
320 testtools project think that you deserve more.
322 We've added a hook so that user code can be called just-in-time whenever there
323 is an exception, and we've also factored out the "run" logic of test cases so
324 that new outcomes can be added without fiddling with the actual flow of logic.
326 It might sound like small potatoes, but it's changes like these that will
327 bring about the end of test frameworks.
333 * A failure in setUp and tearDown now report as failures not as errors.
335 * Cleanups now run after tearDown to be consistent with Python 2.7's cleanup
338 * ExtendedToOriginalDecorator now passes unrecognised attributes through
339 to the decorated result object, permitting other extensions to the
340 TestCase -> TestResult protocol to work.
342 * It is now possible to trigger code just-in-time after an exception causes
343 a test outcome such as failure or skip. See the testtools MANUAL or
344 ``pydoc testtools.TestCase.addOnException``. (bug #469092)
346 * New matcher Equals which performs a simple equality test.
348 * New matcher MatchesAny which looks for a match of any of its arguments.
350 * TestCase no longer breaks if a TestSkipped exception is raised with no
353 * TestCase.run now clones test cases before they are run and runs the clone.
354 This reduces memory footprint in large test runs - state accumulated on
355 test objects during their setup and execution gets freed when test case
356 has finished running unless the TestResult object keeps a reference.
357 NOTE: As test cloning uses deepcopy, this can potentially interfere if
358 a test suite has shared state (such as the testscenarios or testresources
359 projects use). Use the __deepcopy__ hook to control the copying of such
360 objects so that the shared references stay shared.
362 * Testtools now accepts contributions without copyright assignment under some
363 circumstances. See HACKING for details.
365 * Testtools now provides a convenient way to run a test suite using the
366 testtools result object: python -m testtools.run testspec [testspec...].
368 * Testtools now works on Python 3, thanks to Benjamin Peterson.
370 * Test execution now uses a separate class, testtools.RunTest to run single
371 tests. This can be customised and extended in a more consistent fashion than
372 the previous run method idiom. See pydoc for more information.
374 * The test doubles that testtools itself uses are now available as part of
375 the testtools API in testtols.testresult.doubles.
377 * TracebackContent now sets utf8 as the charset encoding, rather than not
378 setting one and encoding with the default encoder.
380 * With python2.7 testtools.TestSkipped will be the unittest.case.SkipTest
381 exception class making skips compatible with code that manually raises the
382 standard library exception. (bug #490109)
387 * TestCase.getUniqueInteger is now implemented using itertools.count. Thanks
388 to Benjamin Peterson for the patch. (bug #490111)
394 The new matcher API introduced in 0.9.0 had a small flaw where the matchee
395 would be evaluated twice to get a description of the mismatch. This could lead
396 to bugs if the act of matching caused side effects to occur in the matchee.
397 Since having such side effects isn't desirable, we have changed the API now
398 before it has become widespread.
403 * Matcher API changed to avoid evaluating matchee twice. Please consult
404 the API documentation.
406 * TestCase.getUniqueString now uses the test id, not the test method name,
407 which works nicer with parameterised tests.
412 * Python2.4 is now supported again.
418 This release of testtools is perhaps the most interesting and exciting one
419 it's ever had. We've continued in bringing together the best practices of unit
420 testing from across a raft of different Python projects, but we've also
421 extended our mission to incorporating unit testing concepts from other
422 languages and from our own research, led by Robert Collins.
424 We now support skipping and expected failures. We'll make sure that you
425 up-call setUp and tearDown, avoiding unexpected testing weirdnesses. We're
426 now compatible with Python 2.5, 2.6 and 2.7 unittest library.
428 All in all, if you are serious about unit testing and want to get the best
429 thinking from the whole Python community, you should get this release.
434 * A new TestResult API has been added for attaching details to test outcomes.
435 This API is currently experimental, but is being prepared with the intent
436 of becoming an upstream Python API. For more details see pydoc
437 testtools.TestResult and the TestCase addDetail / getDetails methods.
439 * assertThat has been added to TestCase. This new assertion supports
440 a hamcrest-inspired matching protocol. See pydoc testtools.Matcher for
441 details about writing matchers, and testtools.matchers for the included
442 matchers. See http://code.google.com/p/hamcrest/.
444 * Compatible with Python 2.6 and Python 2.7
446 * Failing to upcall in setUp or tearDown will now cause a test failure.
447 While the base methods do nothing, failing to upcall is usually a problem
448 in deeper hierarchies, and checking that the root method is called is a
449 simple way to catch this common bug.
451 * New TestResult decorator ExtendedToOriginalDecorator which handles
452 downgrading extended API calls like addSkip to older result objects that
453 do not support them. This is used internally to make testtools simpler but
454 can also be used to simplify other code built on or for use with testtools.
456 * New TextTestResult supporting the extended APIs that testtools provides.
458 * Nose will no longer find 'runTest' tests in classes derived from
459 testtools.testcase.TestCase (bug #312257).
461 * Supports the Python 2.7/3.1 addUnexpectedSuccess and addExpectedFailure
462 TestResult methods, with a support function 'knownFailure' to let tests
463 trigger these outcomes.
465 * When using the skip feature with TestResult objects that do not support it
466 a test success will now be reported. Previously an error was reported but
467 production experience has shown that this is too disruptive for projects that
468 are using skips: they cannot get a clean run on down-level result objects.