4 Changes and improvements to testtools_, grouped by release.
13 * Fixed unit tests which were failing under pypy due to a change in the way
14 pypy formats tracebacks. (Thomi Richards)
16 * Make `testtools.content.text_content` error if anything other than text
17 is given as content. (Thomi Richards)
25 * Exceptions in a ``fixture.getDetails`` method will no longer mask errors
26 raised from the same fixture's ``setUp`` method.
27 (Robert Collins, #1368440)
32 Long overdue, we've adopted a backwards compatibility statement and recognized
33 that we have plenty of users depending on our behaviour - calling our version
34 1.0.0 is a recognition of that.
39 * Fix a long-standing bug where tearDown and cleanUps would not be called if the
40 test run was interrupted. This should fix leaking external resources from
42 (Robert Collins, #1364188)
44 * Fix a long-standing bug where calling sys.exit(0) from within a test would
45 cause the test suite to exit with 0, without reporting a failure of that
46 test. We still allow the test suite to be exited (since catching higher order
47 exceptions requires exceptional circumstances) but we now call a last-resort
48 handler on the TestCase, resulting in an error being reported for the test.
49 (Robert Collins, #1364188)
51 * Fix an issue where tests skipped with the ``skip``* family of decorators would
52 still have their ``setUp`` and ``tearDown`` functions called.
53 (Thomi Richards, #https://github.com/testing-cabal/testtools/issues/86)
55 * We have adopted a formal backwards compatibility statement (see hacking.rst)
61 Brown paper bag release - 0.9.38 was broken for some users,
62 _jython_aware_splitext was not defined entirely compatibly.
63 (Robert Collins, #https://github.com/testing-cabal/testtools/issues/100)
68 Bug fixes for test importing.
73 * Discovery import error detection wasn't implemented for python 2.6 (the
74 'discover' module). (Robert Collins)
76 * Discovery now executes load_tests (if present) in __init__ in all packages.
77 (Robert Collins, http://bugs.python.org/issue16662)
82 Minor improvements to correctness.
87 * ``stdout`` is now correctly honoured on ``run.TestProgram`` - before the
88 runner objects would be created with no stdout parameter. If construction
89 fails, the previous parameter list is attempted, permitting compatibility
90 with Runner classes that don't accept stdout as a parameter.
93 * The ``ExtendedToStreamDecorator`` now handles content objects with one less
94 packet - the last packet of the source content is sent with EOF set rather
95 than an empty packet with EOF set being sent after the last packet of the
96 source content. (Robert Collins)
101 Welcome to our long overdue 0.9.36 release, which improves compatibility with
102 Python3.4, adds assert_that, a function for using matchers without TestCase
103 objects, and finally will error if you try to use setUp or tearDown twice -
104 since that invariably leads to bad things of one sort or another happening.
109 * Error if ``setUp`` or ``tearDown`` are called twice.
110 (Robert Collins, #882884)
112 * Make testtools compatible with the ``unittest.expectedFailure`` decorator in
113 Python 3.4. (Thomi Richards)
119 * Introduce the assert_that function, which allows matchers to be used
120 independent of testtools.TestCase. (Daniel Watkins, #1243834)
129 * Removed a number of code paths where Python 2.4 and Python 2.5 were
130 explicitly handled. (Daniel Watkins)
135 * Added the ``testtools.TestCase.expectThat`` method, which implements
136 delayed assertions. (Thomi Richards)
138 * Docs are now built as part of the Travis-CI build, reducing the chance of
139 Read The Docs being broken accidentally. (Daniel Watkins, #1158773)
147 * Added ability for ``testtools.TestCase`` instances to force a test to
148 fail, even if no assertions failed. (Thomi Richards)
150 * Added ``testtools.content.StacktraceContent``, a content object that
151 automatically creates a ``StackLinesContent`` object containing the current
152 stack trace. (Thomi Richards)
154 * ``AnyMatch`` is now exported properly in ``testtools.matchers``.
155 (Robert Collins, Rob Kennedy, github #44)
157 * In Python 3.3, if there are duplicate test ids, tests.sort() will
158 fail and raise TypeError. Detect the duplicate test ids firstly in
159 sorted_tests() to ensure that all test ids are unique.
162 * ``json_content`` is now in the ``__all__`` attribute for
163 ``testtools.content``. (Robert Collins)
165 * Network tests now bind to 127.0.0.1 to avoid (even temporary) network
166 visible ports. (Benedikt Morbach, github #46)
168 * Test listing now explicitly indicates by printing 'Failed to import' and
169 exiting (2) when an import has failed rather than only signalling through the
170 test name. (Robert Collins, #1245672)
172 * ``test_compat.TestDetectEncoding.test_bom`` now works on Python 3.3 - the
173 corner case with euc_jp is no longer permitted in Python 3.3 so we can
174 skip it. (Martin [gz], #1251962)
182 * Added ``addDetailuniqueName`` method to ``testtools.TestCase`` class.
185 * Removed some unused code from ``testtools.content.TracebackContent``.
188 * Added ``testtools.StackLinesContent``: a content object for displaying
189 pre-processed stack lines. (Thomi Richards)
191 * ``StreamSummary`` was calculating testsRun incorrectly: ``exists`` status
192 tests were counted as run tests, but they are not.
193 (Robert Collins, #1203728)
198 Regular maintenance release. Special thanks to new contributor, Xiao Hanyu!
203 * ``testttols.compat._format_exc_info`` has been refactored into several
204 smaller functions. (Thomi Richards)
209 * Stacktrace filtering no longer hides unittest frames that are surrounded by
210 user frames. We will reenable this when we figure out a better algorithm for
211 retaining meaning. (Robert Collins, #1188420)
213 * The compatibility code for skipped tests with unittest2 was broken.
214 (Robert Collins, #1190951)
216 * Various documentation improvements (Clint Byrum, Xiao Hanyu).
224 * ``ExpectedException`` now accepts a msg parameter for describing an error,
225 much the same as assertEquals etc. (Robert Collins)
230 A new sort of TestResult, the StreamResult has been added, as a prototype for
231 a revised standard library test result API. Expect this API to change.
232 Although we will try to preserve compatibility for early adopters, it is
233 experimental and we might need to break it if it turns out to be unsuitable.
237 * ``assertRaises`` works properly for exception classes that have custom
240 * ``ConcurrentTestSuite`` was silently eating exceptions that propagate from
241 the test.run(result) method call. Ignoring them is fine in a normal test
242 runner, but when they happen in a different thread, the thread that called
243 suite.run() is not in the stack anymore, and the exceptions are lost. We now
244 create a synthetic test recording any such exception.
245 (Robert Collins, #1130429)
247 * Fixed SyntaxError raised in ``_compat2x.py`` when installing via Python 3.
250 * New class ``StreamResult`` which defines the API for the new result type.
253 * New support class ``ConcurrentStreamTestSuite`` for convenient construction
254 and utilisation of ``StreamToQueue`` objects. (Robert Collins)
256 * New support class ``CopyStreamResult`` which forwards events onto multiple
257 ``StreamResult`` objects (each of which receives all the events).
260 * New support class ``StreamSummary`` which summarises a ``StreamResult``
261 stream compatibly with ``TestResult`` code. (Robert Collins)
263 * New support class ``StreamTagger`` which adds or removes tags from
264 ``StreamResult`` events. (RobertCollins)
266 * New support class ``StreamToDict`` which converts a ``StreamResult`` to a
267 series of dicts describing a test. Useful for writing trivial stream
268 analysers. (Robert Collins)
270 * New support class ``TestControl`` which permits cancelling an in-progress
271 run. (Robert Collins)
273 * New support class ``StreamFailFast`` which calls a ``TestControl`` instance
274 to abort the test run when a failure is detected. (Robert Collins)
276 * New support class ``ExtendedToStreamDecorator`` which translates both regular
277 unittest TestResult API calls and the ExtendedTestResult API which testtools
278 has supported into the StreamResult API. ExtendedToStreamDecorator also
279 forwards calls made in the StreamResult API, permitting it to be used
280 anywhere a StreamResult is used. Key TestResult query methods like
281 wasSuccessful and shouldStop are synchronised with the StreamResult API
282 calls, but the detailed statistics like the list of errors are not - a
283 separate consumer will be created to support that.
286 * New support class ``StreamToExtendedDecorator`` which translates
287 ``StreamResult`` API calls into ``ExtendedTestResult`` (or any older
288 ``TestResult``) calls. This permits using un-migrated result objects with
289 new runners / tests. (Robert Collins)
291 * New support class ``StreamToQueue`` for sending messages to one
292 ``StreamResult`` from multiple threads. (Robert Collins)
294 * New support class ``TimestampingStreamResult`` which adds a timestamp to
295 events with no timestamp. (Robert Collins)
297 * New ``TestCase`` decorator ``DecorateTestCaseResult`` that adapts the
298 ``TestResult`` or ``StreamResult`` a case will be run with, for ensuring that
299 a particular result object is used even if the runner running the test doesn't
300 know to use it. (Robert Collins)
302 * New test support class ``testtools.testresult.doubles.StreamResult``, which
303 captures all the StreamResult events. (Robert Collins)
305 * ``PlaceHolder`` can now hold tags, and applies them before, and removes them
306 after, the test. (Robert Collins)
308 * ``PlaceHolder`` can now hold timestamps, and applies them before the test and
309 then before the outcome. (Robert Collins)
311 * ``StreamResultRouter`` added. This is useful for demultiplexing - e.g. for
312 partitioning analysis of events or sending feedback encapsulated in
313 StreamResult events back to their source. (Robert Collins)
315 * ``testtools.run.TestProgram`` now supports the ``TestRunner`` taking over
316 responsibility for formatting the output of ``--list-tests``.
319 * The error message for setUp and tearDown upcall errors was broken on Python
320 3.4. (Monty Taylor, Robert Collins, #1140688)
322 * The repr of object() on pypy includes the object id, which was breaking a
323 test that accidentally depended on the CPython repr for object().
329 A simple bug fix, and better error messages when you don't up-call.
334 * ``testtools.content_type.ContentType`` incorrectly used ',' rather than ';'
335 to separate parameters. (Robert Collins)
340 * ``testtools.compat.unicode_output_stream`` was wrapping a stream encoder
341 around ``io.StringIO`` and ``io.TextIOWrapper`` objects, which was incorrect.
344 * Report the name of the source file for setUp and tearDown upcall errors.
350 Testtools has moved VCS - https://github.com/testing-cabal/testtools/ is
351 the new home. Bug tracking is still on Launchpad, and releases are on Pypi.
353 We made this change to take advantage of the richer ecosystem of tools around
354 Git, and to lower the barrier for new contributors.
359 * New ``testtools.testcase.attr`` and ``testtools.testcase.WithAttributes``
360 helpers allow marking up test case methods with simple labels. This permits
361 filtering tests with more granularity than organising them into modules and
362 test classes. (Robert Collins)
370 * New matcher ``HasLength`` for matching the length of a collection.
373 * New matcher ``MatchesPredicateWithParams`` make it still easier to create
374 ad hoc matchers. (Robert Collins)
376 * We have a simpler release process in future - see doc/hacking.rst.
382 Brown paper bag fix: failed to document the need for setup to be able to use
383 extras. Compounded by pip not supporting setup_requires.
388 * setup.py now can generate egg_info even if extras is not available.
389 Also lists extras in setup_requires for easy_install.
390 (Robert Collins, #1102464)
398 * ``python -m testtools.run --load-list`` will now preserve any custom suites
399 (such as ``testtools.FixtureSuite`` or ``testresources.OptimisingTestSuite``)
400 rather than flattening them.
401 (Robert Collins, #827175)
403 * Testtools now depends on extras, a small library split out from it to contain
404 generally useful non-testing facilities. Since extras has been around for a
405 couple of testtools releases now, we're making this into a hard dependency of
406 testtools. (Robert Collins)
408 * Testtools now uses setuptools rather than distutils so that we can document
409 the extras dependency. (Robert Collins)
414 * Testtools will no longer override test code registered details called
415 'traceback' when reporting caught exceptions from test code.
416 (Robert Collins, #812793)
424 * ``testtools.run discover`` will now sort the tests it discovered. This is a
425 workaround for http://bugs.python.org/issue16709. Non-standard test suites
426 are preserved, and their ``sort_tests()`` method called (if they have such an
427 attribute). ``testtools.testsuite.sorted_tests(suite, True)`` can be used by
428 such suites to do a local sort. (Robert Collins, #1091512)
430 * ``ThreadsafeForwardingResult`` now defines a stub ``progress`` method, which
431 fixes ``testr run`` of streams containing progress markers (by discarding the
432 progress data). (Robert Collins, #1019165)
440 * ``run.TestToolsTestRunner`` now accepts the verbosity, buffer and failfast
441 arguments the upstream python TestProgram code wants to give it, making it
442 possible to support them in a compatible fashion. (Robert Collins)
447 * ``testtools.run`` now supports the ``-f`` or ``--failfast`` parameter.
448 Previously it was advertised in the help but ignored.
449 (Robert Collins, #1090582)
451 * ``AnyMatch`` added, a new matcher that matches when any item in a collection
452 matches the given matcher. (Jonathan Lange)
454 * Spelling corrections to documentation. (Vincent Ladeuil)
456 * ``TestProgram`` now has a sane default for its ``testRunner`` argument.
459 * The test suite passes on Python 3 again. (Robert Collins)
467 * ``content_from_file`` and ``content_from_stream`` now accept seek_offset and
468 seek_whence parameters allowing them to be used to grab less than the full
469 stream, or to be used with StringIO streams. (Robert Collins, #1088693)
477 * ``DirContains`` correctly exposed, after being accidentally hidden in the
478 great matcher re-organization of 0.9.17. (Jonathan Lange)
484 Three new matchers that'll rock your world.
489 * New, powerful matchers that match items in a dictionary:
491 - ``MatchesDict``, match every key in a dictionary with a key in a
492 dictionary of matchers. For when the set of expected keys is equal to the
493 set of observed keys.
495 - ``ContainsDict``, every key in a dictionary of matchers must be
496 found in a dictionary, and the values for those keys must match. For when
497 the set of expected keys is a subset of the set of observed keys.
499 - ``ContainedByDict``, every key in a dictionary must be found in
500 a dictionary of matchers. For when the set of expected keys is a superset
501 of the set of observed keys.
503 The names are a little confusing, sorry. We're still trying to figure out
504 how to present the concept in the simplest way possible.
510 How embarrassing! Three releases in two days.
512 We've worked out the kinks and have confirmation from our downstreams that
513 this is all good. Should be the last release for a little while. Please
514 ignore 0.9.18 and 0.9.17.
519 * Include the matcher tests in the release, allowing the tests to run and
520 pass from the release tarball. (Jonathan Lange)
522 * Fix cosmetic test failures in Python 3.3, introduced during release 0.9.17.
529 Due to an oversight, release 0.9.18 did not contain the new
530 ``testtools.matchers`` package and was thus completely broken. This release
531 corrects that, returning us all to normality.
536 This release brings better discover support and Python3.x improvements. There
537 are still some test failures on Python3.3 but they are cosmetic - the library
538 is as usable there as on any other Python 3 release.
543 * The ``testtools.matchers`` package has been split up. No change to the
544 public interface. (Jonathan Lange)
549 * ``python -m testtools.run discover . --list`` now works. (Robert Collins)
551 * Correctly handling of bytes vs text in JSON content type. (Martin [gz])
557 Some new matchers and a new content helper for JSON content.
559 This is the first release of testtools to drop support for Python 2.4 and 2.5.
560 If you need support for either of those versions, please use testtools 0.9.15.
565 * New content helper, ``json_content`` (Jonathan Lange)
569 * ``ContainsAll`` for asserting one thing is a subset of another
572 * ``SameMembers`` for asserting two iterators have the same members.
575 * Reraising of exceptions in Python 3 is more reliable. (Martin [gz])
581 This is the last release to support Python2.4 and 2.5. It brings in a slew of
582 improvements to test tagging and concurrency, making running large test suites
583 with partitioned workers more reliable and easier to reproduce exact test
584 ordering in a given worker. See our sister project ``testrepository`` for a
585 test runner that uses these features.
590 * ``PlaceHolder`` and ``ErrorHolder`` now support being given result details.
593 * ``ErrorHolder`` is now just a function - all the logic is in ``PlaceHolder``.
596 * ``TestResult`` and all other ``TestResult``-like objects in testtools
597 distinguish between global tags and test-local tags, as per the subunit
598 specification. (Jonathan Lange)
600 * This is the **last** release of testtools that supports Python 2.4 or 2.5.
601 These releases are no longer supported by the Python community and do not
602 receive security updates. If this affects you, you will need to either
603 stay on this release or perform your own backports.
604 (Jonathan Lange, Robert Collins)
606 * ``ThreadsafeForwardingResult`` now forwards global tags as test-local tags,
607 making reasoning about the correctness of the multiplexed stream simpler.
608 This preserves the semantic value (what tags apply to a given test) while
609 consuming less stream size (as no negative-tag statement is needed).
610 (Robert Collins, Gary Poster, #986434)
615 * API documentation corrections. (Raphaël Badin)
617 * ``ConcurrentTestSuite`` now takes an optional ``wrap_result`` parameter
618 that can be used to wrap the ``ThreadsafeForwardingResults`` created by
619 the suite. (Jonathan Lange)
621 * ``Tagger`` added. It's a new ``TestResult`` that tags all tests sent to
622 it with a particular set of tags. (Jonathan Lange)
624 * ``testresultdecorator`` brought over from subunit. (Jonathan Lange)
626 * All ``TestResult`` wrappers now correctly forward ``current_tags`` from
627 their wrapped results, meaning that ``current_tags`` can always be relied
628 upon to return the currently active tags on a test result.
630 * ``TestByTestResult``, a ``TestResult`` that calls a method once per test,
631 added. (Jonathan Lange)
633 * ``ThreadsafeForwardingResult`` correctly forwards ``tags()`` calls where
634 only one of ``new_tags`` or ``gone_tags`` are specified.
635 (Jonathan Lange, #980263)
637 * ``ThreadsafeForwardingResult`` no longer leaks local tags from one test
638 into all future tests run. (Jonathan Lange, #985613)
640 * ``ThreadsafeForwardingResult`` has many, many more tests. (Jonathan Lange)
646 Our sister project, `subunit <https://launchpad.net/subunit>`_, was using a
647 private API that was deleted in the 0.9.13 release. This release restores
648 that API in order to smooth out the upgrade path.
650 If you don't use subunit, then this release won't matter very much to you.
656 Plenty of new matchers and quite a few critical bug fixes (especially to do
657 with stack traces from failed assertions). A net win for all.
662 * ``MatchesAll`` now takes an ``first_only`` keyword argument that changes how
663 mismatches are displayed. If you were previously passing matchers to
664 ``MatchesAll`` with keyword arguments, then this change might affect your
665 test results. (Jonathan Lange)
670 * Actually hide all of the testtools stack for assertion failures. The
671 previous release promised clean stack, but now we actually provide it.
672 (Jonathan Lange, #854769)
674 * ``assertRaises`` now includes the ``repr`` of the callable that failed to raise
675 properly. (Jonathan Lange, #881052)
677 * Asynchronous tests no longer hang when run with trial.
678 (Jonathan Lange, #926189)
680 * ``Content`` objects now have an ``as_text`` method to convert their contents
681 to Unicode text. (Jonathan Lange)
683 * Failed equality assertions now line up. (Jonathan Lange, #879339)
685 * ``FullStackRunTest`` no longer aborts the test run if a test raises an
686 error. (Jonathan Lange)
688 * ``MatchesAll`` and ``MatchesListwise`` both take a ``first_only`` keyword
689 argument. If True, they will report only on the first mismatch they find,
690 and not continue looking for other possible mismatches.
693 * New helper, ``Nullary`` that turns callables with arguments into ones that
694 don't take arguments. (Jonathan Lange)
698 * ``DirContains`` matches the contents of a directory.
699 (Jonathan Lange, James Westby)
701 * ``DirExists`` matches if a directory exists.
702 (Jonathan Lange, James Westby)
704 * ``FileContains`` matches the contents of a file.
705 (Jonathan Lange, James Westby)
707 * ``FileExists`` matches if a file exists.
708 (Jonathan Lange, James Westby)
710 * ``HasPermissions`` matches the permissions of a file. (Jonathan Lange)
712 * ``MatchesPredicate`` matches if a predicate is true. (Jonathan Lange)
714 * ``PathExists`` matches if a path exists. (Jonathan Lange, James Westby)
716 * ``SamePath`` matches if two paths are the same. (Jonathan Lange)
718 * ``TarballContains`` matches the contents of a tarball. (Jonathan Lange)
720 * ``MultiTestResult`` supports the ``tags`` method.
721 (Graham Binns, Francesco Banconi, #914279)
723 * ``ThreadsafeForwardingResult`` supports the ``tags`` method.
724 (Graham Binns, Francesco Banconi, #914279)
726 * ``ThreadsafeForwardingResult`` no longer includes semaphore acquisition time
727 in the test duration (for implicitly timed test runs).
728 (Robert Collins, #914362)
733 This is a very big release. We've made huge improvements on three fronts:
734 1. Test failures are way nicer and easier to read
735 2. Matchers and ``assertThat`` are much more convenient to use
736 3. Correct handling of extended unicode characters
738 We've trimmed off the fat from the stack trace you get when tests fail, we've
739 cut out the bits of error messages that just didn't help, we've made it easier
740 to annotate mismatch failures, to compare complex objects and to match raised
743 Testing code was never this fun.
748 * ``AfterPreproccessing`` renamed to ``AfterPreprocessing``, which is a more
749 correct spelling. Old name preserved for backwards compatibility, but is
750 now deprecated. Please stop using it.
751 (Jonathan Lange, #813460)
753 * ``assertThat`` raises ``MismatchError`` instead of
754 ``TestCase.failureException``. ``MismatchError`` is a subclass of
755 ``AssertionError``, so in most cases this change will not matter. However,
756 if ``self.failureException`` has been set to a non-default value, then
757 mismatches will become test errors rather than test failures.
759 * ``gather_details`` takes two dicts, rather than two detailed objects.
760 (Jonathan Lange, #801027)
762 * ``MatchesRegex`` mismatch now says "<value> does not match /<regex>/" rather
763 than "<regex> did not match <value>". The regular expression contains fewer
764 backslashes too. (Jonathan Lange, #818079)
766 * Tests that run with ``AsynchronousDeferredRunTest`` now have the ``reactor``
767 attribute set to the running reactor. (Jonathan Lange, #720749)
772 * All public matchers are now in ``testtools.matchers.__all__``.
773 (Jonathan Lange, #784859)
775 * ``assertThat`` can actually display mismatches and matchers that contain
776 extended unicode characters. (Jonathan Lange, Martin [gz], #804127)
778 * ``assertThat`` output is much less verbose, displaying only what the mismatch
779 tells us to display. Old-style verbose output can be had by passing
780 ``verbose=True`` to assertThat. (Jonathan Lange, #675323, #593190)
782 * ``assertThat`` accepts a message which will be used to annotate the matcher.
783 This can be given as a third parameter or as a keyword parameter.
786 * Automated the Launchpad part of the release process.
787 (Jonathan Lange, #623486)
789 * Correctly display non-ASCII unicode output on terminals that claim to have a
790 unicode encoding. (Martin [gz], #804122)
792 * ``DocTestMatches`` correctly handles unicode output from examples, rather
793 than raising an error. (Martin [gz], #764170)
795 * ``ErrorHolder`` and ``PlaceHolder`` added to docs. (Jonathan Lange, #816597)
797 * ``ExpectedException`` now matches any exception of the given type by
798 default, and also allows specifying a ``Matcher`` rather than a mere regular
799 expression. (Jonathan Lange, #791889)
801 * ``FixtureSuite`` added, allows test suites to run with a given fixture.
804 * Hide testtools's own stack frames when displaying tracebacks, making it
805 easier for test authors to focus on their errors.
806 (Jonathan Lange, Martin [gz], #788974)
808 * Less boilerplate displayed in test failures and errors.
809 (Jonathan Lange, #660852)
811 * ``MatchesException`` now allows you to match exceptions against any matcher,
812 rather than just regular expressions. (Jonathan Lange, #791889)
814 * ``MatchesException`` now permits a tuple of types rather than a single type
815 (when using the type matching mode). (Robert Collins)
817 * ``MatchesStructure.byEquality`` added to make the common case of matching
818 many attributes by equality much easier. ``MatchesStructure.byMatcher``
819 added in case folk want to match by things other than equality.
822 * New convenience assertions, ``assertIsNone`` and ``assertIsNotNone``.
827 * ``AllMatch`` matches many values against a single matcher.
828 (Jonathan Lange, #615108)
830 * ``Contains``. (Robert Collins)
832 * ``GreaterThan``. (Christian Kampka)
834 * New helper, ``safe_hasattr`` added. (Jonathan Lange)
836 * ``reraise`` added to ``testtools.compat``. (Jonathan Lange)
842 This release brings consistent use of super for better compatibility with
843 multiple inheritance, fixed Python3 support, improvements in fixture and mather
844 outputs and a compat helper for testing libraries that deal with bytestrings.
849 * ``TestCase`` now uses super to call base ``unittest.TestCase`` constructor,
850 ``setUp`` and ``tearDown``. (Tim Cole, #771508)
852 * If, when calling ``useFixture`` an error occurs during fixture set up, we
853 still attempt to gather details from the fixture. (Gavin Panella)
859 * Additional compat helper for ``BytesIO`` for libraries that build on
860 testtools and are working on Python 3 porting. (Robert Collins)
862 * Corrected documentation for ``MatchesStructure`` in the test authors
863 document. (Jonathan Lange)
865 * ``LessThan`` error message now says something that is logically correct.
866 (Gavin Panella, #762008)
868 * Multiple details from a single fixture are now kept separate, rather than
869 being mooshed together. (Gavin Panella, #788182)
871 * Python 3 support now back in action. (Martin [gz], #688729)
873 * ``try_import`` and ``try_imports`` have a callback that is called whenever
874 they fail to import a module. (Martin Pool)
880 The last release of testtools could not be easy_installed. This is considered
881 severe enough for a re-release.
886 * Include ``doc/`` in the source distribution, making testtools installable
887 from PyPI again (Tres Seaver, #757439)
893 Many, many new matchers, vastly expanded documentation, stacks of bug fixes,
894 better unittest2 integration. If you've ever wanted to try out testtools but
895 been afraid to do so, this is the release to try.
901 * The timestamps generated by ``TestResult`` objects when no timing data has
902 been received are now datetime-with-timezone, which allows them to be
903 sensibly serialised and transported. (Robert Collins, #692297)
908 * ``AnnotatedMismatch`` now correctly returns details.
909 (Jonathan Lange, #724691)
911 * distutils integration for the testtools test runner. Can now use it for
912 'python setup.py test'. (Christian Kampka, #693773)
914 * ``EndsWith`` and ``KeysEqual`` now in testtools.matchers.__all__.
915 (Jonathan Lange, #692158)
917 * ``MatchesException`` extended to support a regular expression check against
918 the str() of a raised exception. (Jonathan Lange)
920 * ``MultiTestResult`` now forwards the ``time`` API. (Robert Collins, #692294)
922 * ``MultiTestResult`` now documented in the manual. (Jonathan Lange, #661116)
924 * New content helpers ``content_from_file``, ``content_from_stream`` and
925 ``attach_file`` make it easier to attach file-like objects to a
926 test. (Jonathan Lange, Robert Collins, #694126)
928 * New ``ExpectedException`` context manager to help write tests against things
929 that are expected to raise exceptions. (Aaron Bentley)
933 * ``MatchesListwise`` matches an iterable of matchers against an iterable
934 of values. (Michael Hudson-Doyle)
936 * ``MatchesRegex`` matches a string against a regular expression.
937 (Michael Hudson-Doyle)
939 * ``MatchesStructure`` matches attributes of an object against given
940 matchers. (Michael Hudson-Doyle)
942 * ``AfterPreproccessing`` matches values against a matcher after passing them
943 through a callable. (Michael Hudson-Doyle)
945 * ``MatchesSetwise`` matches an iterable of matchers against an iterable of
946 values, without regard to order. (Michael Hudson-Doyle)
948 * ``setup.py`` can now build a snapshot when Bazaar is installed but the tree
949 is not a Bazaar tree. (Jelmer Vernooij)
951 * Support for running tests using distutils (Christian Kampka, #726539)
953 * Vastly improved and extended documentation. (Jonathan Lange)
955 * Use unittest2 exception classes if available. (Jelmer Vernooij)
961 In this release we bring some very interesting improvements:
963 * new matchers for exceptions, sets, lists, dicts and more.
965 * experimental (works but the contract isn't supported) twisted reactor
968 * The built in runner can now list tests and filter tests (the -l and
969 --load-list options).
974 * addUnexpectedSuccess is translated to addFailure for test results that don't
975 know about addUnexpectedSuccess. Further, it fails the entire result for
976 all testtools TestResults (i.e. wasSuccessful() returns False after
977 addUnexpectedSuccess has been called). Note that when using a delegating
978 result such as ThreadsafeForwardingResult, MultiTestResult or
979 ExtendedToOriginalDecorator then the behaviour of addUnexpectedSuccess is
980 determined by the delegated to result(s).
981 (Jonathan Lange, Robert Collins, #654474, #683332)
983 * startTestRun will reset any errors on the result. That is, wasSuccessful()
984 will always return True immediately after startTestRun() is called. This
985 only applies to delegated test results (ThreadsafeForwardingResult,
986 MultiTestResult and ExtendedToOriginalDecorator) if the delegated to result
987 is a testtools test result - we cannot reliably reset the state of unknown
988 test result class instances. (Jonathan Lange, Robert Collins, #683332)
990 * Responsibility for running test cleanups has been moved to ``RunTest``.
991 This change does not affect public APIs and can be safely ignored by test
992 authors. (Jonathan Lange, #662647)
999 * ``EndsWith`` which complements the existing ``StartsWith`` matcher.
1000 (Jonathan Lange, #669165)
1002 * ``MatchesException`` matches an exception class and parameters. (Robert
1005 * ``KeysEqual`` matches a dictionary with particular keys. (Jonathan Lange)
1007 * ``assertIsInstance`` supports a custom error message to be supplied, which
1008 is necessary when using ``assertDictEqual`` on Python 2.7 with a
1009 ``testtools.TestCase`` base class. (Jelmer Vernooij)
1011 * Experimental support for running tests that return Deferreds.
1012 (Jonathan Lange, Martin [gz])
1014 * Provide a per-test decorator, run_test_with, to specify which RunTest
1015 object to use for a given test. (Jonathan Lange, #657780)
1017 * Fix the runTest parameter of TestCase to actually work, rather than raising
1018 a TypeError. (Jonathan Lange, #657760)
1020 * Non-release snapshots of testtools will now work with buildout.
1021 (Jonathan Lange, #613734)
1023 * Malformed SyntaxErrors no longer blow up the test suite. (Martin [gz])
1025 * ``MismatchesAll.describe`` no longer appends a trailing newline.
1026 (Michael Hudson-Doyle, #686790)
1028 * New helpers for conditionally importing modules, ``try_import`` and
1029 ``try_imports``. (Jonathan Lange)
1031 * ``Raises`` added to the ``testtools.matchers`` module - matches if the
1032 supplied callable raises, and delegates to an optional matcher for validation
1033 of the exception. (Robert Collins)
1035 * ``raises`` added to the ``testtools.matchers`` module - matches if the
1036 supplied callable raises and delegates to ``MatchesException`` to validate
1037 the exception. (Jonathan Lange)
1039 * Tests will now pass on Python 2.6.4 : an ``Exception`` change made only in
1040 2.6.4 and reverted in Python 2.6.5 was causing test failures on that version.
1041 (Martin [gz], #689858).
1043 * ``testtools.TestCase.useFixture`` has been added to glue with fixtures nicely.
1046 * ``testtools.run`` now supports ``-l`` to list tests rather than executing
1047 them. This is useful for integration with external test analysis/processing
1048 tools like subunit and testrepository. (Robert Collins)
1050 * ``testtools.run`` now supports ``--load-list``, which takes a file containing
1051 test ids, one per line, and intersects those ids with the tests found. This
1052 allows fine grained control of what tests are run even when the tests cannot
1053 be named as objects to import (e.g. due to test parameterisation via
1054 testscenarios). (Robert Collins)
1056 * Update documentation to say how to use testtools.run() on Python 2.4.
1057 (Jonathan Lange, #501174)
1059 * ``text_content`` conveniently converts a Python string to a Content object.
1060 (Jonathan Lange, James Westby)
1067 Lots of little cleanups in this release; many small improvements to make your
1068 testing life more pleasant.
1073 * Cleanups can raise ``testtools.MultipleExceptions`` if they have multiple
1074 exceptions to report. For instance, a cleanup which is itself responsible for
1075 running several different internal cleanup routines might use this.
1077 * Code duplication between assertEqual and the matcher Equals has been removed.
1079 * In normal circumstances, a TestCase will no longer share details with clones
1080 of itself. (Andrew Bennetts, bug #637725)
1082 * Less exception object cycles are generated (reduces peak memory use between
1083 garbage collection). (Martin [gz])
1085 * New matchers 'DoesNotStartWith' and 'StartsWith' contributed by Canonical
1086 from the Launchpad project. Written by James Westby.
1088 * Timestamps as produced by subunit protocol clients are now forwarded in the
1089 ThreadsafeForwardingResult so correct test durations can be reported.
1090 (Martin [gz], Robert Collins, #625594)
1092 * With unittest from Python 2.7 skipped tests will now show only the reason
1093 rather than a serialisation of all details. (Martin [gz], #625583)
1095 * The testtools release process is now a little better documented and a little
1096 smoother. (Jonathan Lange, #623483, #623487)
1102 Nothing major in this release, just enough small bits and pieces to make it
1103 useful enough to upgrade to.
1105 In particular, a serious bug in assertThat() has been fixed, it's easier to
1106 write Matchers, there's a TestCase.patch() method for those inevitable monkey
1107 patches and TestCase.assertEqual gives slightly nicer errors.
1112 * 'TestCase.assertEqual' now formats errors a little more nicely, in the
1115 * Added `PlaceHolder` and `ErrorHolder`, TestCase-like objects that can be
1116 used to add results to a `TestResult`.
1118 * 'Mismatch' now takes optional description and details parameters, so
1119 custom Matchers aren't compelled to make their own subclass.
1121 * jml added a built-in UTF8_TEXT ContentType to make it slightly easier to
1122 add details to test results. See bug #520044.
1124 * Fix a bug in our built-in matchers where assertThat would blow up if any
1125 of them failed. All built-in mismatch objects now provide get_details().
1127 * New 'Is' matcher, which lets you assert that a thing is identical to
1130 * New 'LessThan' matcher which lets you assert that a thing is less than
1133 * TestCase now has a 'patch()' method to make it easier to monkey-patching
1134 objects in tests. See the manual for more information. Fixes bug #310770.
1136 * MultiTestResult methods now pass back return values from the results it
1142 This release fixes some obscure traceback formatting issues that probably
1143 weren't affecting you but were certainly breaking our own test suite.
1148 * Jamu Kakar has updated classes in testtools.matchers and testtools.runtest
1149 to be new-style classes, fixing bug #611273.
1154 * Martin[gz] fixed traceback handling to handle cases where extract_tb returns
1155 a source line of None. Fixes bug #611307.
1157 * Martin[gz] fixed an unicode issue that was causing the tests to fail,
1158 closing bug #604187.
1160 * testtools now handles string exceptions (although why would you want to use
1161 them?) and formats their tracebacks correctly. Thanks to Martin[gz] for
1167 This release overhauls the traceback formatting layer to deal with Python 2
1168 line numbers and traceback objects often being local user encoded strings
1169 rather than unicode objects. Test discovery has also been added and Python 3.1
1170 is also supported. Finally, the Mismatch protocol has been extended to let
1171 Matchers collaborate with tests in supplying detailed data about failures.
1176 * testtools.utils has been renamed to testtools.compat. Importing
1177 testtools.utils will now generate a deprecation warning.
1182 * Add machinery for Python 2 to create unicode tracebacks like those used by
1183 Python 3. This means testtools no longer throws on encountering non-ascii
1184 filenames, source lines, or exception strings when displaying test results.
1185 Largely contributed by Martin[gz] with some tweaks from Robert Collins.
1187 * James Westby has supplied test discovery support using the Python 2.7
1188 TestRunner in testtools.run. This requires the 'discover' module. This
1191 * Python 3.1 is now supported, thanks to Martin[gz] for a partial patch.
1192 This fixes bug #592375.
1194 * TestCase.addCleanup has had its docstring corrected about when cleanups run.
1196 * TestCase.skip is now deprecated in favour of TestCase.skipTest, which is the
1197 Python2.7 spelling for skip. This closes bug #560436.
1199 * Tests work on IronPython patch from Martin[gz] applied.
1201 * Thanks to a patch from James Westby testtools.matchers.Mismatch can now
1202 supply a get_details method, which assertThat will query to provide
1203 additional attachments. This can be used to provide additional detail
1204 about the mismatch that doesn't suite being included in describe(). For
1205 instance, if the match process was complex, a log of the process could be
1206 included, permitting debugging.
1208 * testtools.testresults.real._StringException will now answer __str__ if its
1209 value is unicode by encoding with UTF8, and vice versa to answer __unicode__.
1210 This permits subunit decoded exceptions to contain unicode and still format
1216 More matchers, Python 2.4 support, faster test cloning by switching to copy
1217 rather than deepcopy and better output when exceptions occur in cleanups are
1218 the defining characteristics of this release.
1223 * New matcher "Annotate" that adds a simple string message to another matcher,
1224 much like the option 'message' parameter to standard library assertFoo
1227 * New matchers "Not" and "MatchesAll". "Not" will invert another matcher, and
1228 "MatchesAll" that needs a successful match for all of its arguments.
1230 * On Python 2.4, where types.FunctionType cannot be deepcopied, testtools will
1231 now monkeypatch copy._deepcopy_dispatch using the same trivial patch that
1232 added such support to Python 2.5. The monkey patch is triggered by the
1233 absence of FunctionType from the dispatch dict rather than a version check.
1236 * On windows the test 'test_now_datetime_now' should now work reliably.
1238 * TestCase.getUniqueInteger and TestCase.getUniqueString now have docstrings.
1240 * TestCase.getUniqueString now takes an optional prefix parameter, so you can
1241 now use it in circumstances that forbid strings with '.'s, and such like.
1243 * testtools.testcase.clone_test_with_new_id now uses copy.copy, rather than
1244 copy.deepcopy. Tests that need a deeper copy should use the copy protocol to
1245 control how they are copied. Bug #498869.
1247 * The backtrace test result output tests should now pass on windows and other
1248 systems where os.sep is not '/'.
1250 * When a cleanUp or tearDown exception occurs, it is now accumulated as a new
1251 traceback in the test details, rather than as a separate call to addError /
1252 addException. This makes testtools work better with most TestResult objects
1253 and fixes bug #335816.
1259 Python 3 support, more matchers and better consistency with Python 2.7 --
1260 you'd think that would be enough for a point release. Well, we here on the
1261 testtools project think that you deserve more.
1263 We've added a hook so that user code can be called just-in-time whenever there
1264 is an exception, and we've also factored out the "run" logic of test cases so
1265 that new outcomes can be added without fiddling with the actual flow of logic.
1267 It might sound like small potatoes, but it's changes like these that will
1268 bring about the end of test frameworks.
1274 * A failure in setUp and tearDown now report as failures not as errors.
1276 * Cleanups now run after tearDown to be consistent with Python 2.7's cleanup
1279 * ExtendedToOriginalDecorator now passes unrecognised attributes through
1280 to the decorated result object, permitting other extensions to the
1281 TestCase -> TestResult protocol to work.
1283 * It is now possible to trigger code just-in-time after an exception causes
1284 a test outcome such as failure or skip. See the testtools MANUAL or
1285 ``pydoc testtools.TestCase.addOnException``. (bug #469092)
1287 * New matcher Equals which performs a simple equality test.
1289 * New matcher MatchesAny which looks for a match of any of its arguments.
1291 * TestCase no longer breaks if a TestSkipped exception is raised with no
1294 * TestCase.run now clones test cases before they are run and runs the clone.
1295 This reduces memory footprint in large test runs - state accumulated on
1296 test objects during their setup and execution gets freed when test case
1297 has finished running unless the TestResult object keeps a reference.
1298 NOTE: As test cloning uses deepcopy, this can potentially interfere if
1299 a test suite has shared state (such as the testscenarios or testresources
1300 projects use). Use the __deepcopy__ hook to control the copying of such
1301 objects so that the shared references stay shared.
1303 * Testtools now accepts contributions without copyright assignment under some
1304 circumstances. See HACKING for details.
1306 * Testtools now provides a convenient way to run a test suite using the
1307 testtools result object: python -m testtools.run testspec [testspec...].
1309 * Testtools now works on Python 3, thanks to Benjamin Peterson.
1311 * Test execution now uses a separate class, testtools.RunTest to run single
1312 tests. This can be customised and extended in a more consistent fashion than
1313 the previous run method idiom. See pydoc for more information.
1315 * The test doubles that testtools itself uses are now available as part of
1316 the testtools API in testtols.testresult.doubles.
1318 * TracebackContent now sets utf8 as the charset encoding, rather than not
1319 setting one and encoding with the default encoder.
1321 * With python2.7 testtools.TestSkipped will be the unittest.case.SkipTest
1322 exception class making skips compatible with code that manually raises the
1323 standard library exception. (bug #490109)
1328 * TestCase.getUniqueInteger is now implemented using itertools.count. Thanks
1329 to Benjamin Peterson for the patch. (bug #490111)
1335 The new matcher API introduced in 0.9.0 had a small flaw where the matchee
1336 would be evaluated twice to get a description of the mismatch. This could lead
1337 to bugs if the act of matching caused side effects to occur in the matchee.
1338 Since having such side effects isn't desirable, we have changed the API now
1339 before it has become widespread.
1344 * Matcher API changed to avoid evaluating matchee twice. Please consult
1345 the API documentation.
1347 * TestCase.getUniqueString now uses the test id, not the test method name,
1348 which works nicer with parameterised tests.
1353 * Python2.4 is now supported again.
1359 This release of testtools is perhaps the most interesting and exciting one
1360 it's ever had. We've continued in bringing together the best practices of unit
1361 testing from across a raft of different Python projects, but we've also
1362 extended our mission to incorporating unit testing concepts from other
1363 languages and from our own research, led by Robert Collins.
1365 We now support skipping and expected failures. We'll make sure that you
1366 up-call setUp and tearDown, avoiding unexpected testing weirdnesses. We're
1367 now compatible with Python 2.5, 2.6 and 2.7 unittest library.
1369 All in all, if you are serious about unit testing and want to get the best
1370 thinking from the whole Python community, you should get this release.
1375 * A new TestResult API has been added for attaching details to test outcomes.
1376 This API is currently experimental, but is being prepared with the intent
1377 of becoming an upstream Python API. For more details see pydoc
1378 testtools.TestResult and the TestCase addDetail / getDetails methods.
1380 * assertThat has been added to TestCase. This new assertion supports
1381 a hamcrest-inspired matching protocol. See pydoc testtools.Matcher for
1382 details about writing matchers, and testtools.matchers for the included
1383 matchers. See http://code.google.com/p/hamcrest/.
1385 * Compatible with Python 2.6 and Python 2.7
1387 * Failing to upcall in setUp or tearDown will now cause a test failure.
1388 While the base methods do nothing, failing to upcall is usually a problem
1389 in deeper hierarchies, and checking that the root method is called is a
1390 simple way to catch this common bug.
1392 * New TestResult decorator ExtendedToOriginalDecorator which handles
1393 downgrading extended API calls like addSkip to older result objects that
1394 do not support them. This is used internally to make testtools simpler but
1395 can also be used to simplify other code built on or for use with testtools.
1397 * New TextTestResult supporting the extended APIs that testtools provides.
1399 * Nose will no longer find 'runTest' tests in classes derived from
1400 testtools.testcase.TestCase (bug #312257).
1402 * Supports the Python 2.7/3.1 addUnexpectedSuccess and addExpectedFailure
1403 TestResult methods, with a support function 'knownFailure' to let tests
1404 trigger these outcomes.
1406 * When using the skip feature with TestResult objects that do not support it
1407 a test success will now be reported. Previously an error was reported but
1408 production experience has shown that this is too disruptive for projects that
1409 are using skips: they cannot get a clean run on down-level result objects.
1412 .. _testtools: http://pypi.python.org/pypi/testtools