4 Changes and improvements to testtools_, grouped by release.
15 * ``testtools.run discover`` will now sort the tests it discovered. This is a
16 workaround for http://bugs.python.org/issue16709. Non-standard test suites
17 are preserved, and their ``sort_tests()`` method called (if they have such an
18 attribute). ``testtools.testsuite.sorted_tests(suite, True)`` can be used by
19 such suites to do a local sort. (Robert Collins, #1091512)
21 * ``ThreadsafeForwardingResult`` now defines a stub ``progress`` method, which
22 fixes ``testr run`` of streams containing progress markers (by discarding the
23 progress data). (Robert Collins, #1019165)
31 * ``run.TestToolsTestRunner`` now accepts the verbosity, buffer and failfast
32 arguments the upstream python TestProgram code wants to give it, making it
33 possible to support them in a compatible fashion. (Robert Collins)
38 * ``testtools.run`` now supports the ``-f`` or ``--failfast`` parameter.
39 Previously it was advertised in the help but ignored.
40 (Robert Collins, #1090582)
42 * ``AnyMatch`` added, a new matcher that matches when any item in a collection
43 matches the given matcher. (Jonathan Lange)
45 * Spelling corrections to documentation. (Vincent Ladeuil)
47 * ``TestProgram`` now has a sane default for its ``testRunner`` argument.
50 * The test suite passes on Python 3 again. (Robert Collins)
58 * ``content_from_file`` and ``content_from_stream`` now accept seek_offset and
59 seek_whence parameters allowing them to be used to grab less than the full
60 stream, or to be used with StringIO streams. (Robert Collins, #1088693)
68 * ``DirContains`` correctly exposed, after being accidentally hidden in the
69 great matcher re-organization of 0.9.17. (Jonathan Lange)
75 Three new matchers that'll rock your world.
80 * New, powerful matchers that match items in a dictionary:
82 - ``MatchesDict``, match every key in a dictionary with a key in a
83 dictionary of matchers. For when the set of expected keys is equal to the
86 - ``ContainsDict``, every key in a dictionary of matchers must be
87 found in a dictionary, and the values for those keys must match. For when
88 the set of expected keys is a subset of the set of observed keys.
90 - ``ContainedByDict``, every key in a dictionary must be found in
91 a dictionary of matchers. For when the set of expected keys is a superset
92 of the set of observed keys.
94 The names are a little confusing, sorry. We're still trying to figure out
95 how to present the concept in the simplest way possible.
101 How embarrassing! Three releases in two days.
103 We've worked out the kinks and have confirmation from our downstreams that
104 this is all good. Should be the last release for a little while. Please
105 ignore 0.9.18 and 0.9.17.
110 * Include the matcher tests in the release, allowing the tests to run and
111 pass from the release tarball. (Jonathan Lange)
113 * Fix cosmetic test failures in Python 3.3, introduced during release 0.9.17.
120 Due to an oversight, release 0.9.18 did not contain the new
121 ``testtools.matchers`` package and was thus completely broken. This release
122 corrects that, returning us all to normality.
127 This release brings better discover support and Python3.x improvements. There
128 are still some test failures on Python3.3 but they are cosmetic - the library
129 is as usable there as on any other Python 3 release.
134 * The ``testtools.matchers`` package has been split up. No change to the
135 public interface. (Jonathan Lange)
140 * ``python -m testtools.run discover . --list`` now works. (Robert Collins)
142 * Correctly handling of bytes vs text in JSON content type. (Martin [gz])
148 Some new matchers and a new content helper for JSON content.
150 This is the first release of testtools to drop support for Python 2.4 and 2.5.
151 If you need support for either of those versions, please use testtools 0.9.15.
156 * New content helper, ``json_content`` (Jonathan Lange)
160 * ``ContainsAll`` for asserting one thing is a subset of another
163 * ``SameMembers`` for asserting two iterators have the same members.
166 * Reraising of exceptions in Python 3 is more reliable. (Martin [gz])
172 This is the last release to support Python2.4 and 2.5. It brings in a slew of
173 improvements to test tagging and concurrency, making running large test suites
174 with partitioned workers more reliable and easier to reproduce exact test
175 ordering in a given worker. See our sister project ``testrepository`` for a
176 test runner that uses these features.
181 * ``PlaceHolder`` and ``ErrorHolder`` now support being given result details.
184 * ``ErrorHolder`` is now just a function - all the logic is in ``PlaceHolder``.
187 * ``TestResult`` and all other ``TestResult``-like objects in testtools
188 distinguish between global tags and test-local tags, as per the subunit
189 specification. (Jonathan Lange)
191 * This is the **last** release of testtools that supports Python 2.4 or 2.5.
192 These releases are no longer supported by the Python community and do not
193 receive security updates. If this affects you, you will need to either
194 stay on this release or perform your own backports.
195 (Jonathan Lange, Robert Collins)
197 * ``ThreadsafeForwardingResult`` now forwards global tags as test-local tags,
198 making reasoning about the correctness of the multiplexed stream simpler.
199 This preserves the semantic value (what tags apply to a given test) while
200 consuming less stream size (as no negative-tag statement is needed).
201 (Robert Collins, Gary Poster, #986434)
206 * API documentation corrections. (Raphaël Badin)
208 * ``ConcurrentTestSuite`` now takes an optional ``wrap_result`` parameter
209 that can be used to wrap the ``ThreadsafeForwardingResult``s created by
210 the suite. (Jonathan Lange)
212 * ``Tagger`` added. It's a new ``TestResult`` that tags all tests sent to
213 it with a particular set of tags. (Jonathan Lange)
215 * ``testresultdecorator`` brought over from subunit. (Jonathan Lange)
217 * All ``TestResult`` wrappers now correctly forward ``current_tags`` from
218 their wrapped results, meaning that ``current_tags`` can always be relied
219 upon to return the currently active tags on a test result.
221 * ``TestByTestResult``, a ``TestResult`` that calls a method once per test,
222 added. (Jonathan Lange)
224 * ``ThreadsafeForwardingResult`` correctly forwards ``tags()`` calls where
225 only one of ``new_tags`` or ``gone_tags`` are specified.
226 (Jonathan Lange, #980263)
228 * ``ThreadsafeForwardingResult`` no longer leaks local tags from one test
229 into all future tests run. (Jonathan Lange, #985613)
231 * ``ThreadsafeForwardingResult`` has many, many more tests. (Jonathan Lange)
237 Our sister project, `subunit <https://launchpad.net/subunit>`_, was using a
238 private API that was deleted in the 0.9.13 release. This release restores
239 that API in order to smooth out the upgrade path.
241 If you don't use subunit, then this release won't matter very much to you.
247 Plenty of new matchers and quite a few critical bug fixes (especially to do
248 with stack traces from failed assertions). A net win for all.
253 * ``MatchesAll`` now takes an ``first_only`` keyword argument that changes how
254 mismatches are displayed. If you were previously passing matchers to
255 ``MatchesAll`` with keyword arguments, then this change might affect your
256 test results. (Jonathan Lange)
261 * Actually hide all of the testtools stack for assertion failures. The
262 previous release promised clean stack, but now we actually provide it.
263 (Jonathan Lange, #854769)
265 * ``assertRaises`` now includes the ``repr`` of the callable that failed to raise
266 properly. (Jonathan Lange, #881052)
268 * Asynchronous tests no longer hang when run with trial.
269 (Jonathan Lange, #926189)
271 * ``Content`` objects now have an ``as_text`` method to convert their contents
272 to Unicode text. (Jonathan Lange)
274 * Failed equality assertions now line up. (Jonathan Lange, #879339)
276 * ``FullStackRunTest`` no longer aborts the test run if a test raises an
277 error. (Jonathan Lange)
279 * ``MatchesAll`` and ``MatchesListwise`` both take a ``first_only`` keyword
280 argument. If True, they will report only on the first mismatch they find,
281 and not continue looking for other possible mismatches.
284 * New helper, ``Nullary`` that turns callables with arguments into ones that
285 don't take arguments. (Jonathan Lange)
289 * ``DirContains`` matches the contents of a directory.
290 (Jonathan Lange, James Westby)
292 * ``DirExists`` matches if a directory exists.
293 (Jonathan Lange, James Westby)
295 * ``FileContains`` matches the contents of a file.
296 (Jonathan Lange, James Westby)
298 * ``FileExists`` matches if a file exists.
299 (Jonathan Lange, James Westby)
301 * ``HasPermissions`` matches the permissions of a file. (Jonathan Lange)
303 * ``MatchesPredicate`` matches if a predicate is true. (Jonathan Lange)
305 * ``PathExists`` matches if a path exists. (Jonathan Lange, James Westby)
307 * ``SamePath`` matches if two paths are the same. (Jonathan Lange)
309 * ``TarballContains`` matches the contents of a tarball. (Jonathan Lange)
311 * ``MultiTestResult`` supports the ``tags`` method.
312 (Graham Binns, Francesco Banconi, #914279)
314 * ``ThreadsafeForwardingResult`` supports the ``tags`` method.
315 (Graham Binns, Francesco Banconi, #914279)
317 * ``ThreadsafeForwardingResult`` no longer includes semaphore acquisition time
318 in the test duration (for implicitly timed test runs).
319 (Robert Collins, #914362)
324 This is a very big release. We've made huge improvements on three fronts:
325 1. Test failures are way nicer and easier to read
326 2. Matchers and ``assertThat`` are much more convenient to use
327 3. Correct handling of extended unicode characters
329 We've trimmed off the fat from the stack trace you get when tests fail, we've
330 cut out the bits of error messages that just didn't help, we've made it easier
331 to annotate mismatch failures, to compare complex objects and to match raised
334 Testing code was never this fun.
339 * ``AfterPreproccessing`` renamed to ``AfterPreprocessing``, which is a more
340 correct spelling. Old name preserved for backwards compatibility, but is
341 now deprecated. Please stop using it.
342 (Jonathan Lange, #813460)
344 * ``assertThat`` raises ``MismatchError`` instead of
345 ``TestCase.failureException``. ``MismatchError`` is a subclass of
346 ``AssertionError``, so in most cases this change will not matter. However,
347 if ``self.failureException`` has been set to a non-default value, then
348 mismatches will become test errors rather than test failures.
350 * ``gather_details`` takes two dicts, rather than two detailed objects.
351 (Jonathan Lange, #801027)
353 * ``MatchesRegex`` mismatch now says "<value> does not match /<regex>/" rather
354 than "<regex> did not match <value>". The regular expression contains fewer
355 backslashes too. (Jonathan Lange, #818079)
357 * Tests that run with ``AsynchronousDeferredRunTest`` now have the ``reactor``
358 attribute set to the running reactor. (Jonathan Lange, #720749)
363 * All public matchers are now in ``testtools.matchers.__all__``.
364 (Jonathan Lange, #784859)
366 * ``assertThat`` can actually display mismatches and matchers that contain
367 extended unicode characters. (Jonathan Lange, Martin [gz], #804127)
369 * ``assertThat`` output is much less verbose, displaying only what the mismatch
370 tells us to display. Old-style verbose output can be had by passing
371 ``verbose=True`` to assertThat. (Jonathan Lange, #675323, #593190)
373 * ``assertThat`` accepts a message which will be used to annotate the matcher.
374 This can be given as a third parameter or as a keyword parameter.
377 * Automated the Launchpad part of the release process.
378 (Jonathan Lange, #623486)
380 * Correctly display non-ASCII unicode output on terminals that claim to have a
381 unicode encoding. (Martin [gz], #804122)
383 * ``DocTestMatches`` correctly handles unicode output from examples, rather
384 than raising an error. (Martin [gz], #764170)
386 * ``ErrorHolder`` and ``PlaceHolder`` added to docs. (Jonathan Lange, #816597)
388 * ``ExpectedException`` now matches any exception of the given type by
389 default, and also allows specifying a ``Matcher`` rather than a mere regular
390 expression. (Jonathan Lange, #791889)
392 * ``FixtureSuite`` added, allows test suites to run with a given fixture.
395 * Hide testtools's own stack frames when displaying tracebacks, making it
396 easier for test authors to focus on their errors.
397 (Jonathan Lange, Martin [gz], #788974)
399 * Less boilerplate displayed in test failures and errors.
400 (Jonathan Lange, #660852)
402 * ``MatchesException`` now allows you to match exceptions against any matcher,
403 rather than just regular expressions. (Jonathan Lange, #791889)
405 * ``MatchesException`` now permits a tuple of types rather than a single type
406 (when using the type matching mode). (Robert Collins)
408 * ``MatchesStructure.byEquality`` added to make the common case of matching
409 many attributes by equality much easier. ``MatchesStructure.byMatcher``
410 added in case folk want to match by things other than equality.
413 * New convenience assertions, ``assertIsNone`` and ``assertIsNotNone``.
418 * ``AllMatch`` matches many values against a single matcher.
419 (Jonathan Lange, #615108)
421 * ``Contains``. (Robert Collins)
423 * ``GreaterThan``. (Christian Kampka)
425 * New helper, ``safe_hasattr`` added. (Jonathan Lange)
427 * ``reraise`` added to ``testtools.compat``. (Jonathan Lange)
433 This release brings consistent use of super for better compatibility with
434 multiple inheritance, fixed Python3 support, improvements in fixture and mather
435 outputs and a compat helper for testing libraries that deal with bytestrings.
440 * ``TestCase`` now uses super to call base ``unittest.TestCase`` constructor,
441 ``setUp`` and ``tearDown``. (Tim Cole, #771508)
443 * If, when calling ``useFixture`` an error occurs during fixture set up, we
444 still attempt to gather details from the fixture. (Gavin Panella)
450 * Additional compat helper for ``BytesIO`` for libraries that build on
451 testtools and are working on Python 3 porting. (Robert Collins)
453 * Corrected documentation for ``MatchesStructure`` in the test authors
454 document. (Jonathan Lange)
456 * ``LessThan`` error message now says something that is logically correct.
457 (Gavin Panella, #762008)
459 * Multiple details from a single fixture are now kept separate, rather than
460 being mooshed together. (Gavin Panella, #788182)
462 * Python 3 support now back in action. (Martin [gz], #688729)
464 * ``try_import`` and ``try_imports`` have a callback that is called whenever
465 they fail to import a module. (Martin Pool)
471 The last release of testtools could not be easy_installed. This is considered
472 severe enough for a re-release.
477 * Include ``doc/`` in the source distribution, making testtools installable
478 from PyPI again (Tres Seaver, #757439)
484 Many, many new matchers, vastly expanded documentation, stacks of bug fixes,
485 better unittest2 integration. If you've ever wanted to try out testtools but
486 been afraid to do so, this is the release to try.
492 * The timestamps generated by ``TestResult`` objects when no timing data has
493 been received are now datetime-with-timezone, which allows them to be
494 sensibly serialised and transported. (Robert Collins, #692297)
499 * ``AnnotatedMismatch`` now correctly returns details.
500 (Jonathan Lange, #724691)
502 * distutils integration for the testtools test runner. Can now use it for
503 'python setup.py test'. (Christian Kampka, #693773)
505 * ``EndsWith`` and ``KeysEqual`` now in testtools.matchers.__all__.
506 (Jonathan Lange, #692158)
508 * ``MatchesException`` extended to support a regular expression check against
509 the str() of a raised exception. (Jonathan Lange)
511 * ``MultiTestResult`` now forwards the ``time`` API. (Robert Collins, #692294)
513 * ``MultiTestResult`` now documented in the manual. (Jonathan Lange, #661116)
515 * New content helpers ``content_from_file``, ``content_from_stream`` and
516 ``attach_file`` make it easier to attach file-like objects to a
517 test. (Jonathan Lange, Robert Collins, #694126)
519 * New ``ExpectedException`` context manager to help write tests against things
520 that are expected to raise exceptions. (Aaron Bentley)
524 * ``MatchesListwise`` matches an iterable of matchers against an iterable
525 of values. (Michael Hudson-Doyle)
527 * ``MatchesRegex`` matches a string against a regular expression.
528 (Michael Hudson-Doyle)
530 * ``MatchesStructure`` matches attributes of an object against given
531 matchers. (Michael Hudson-Doyle)
533 * ``AfterPreproccessing`` matches values against a matcher after passing them
534 through a callable. (Michael Hudson-Doyle)
536 * ``MatchesSetwise`` matches an iterable of matchers against an iterable of
537 values, without regard to order. (Michael Hudson-Doyle)
539 * ``setup.py`` can now build a snapshot when Bazaar is installed but the tree
540 is not a Bazaar tree. (Jelmer Vernooij)
542 * Support for running tests using distutils (Christian Kampka, #726539)
544 * Vastly improved and extended documentation. (Jonathan Lange)
546 * Use unittest2 exception classes if available. (Jelmer Vernooij)
552 In this release we bring some very interesting improvements:
554 * new matchers for exceptions, sets, lists, dicts and more.
556 * experimental (works but the contract isn't supported) twisted reactor
559 * The built in runner can now list tests and filter tests (the -l and
560 --load-list options).
565 * addUnexpectedSuccess is translated to addFailure for test results that don't
566 know about addUnexpectedSuccess. Further, it fails the entire result for
567 all testtools TestResults (i.e. wasSuccessful() returns False after
568 addUnexpectedSuccess has been called). Note that when using a delegating
569 result such as ThreadsafeForwardingResult, MultiTestResult or
570 ExtendedToOriginalDecorator then the behaviour of addUnexpectedSuccess is
571 determined by the delegated to result(s).
572 (Jonathan Lange, Robert Collins, #654474, #683332)
574 * startTestRun will reset any errors on the result. That is, wasSuccessful()
575 will always return True immediately after startTestRun() is called. This
576 only applies to delegated test results (ThreadsafeForwardingResult,
577 MultiTestResult and ExtendedToOriginalDecorator) if the delegated to result
578 is a testtools test result - we cannot reliably reset the state of unknown
579 test result class instances. (Jonathan Lange, Robert Collins, #683332)
581 * Responsibility for running test cleanups has been moved to ``RunTest``.
582 This change does not affect public APIs and can be safely ignored by test
583 authors. (Jonathan Lange, #662647)
590 * ``EndsWith`` which complements the existing ``StartsWith`` matcher.
591 (Jonathan Lange, #669165)
593 * ``MatchesException`` matches an exception class and parameters. (Robert
596 * ``KeysEqual`` matches a dictionary with particular keys. (Jonathan Lange)
598 * ``assertIsInstance`` supports a custom error message to be supplied, which
599 is necessary when using ``assertDictEqual`` on Python 2.7 with a
600 ``testtools.TestCase`` base class. (Jelmer Vernooij)
602 * Experimental support for running tests that return Deferreds.
603 (Jonathan Lange, Martin [gz])
605 * Provide a per-test decorator, run_test_with, to specify which RunTest
606 object to use for a given test. (Jonathan Lange, #657780)
608 * Fix the runTest parameter of TestCase to actually work, rather than raising
609 a TypeError. (Jonathan Lange, #657760)
611 * Non-release snapshots of testtools will now work with buildout.
612 (Jonathan Lange, #613734)
614 * Malformed SyntaxErrors no longer blow up the test suite. (Martin [gz])
616 * ``MismatchesAll.describe`` no longer appends a trailing newline.
617 (Michael Hudson-Doyle, #686790)
619 * New helpers for conditionally importing modules, ``try_import`` and
620 ``try_imports``. (Jonathan Lange)
622 * ``Raises`` added to the ``testtools.matchers`` module - matches if the
623 supplied callable raises, and delegates to an optional matcher for validation
624 of the exception. (Robert Collins)
626 * ``raises`` added to the ``testtools.matchers`` module - matches if the
627 supplied callable raises and delegates to ``MatchesException`` to validate
628 the exception. (Jonathan Lange)
630 * Tests will now pass on Python 2.6.4 : an ``Exception`` change made only in
631 2.6.4 and reverted in Python 2.6.5 was causing test failures on that version.
632 (Martin [gz], #689858).
634 * ``testtools.TestCase.useFixture`` has been added to glue with fixtures nicely.
637 * ``testtools.run`` now supports ``-l`` to list tests rather than executing
638 them. This is useful for integration with external test analysis/processing
639 tools like subunit and testrepository. (Robert Collins)
641 * ``testtools.run`` now supports ``--load-list``, which takes a file containing
642 test ids, one per line, and intersects those ids with the tests found. This
643 allows fine grained control of what tests are run even when the tests cannot
644 be named as objects to import (e.g. due to test parameterisation via
645 testscenarios). (Robert Collins)
647 * Update documentation to say how to use testtools.run() on Python 2.4.
648 (Jonathan Lange, #501174)
650 * ``text_content`` conveniently converts a Python string to a Content object.
651 (Jonathan Lange, James Westby)
658 Lots of little cleanups in this release; many small improvements to make your
659 testing life more pleasant.
664 * Cleanups can raise ``testtools.MultipleExceptions`` if they have multiple
665 exceptions to report. For instance, a cleanup which is itself responsible for
666 running several different internal cleanup routines might use this.
668 * Code duplication between assertEqual and the matcher Equals has been removed.
670 * In normal circumstances, a TestCase will no longer share details with clones
671 of itself. (Andrew Bennetts, bug #637725)
673 * Less exception object cycles are generated (reduces peak memory use between
674 garbage collection). (Martin [gz])
676 * New matchers 'DoesNotStartWith' and 'StartsWith' contributed by Canonical
677 from the Launchpad project. Written by James Westby.
679 * Timestamps as produced by subunit protocol clients are now forwarded in the
680 ThreadsafeForwardingResult so correct test durations can be reported.
681 (Martin [gz], Robert Collins, #625594)
683 * With unittest from Python 2.7 skipped tests will now show only the reason
684 rather than a serialisation of all details. (Martin [gz], #625583)
686 * The testtools release process is now a little better documented and a little
687 smoother. (Jonathan Lange, #623483, #623487)
693 Nothing major in this release, just enough small bits and pieces to make it
694 useful enough to upgrade to.
696 In particular, a serious bug in assertThat() has been fixed, it's easier to
697 write Matchers, there's a TestCase.patch() method for those inevitable monkey
698 patches and TestCase.assertEqual gives slightly nicer errors.
703 * 'TestCase.assertEqual' now formats errors a little more nicely, in the
706 * Added `PlaceHolder` and `ErrorHolder`, TestCase-like objects that can be
707 used to add results to a `TestResult`.
709 * 'Mismatch' now takes optional description and details parameters, so
710 custom Matchers aren't compelled to make their own subclass.
712 * jml added a built-in UTF8_TEXT ContentType to make it slightly easier to
713 add details to test results. See bug #520044.
715 * Fix a bug in our built-in matchers where assertThat would blow up if any
716 of them failed. All built-in mismatch objects now provide get_details().
718 * New 'Is' matcher, which lets you assert that a thing is identical to
721 * New 'LessThan' matcher which lets you assert that a thing is less than
724 * TestCase now has a 'patch()' method to make it easier to monkey-patching
725 objects in tests. See the manual for more information. Fixes bug #310770.
727 * MultiTestResult methods now pass back return values from the results it
733 This release fixes some obscure traceback formatting issues that probably
734 weren't affecting you but were certainly breaking our own test suite.
739 * Jamu Kakar has updated classes in testtools.matchers and testtools.runtest
740 to be new-style classes, fixing bug #611273.
745 * Martin[gz] fixed traceback handling to handle cases where extract_tb returns
746 a source line of None. Fixes bug #611307.
748 * Martin[gz] fixed an unicode issue that was causing the tests to fail,
751 * testtools now handles string exceptions (although why would you want to use
752 them?) and formats their tracebacks correctly. Thanks to Martin[gz] for
758 This release overhauls the traceback formatting layer to deal with Python 2
759 line numbers and traceback objects often being local user encoded strings
760 rather than unicode objects. Test discovery has also been added and Python 3.1
761 is also supported. Finally, the Mismatch protocol has been extended to let
762 Matchers collaborate with tests in supplying detailed data about failures.
767 * testtools.utils has been renamed to testtools.compat. Importing
768 testtools.utils will now generate a deprecation warning.
773 * Add machinery for Python 2 to create unicode tracebacks like those used by
774 Python 3. This means testtools no longer throws on encountering non-ascii
775 filenames, source lines, or exception strings when displaying test results.
776 Largely contributed by Martin[gz] with some tweaks from Robert Collins.
778 * James Westby has supplied test discovery support using the Python 2.7
779 TestRunner in testtools.run. This requires the 'discover' module. This
782 * Python 3.1 is now supported, thanks to Martin[gz] for a partial patch.
783 This fixes bug #592375.
785 * TestCase.addCleanup has had its docstring corrected about when cleanups run.
787 * TestCase.skip is now deprecated in favour of TestCase.skipTest, which is the
788 Python2.7 spelling for skip. This closes bug #560436.
790 * Tests work on IronPython patch from Martin[gz] applied.
792 * Thanks to a patch from James Westby testtools.matchers.Mismatch can now
793 supply a get_details method, which assertThat will query to provide
794 additional attachments. This can be used to provide additional detail
795 about the mismatch that doesn't suite being included in describe(). For
796 instance, if the match process was complex, a log of the process could be
797 included, permitting debugging.
799 * testtools.testresults.real._StringException will now answer __str__ if its
800 value is unicode by encoding with UTF8, and vice versa to answer __unicode__.
801 This permits subunit decoded exceptions to contain unicode and still format
807 More matchers, Python 2.4 support, faster test cloning by switching to copy
808 rather than deepcopy and better output when exceptions occur in cleanups are
809 the defining characteristics of this release.
814 * New matcher "Annotate" that adds a simple string message to another matcher,
815 much like the option 'message' parameter to standard library assertFoo
818 * New matchers "Not" and "MatchesAll". "Not" will invert another matcher, and
819 "MatchesAll" that needs a successful match for all of its arguments.
821 * On Python 2.4, where types.FunctionType cannot be deepcopied, testtools will
822 now monkeypatch copy._deepcopy_dispatch using the same trivial patch that
823 added such support to Python 2.5. The monkey patch is triggered by the
824 absence of FunctionType from the dispatch dict rather than a version check.
827 * On windows the test 'test_now_datetime_now' should now work reliably.
829 * TestCase.getUniqueInteger and TestCase.getUniqueString now have docstrings.
831 * TestCase.getUniqueString now takes an optional prefix parameter, so you can
832 now use it in circumstances that forbid strings with '.'s, and such like.
834 * testtools.testcase.clone_test_with_new_id now uses copy.copy, rather than
835 copy.deepcopy. Tests that need a deeper copy should use the copy protocol to
836 control how they are copied. Bug #498869.
838 * The backtrace test result output tests should now pass on windows and other
839 systems where os.sep is not '/'.
841 * When a cleanUp or tearDown exception occurs, it is now accumulated as a new
842 traceback in the test details, rather than as a separate call to addError /
843 addException. This makes testtools work better with most TestResult objects
844 and fixes bug #335816.
850 Python 3 support, more matchers and better consistency with Python 2.7 --
851 you'd think that would be enough for a point release. Well, we here on the
852 testtools project think that you deserve more.
854 We've added a hook so that user code can be called just-in-time whenever there
855 is an exception, and we've also factored out the "run" logic of test cases so
856 that new outcomes can be added without fiddling with the actual flow of logic.
858 It might sound like small potatoes, but it's changes like these that will
859 bring about the end of test frameworks.
865 * A failure in setUp and tearDown now report as failures not as errors.
867 * Cleanups now run after tearDown to be consistent with Python 2.7's cleanup
870 * ExtendedToOriginalDecorator now passes unrecognised attributes through
871 to the decorated result object, permitting other extensions to the
872 TestCase -> TestResult protocol to work.
874 * It is now possible to trigger code just-in-time after an exception causes
875 a test outcome such as failure or skip. See the testtools MANUAL or
876 ``pydoc testtools.TestCase.addOnException``. (bug #469092)
878 * New matcher Equals which performs a simple equality test.
880 * New matcher MatchesAny which looks for a match of any of its arguments.
882 * TestCase no longer breaks if a TestSkipped exception is raised with no
885 * TestCase.run now clones test cases before they are run and runs the clone.
886 This reduces memory footprint in large test runs - state accumulated on
887 test objects during their setup and execution gets freed when test case
888 has finished running unless the TestResult object keeps a reference.
889 NOTE: As test cloning uses deepcopy, this can potentially interfere if
890 a test suite has shared state (such as the testscenarios or testresources
891 projects use). Use the __deepcopy__ hook to control the copying of such
892 objects so that the shared references stay shared.
894 * Testtools now accepts contributions without copyright assignment under some
895 circumstances. See HACKING for details.
897 * Testtools now provides a convenient way to run a test suite using the
898 testtools result object: python -m testtools.run testspec [testspec...].
900 * Testtools now works on Python 3, thanks to Benjamin Peterson.
902 * Test execution now uses a separate class, testtools.RunTest to run single
903 tests. This can be customised and extended in a more consistent fashion than
904 the previous run method idiom. See pydoc for more information.
906 * The test doubles that testtools itself uses are now available as part of
907 the testtools API in testtols.testresult.doubles.
909 * TracebackContent now sets utf8 as the charset encoding, rather than not
910 setting one and encoding with the default encoder.
912 * With python2.7 testtools.TestSkipped will be the unittest.case.SkipTest
913 exception class making skips compatible with code that manually raises the
914 standard library exception. (bug #490109)
919 * TestCase.getUniqueInteger is now implemented using itertools.count. Thanks
920 to Benjamin Peterson for the patch. (bug #490111)
926 The new matcher API introduced in 0.9.0 had a small flaw where the matchee
927 would be evaluated twice to get a description of the mismatch. This could lead
928 to bugs if the act of matching caused side effects to occur in the matchee.
929 Since having such side effects isn't desirable, we have changed the API now
930 before it has become widespread.
935 * Matcher API changed to avoid evaluating matchee twice. Please consult
936 the API documentation.
938 * TestCase.getUniqueString now uses the test id, not the test method name,
939 which works nicer with parameterised tests.
944 * Python2.4 is now supported again.
950 This release of testtools is perhaps the most interesting and exciting one
951 it's ever had. We've continued in bringing together the best practices of unit
952 testing from across a raft of different Python projects, but we've also
953 extended our mission to incorporating unit testing concepts from other
954 languages and from our own research, led by Robert Collins.
956 We now support skipping and expected failures. We'll make sure that you
957 up-call setUp and tearDown, avoiding unexpected testing weirdnesses. We're
958 now compatible with Python 2.5, 2.6 and 2.7 unittest library.
960 All in all, if you are serious about unit testing and want to get the best
961 thinking from the whole Python community, you should get this release.
966 * A new TestResult API has been added for attaching details to test outcomes.
967 This API is currently experimental, but is being prepared with the intent
968 of becoming an upstream Python API. For more details see pydoc
969 testtools.TestResult and the TestCase addDetail / getDetails methods.
971 * assertThat has been added to TestCase. This new assertion supports
972 a hamcrest-inspired matching protocol. See pydoc testtools.Matcher for
973 details about writing matchers, and testtools.matchers for the included
974 matchers. See http://code.google.com/p/hamcrest/.
976 * Compatible with Python 2.6 and Python 2.7
978 * Failing to upcall in setUp or tearDown will now cause a test failure.
979 While the base methods do nothing, failing to upcall is usually a problem
980 in deeper hierarchies, and checking that the root method is called is a
981 simple way to catch this common bug.
983 * New TestResult decorator ExtendedToOriginalDecorator which handles
984 downgrading extended API calls like addSkip to older result objects that
985 do not support them. This is used internally to make testtools simpler but
986 can also be used to simplify other code built on or for use with testtools.
988 * New TextTestResult supporting the extended APIs that testtools provides.
990 * Nose will no longer find 'runTest' tests in classes derived from
991 testtools.testcase.TestCase (bug #312257).
993 * Supports the Python 2.7/3.1 addUnexpectedSuccess and addExpectedFailure
994 TestResult methods, with a support function 'knownFailure' to let tests
995 trigger these outcomes.
997 * When using the skip feature with TestResult objects that do not support it
998 a test success will now be reported. Previously an error was reported but
999 production experience has shown that this is too disruptive for projects that
1000 are using skips: they cannot get a clean run on down-level result objects.
1003 .. _testtools: http://pypi.python.org/pypi/testtools