Add a StreamResult safe for use in threaded/concurrent code.
[third_party/testtools] / NEWS
1 testtools NEWS
2 ++++++++++++++
3
4 Changes and improvements to testtools_, grouped by release.
5
6 NEXT
7 ~~~~
8
9 A new sort of TestResult, the StreamResult has been added, as a prototype for
10 a revised standard library test result API.  Expect this API to change.
11 Although we will try to preserve compatibility for early adopters, it is
12 experimental and we might need to break it.
13
14 Improvements
15 ------------
16
17 * ``ConcurrentTestSuite`` was silently eating exceptions that propagate from
18   the test.run(result) method call. Ignoring them is fine in a normal test
19   runner, but when they happen in a different thread, the thread that called
20   suite.run() is not in the stack anymore, and the exceptions are lost. We now
21   create a synthetic test recording any such exception.
22   (Robert Collins, #1130429)
23
24 * Fixed SyntaxError raised in ``_compat2x.py`` when installing via Python 3.
25   (Will Bond, #941958)
26
27 * New class ``StreamResult`` which defines the API for the new result type.
28   (Robert Collins)
29
30 * New support class ``ConcurrentStreamTestSuite`` for convenient construction
31   and utilisation of ``StreamToQueue`` objects. (Robert Collins)
32
33 * New support class ``CopyStreamResult`` which forwards events onto multiple
34   ``StreamResult`` objects (each of which receives all the events).
35   (Robert Collins)
36
37 * New support class ``StreamSummary`` which summarises a ``StreamResult``
38   stream compatibly with ``TestResult`` code. (Robert Collins)
39
40 * New support class ``StreamTagger`` which adds or removes tags from
41   ``StreamResult`` events. (RobertCollins)
42
43 * New support class ``StreamToDict`` which converts a ``StreamResult`` to a
44   series of dicts describing a test. Useful for writing trivial stream
45   analysers. (Robert Collins)
46
47 * New support class ``TestControl`` which permits cancelling an in-progress
48   run. (Robert Collins)
49
50 * New support class ``StreamFailFast`` which calls a ``TestControl`` instance
51   to abort the test run when a failure is detected. (Robert Collins)
52
53 * New support class ``ExtendedToStreamDecorator`` which translates both regular
54   unittest TestResult API calls and the ExtendedTestResult API which testtools
55   has supported into the StreamResult API. ExtendedToStreamDecorator also
56   forwards calls made in the StreamResult API, permitting it to be used
57   anywhere a StreamResult is used. Key TestResult query methods like
58   wasSuccessful and shouldStop are synchronised with the StreamResult API
59   calls, but the detailed statistics like the list of errors are not - a
60   separate consumer will be created to support that.
61   (Robert Collins)
62
63 * New support class ``StreamToExtendedDecorator`` which translates
64   ``StreamResult`` API calls into ``ExtendedTestResult`` (or any older
65   ``TestResult``) calls. This permits using un-migrated result objects with
66   new runners / tests. (Robert Collins)
67
68 * New support class ``StreamToQueue`` for sending messages to one
69   ``StreamResult`` from multiple threads. (Robert Collins)
70
71 * New support class ``TimestampingStreamResult`` which adds a timestamp to
72   events with no timestamp. (Robert Collins)
73
74 * New ``TestCase`` decorator ``DecorateTestCaseResult`` that adapts the
75   ``TestResult`` or ``StreamResult`` a case will be run with, for ensuring that
76   a particular result object is used even if the runner running the test doesn't
77   know to use it. (Robert Collins)
78
79 * New test support class ``testtools.testresult.doubles.StreamResult``, which
80   captures all the StreamResult events. (Robert Collins)
81
82 * ``PlaceHolder`` can now hold tags, and applies them before, and removes them
83   after, the test. (Robert Collins)
84
85 * ``PlaceHolder`` can now hold timestamps, and applies them before the test and
86   then before the outcome. (Robert Collins)
87
88 * The error message for setUp and tearDown upcall errors was broken on Python
89   3.4. (Monty Taylor, Robert Collins, #1140688)
90
91 * The repr of object() on pypy includes the object id, which was breaking a
92   test that accidentally depended on the CPython repr for object().
93   (Jonathan Lange)
94
95 0.9.29
96 ~~~~~~
97
98 A simple bug fix, and better error messages when you don't up-call.
99
100 Changes
101 -------
102
103 * ``testtools.content_type.ContentType`` incorrectly used ',' rather than ';'
104   to separate parameters. (Robert Collins)
105
106 Improvements
107 ------------
108
109 * ``testtools.compat.unicode_output_stream`` was wrapping a stream encoder
110   around ``io.StringIO`` and ``io.TextIOWrapper`` objects, which was incorrect.
111   (Robert Collins)
112
113 * Report the name of the source file for setUp and tearDown upcall errors.
114   (Monty Taylor)
115
116 0.9.28
117 ~~~~~~
118
119 Testtools has moved VCS - https://github.com/testing-cabal/testtools/ is
120 the new home. Bug tracking is still on Launchpad, and releases are on Pypi.
121
122 We made this change to take advantage of the richer ecosystem of tools around
123 Git, and to lower the barrier for new contributors.
124
125 Improvements
126 ------------
127
128 * New ``testtools.testcase.attr`` and ``testtools.testcase.WithAttributes``
129   helpers allow marking up test case methods with simple labels. This permits
130   filtering tests with more granularity than organising them into modules and
131   test classes. (Robert Collins)
132
133 0.9.27
134 ~~~~~~
135
136 Improvements
137 ------------
138
139 * New matcher ``HasLength`` for matching the length of a collection.
140   (Robert Collins)
141
142 * New matcher ``MatchesPredicateWithParams`` make it still easier to create
143   ad hoc matchers. (Robert Collins)
144
145 * We have a simpler release process in future - see doc/hacking.rst.
146   (Robert Collins)
147
148 0.9.26
149 ~~~~~~
150
151 Brown paper bag fix: failed to document the need for setup to be able to use
152 extras. Compounded by pip not supporting setup_requires.
153
154 Changes
155 -------
156
157 * setup.py now can generate egg_info even if extras is not available.
158   Also lists extras in setup_requires for easy_install.
159   (Robert Collins, #1102464)
160
161 0.9.25
162 ~~~~~~
163
164 Changes
165 -------
166
167 * ``python -m testtools.run --load-list`` will now preserve any custom suites
168   (such as ``testtools.FixtureSuite`` or ``testresources.OptimisingTestSuite``)
169   rather than flattening them.
170   (Robert Collins, #827175)
171
172 * Testtools now depends on extras, a small library split out from it to contain
173   generally useful non-testing facilities. Since extras has been around for a
174   couple of testtools releases now, we're making this into a hard dependency of
175   testtools. (Robert Collins)
176
177 * Testtools now uses setuptools rather than distutils so that we can document
178   the extras dependency. (Robert Collins)
179
180 Improvements
181 ------------
182
183 * Testtools will no longer override test code registered details called
184   'traceback' when reporting caught exceptions from test code.
185   (Robert Collins, #812793)
186
187 0.9.24
188 ~~~~~~
189
190 Changes
191 -------
192
193 * ``testtools.run discover`` will now sort the tests it discovered. This is a 
194   workaround for http://bugs.python.org/issue16709. Non-standard test suites
195   are preserved, and their ``sort_tests()`` method called (if they have such an
196   attribute). ``testtools.testsuite.sorted_tests(suite, True)`` can be used by
197   such suites to do a local sort. (Robert Collins, #1091512)
198
199 * ``ThreadsafeForwardingResult`` now defines a stub ``progress`` method, which
200   fixes ``testr run`` of streams containing progress markers (by discarding the 
201   progress data). (Robert Collins, #1019165)
202
203 0.9.23
204 ~~~~~~
205
206 Changes
207 -------
208
209 * ``run.TestToolsTestRunner`` now accepts the verbosity, buffer and failfast
210   arguments the upstream python TestProgram code wants to give it, making it
211   possible to support them in a compatible fashion. (Robert Collins)
212
213 Improvements
214 ------------
215
216 * ``testtools.run`` now supports the ``-f`` or ``--failfast`` parameter.
217   Previously it was advertised in the help but ignored.
218   (Robert Collins, #1090582)
219
220 * ``AnyMatch`` added, a new matcher that matches when any item in a collection
221   matches the given matcher.  (Jonathan Lange)
222
223 * Spelling corrections to documentation.  (Vincent Ladeuil)
224
225 * ``TestProgram`` now has a sane default for its ``testRunner`` argument.
226   (Vincent Ladeuil)
227
228 * The test suite passes on Python 3 again. (Robert Collins)
229
230 0.9.22
231 ~~~~~~
232
233 Improvements
234 ------------
235
236 * ``content_from_file`` and ``content_from_stream`` now accept seek_offset and
237   seek_whence parameters allowing them to be used to grab less than the full
238   stream, or to be used with StringIO streams. (Robert Collins, #1088693)
239
240 0.9.21
241 ~~~~~~
242
243 Improvements
244 ------------
245
246 * ``DirContains`` correctly exposed, after being accidentally hidden in the
247   great matcher re-organization of 0.9.17.  (Jonathan Lange)
248
249
250 0.9.20
251 ~~~~~~
252
253 Three new matchers that'll rock your world.
254
255 Improvements
256 ------------
257
258 * New, powerful matchers that match items in a dictionary:
259
260   - ``MatchesDict``, match every key in a dictionary with a key in a
261     dictionary of matchers.  For when the set of expected keys is equal to the
262     set of observed keys.
263
264   - ``ContainsDict``, every key in a dictionary of matchers must be
265     found in a dictionary, and the values for those keys must match.  For when
266     the set of expected keys is a subset of the set of observed keys.
267
268   - ``ContainedByDict``, every key in a dictionary must be found in
269     a dictionary of matchers.  For when the set of expected keys is a superset
270     of the set of observed keys.
271
272   The names are a little confusing, sorry.  We're still trying to figure out
273   how to present the concept in the simplest way possible.
274
275
276 0.9.19
277 ~~~~~~
278
279 How embarrassing!  Three releases in two days.
280
281 We've worked out the kinks and have confirmation from our downstreams that
282 this is all good.  Should be the last release for a little while.  Please
283 ignore 0.9.18 and 0.9.17.
284
285 Improvements
286 ------------
287
288 * Include the matcher tests in the release, allowing the tests to run and
289   pass from the release tarball.  (Jonathan Lange)
290
291 * Fix cosmetic test failures in Python 3.3, introduced during release 0.9.17.
292   (Jonathan Lange)
293
294
295 0.9.18
296 ~~~~~~
297
298 Due to an oversight, release 0.9.18 did not contain the new
299 ``testtools.matchers`` package and was thus completely broken.  This release
300 corrects that, returning us all to normality.
301
302 0.9.17
303 ~~~~~~
304
305 This release brings better discover support and Python3.x improvements. There
306 are still some test failures on Python3.3 but they are cosmetic - the library
307 is as usable there as on any other Python 3 release.
308
309 Changes
310 -------
311
312 * The ``testtools.matchers`` package has been split up.  No change to the
313   public interface.  (Jonathan Lange)
314
315 Improvements
316 ------------
317
318 * ``python -m testtools.run discover . --list`` now works. (Robert Collins)
319
320 * Correctly handling of bytes vs text in JSON content type. (Martin [gz])
321
322
323 0.9.16
324 ~~~~~~
325
326 Some new matchers and a new content helper for JSON content.
327
328 This is the first release of testtools to drop support for Python 2.4 and 2.5.
329 If you need support for either of those versions, please use testtools 0.9.15.
330
331 Improvements
332 ------------
333
334 * New content helper, ``json_content`` (Jonathan Lange)
335
336 * New matchers:
337
338   * ``ContainsAll`` for asserting one thing is a subset of another
339     (Raphaël Badin)
340
341   * ``SameMembers`` for asserting two iterators have the same members.
342     (Jonathan Lange)
343
344 * Reraising of exceptions in Python 3 is more reliable. (Martin [gz])
345
346
347 0.9.15
348 ~~~~~~
349
350 This is the last release to support Python2.4 and 2.5. It brings in a slew of
351 improvements to test tagging and concurrency, making running large test suites
352 with partitioned workers more reliable and easier to reproduce exact test
353 ordering in a given worker. See our sister project ``testrepository`` for a
354 test runner that uses these features.
355
356 Changes
357 -------
358
359 * ``PlaceHolder`` and ``ErrorHolder`` now support being given result details.
360   (Robert Collins)
361
362 * ``ErrorHolder`` is now just a function - all the logic is in ``PlaceHolder``.
363   (Robert Collins)
364
365 * ``TestResult`` and all other ``TestResult``-like objects in testtools
366   distinguish between global tags and test-local tags, as per the subunit
367   specification.  (Jonathan Lange)
368
369 * This is the **last** release of testtools that supports Python 2.4 or 2.5.
370   These releases are no longer supported by the Python community and do not
371   receive security updates. If this affects you, you will need to either
372   stay on this release or perform your own backports.
373   (Jonathan Lange, Robert Collins)
374
375 * ``ThreadsafeForwardingResult`` now forwards global tags as test-local tags,
376   making reasoning about the correctness of the multiplexed stream simpler.
377   This preserves the semantic value (what tags apply to a given test) while
378   consuming less stream size (as no negative-tag statement is needed).
379   (Robert Collins, Gary Poster, #986434)
380
381 Improvements
382 ------------
383
384 * API documentation corrections. (Raphaël Badin)
385
386 * ``ConcurrentTestSuite`` now takes an optional ``wrap_result`` parameter
387   that can be used to wrap the ``ThreadsafeForwardingResults`` created by
388   the suite.  (Jonathan Lange)
389
390 * ``Tagger`` added.  It's a new ``TestResult`` that tags all tests sent to
391   it with a particular set of tags.  (Jonathan Lange)
392
393 * ``testresultdecorator`` brought over from subunit.  (Jonathan Lange)
394
395 * All ``TestResult`` wrappers now correctly forward ``current_tags`` from
396   their wrapped results, meaning that ``current_tags`` can always be relied
397   upon to return the currently active tags on a test result.
398
399 * ``TestByTestResult``, a ``TestResult`` that calls a method once per test,
400   added.  (Jonathan Lange)
401
402 * ``ThreadsafeForwardingResult`` correctly forwards ``tags()`` calls where
403   only one of ``new_tags`` or ``gone_tags`` are specified.
404   (Jonathan Lange, #980263)
405
406 * ``ThreadsafeForwardingResult`` no longer leaks local tags from one test
407   into all future tests run.  (Jonathan Lange, #985613)
408
409 * ``ThreadsafeForwardingResult`` has many, many more tests.  (Jonathan Lange)
410
411
412 0.9.14
413 ~~~~~~
414
415 Our sister project, `subunit <https://launchpad.net/subunit>`_, was using a
416 private API that was deleted in the 0.9.13 release.  This release restores
417 that API in order to smooth out the upgrade path.
418
419 If you don't use subunit, then this release won't matter very much to you.
420
421
422 0.9.13
423 ~~~~~~
424
425 Plenty of new matchers and quite a few critical bug fixes (especially to do
426 with stack traces from failed assertions).  A net win for all.
427
428 Changes
429 -------
430
431 * ``MatchesAll`` now takes an ``first_only`` keyword argument that changes how
432   mismatches are displayed.  If you were previously passing matchers to
433   ``MatchesAll`` with keyword arguments, then this change might affect your
434   test results.  (Jonathan Lange)
435
436 Improvements
437 ------------
438
439 * Actually hide all of the testtools stack for assertion failures. The
440   previous release promised clean stack, but now we actually provide it.
441   (Jonathan Lange, #854769)
442
443 * ``assertRaises`` now includes the ``repr`` of the callable that failed to raise
444   properly. (Jonathan Lange, #881052)
445
446 * Asynchronous tests no longer hang when run with trial.
447   (Jonathan Lange, #926189)
448
449 * ``Content`` objects now have an ``as_text`` method to convert their contents
450   to Unicode text.  (Jonathan Lange)
451
452 * Failed equality assertions now line up. (Jonathan Lange, #879339)
453
454 * ``FullStackRunTest`` no longer aborts the test run if a test raises an
455   error.  (Jonathan Lange)
456
457 * ``MatchesAll`` and ``MatchesListwise`` both take a ``first_only`` keyword
458   argument.  If True, they will report only on the first mismatch they find,
459   and not continue looking for other possible mismatches.
460   (Jonathan Lange)
461
462 * New helper, ``Nullary`` that turns callables with arguments into ones that
463   don't take arguments.  (Jonathan Lange)
464
465 * New matchers:
466
467   * ``DirContains`` matches the contents of a directory.
468     (Jonathan Lange, James Westby)
469
470   * ``DirExists`` matches if a directory exists.
471     (Jonathan Lange, James Westby)
472
473   * ``FileContains`` matches the contents of a file.
474     (Jonathan Lange, James Westby)
475
476   * ``FileExists`` matches if a file exists.
477     (Jonathan Lange, James Westby)
478
479   * ``HasPermissions`` matches the permissions of a file.  (Jonathan Lange)
480
481   * ``MatchesPredicate`` matches if a predicate is true.  (Jonathan Lange)
482
483   * ``PathExists`` matches if a path exists.  (Jonathan Lange, James Westby)
484
485   * ``SamePath`` matches if two paths are the same.  (Jonathan Lange)
486
487   * ``TarballContains`` matches the contents of a tarball.  (Jonathan Lange)
488
489 * ``MultiTestResult`` supports the ``tags`` method.
490   (Graham Binns, Francesco Banconi, #914279)
491
492 * ``ThreadsafeForwardingResult`` supports the ``tags`` method.
493   (Graham Binns, Francesco Banconi, #914279)
494
495 * ``ThreadsafeForwardingResult`` no longer includes semaphore acquisition time
496   in the test duration (for implicitly timed test runs).
497   (Robert Collins, #914362)
498
499 0.9.12
500 ~~~~~~
501
502 This is a very big release.  We've made huge improvements on three fronts:
503  1. Test failures are way nicer and easier to read
504  2. Matchers and ``assertThat`` are much more convenient to use
505  3. Correct handling of extended unicode characters
506
507 We've trimmed off the fat from the stack trace you get when tests fail, we've
508 cut out the bits of error messages that just didn't help, we've made it easier
509 to annotate mismatch failures, to compare complex objects and to match raised
510 exceptions.
511
512 Testing code was never this fun.
513
514 Changes
515 -------
516
517 * ``AfterPreproccessing`` renamed to ``AfterPreprocessing``, which is a more
518   correct spelling.  Old name preserved for backwards compatibility, but is
519   now deprecated.  Please stop using it.
520   (Jonathan Lange, #813460)
521
522 * ``assertThat`` raises ``MismatchError`` instead of
523   ``TestCase.failureException``.  ``MismatchError`` is a subclass of
524   ``AssertionError``, so in most cases this change will not matter. However,
525   if ``self.failureException`` has been set to a non-default value, then
526   mismatches will become test errors rather than test failures.
527
528 * ``gather_details`` takes two dicts, rather than two detailed objects.
529   (Jonathan Lange, #801027)
530
531 * ``MatchesRegex`` mismatch now says "<value> does not match /<regex>/" rather
532   than "<regex> did not match <value>". The regular expression contains fewer
533   backslashes too. (Jonathan Lange, #818079)
534
535 * Tests that run with ``AsynchronousDeferredRunTest`` now have the ``reactor``
536   attribute set to the running reactor. (Jonathan Lange, #720749)
537
538 Improvements
539 ------------
540
541 * All public matchers are now in ``testtools.matchers.__all__``.
542   (Jonathan Lange, #784859)
543
544 * ``assertThat`` can actually display mismatches and matchers that contain
545   extended unicode characters. (Jonathan Lange, Martin [gz], #804127)
546
547 * ``assertThat`` output is much less verbose, displaying only what the mismatch
548   tells us to display. Old-style verbose output can be had by passing
549   ``verbose=True`` to assertThat. (Jonathan Lange, #675323, #593190)
550
551 * ``assertThat`` accepts a message which will be used to annotate the matcher.
552   This can be given as a third parameter or as a keyword parameter.
553   (Robert Collins)
554
555 * Automated the Launchpad part of the release process.
556   (Jonathan Lange, #623486)
557
558 * Correctly display non-ASCII unicode output on terminals that claim to have a
559   unicode encoding. (Martin [gz], #804122)
560
561 * ``DocTestMatches`` correctly handles unicode output from examples, rather
562   than raising an error. (Martin [gz], #764170)
563
564 * ``ErrorHolder`` and ``PlaceHolder`` added to docs. (Jonathan Lange, #816597)
565
566 * ``ExpectedException`` now matches any exception of the given type by
567   default, and also allows specifying a ``Matcher`` rather than a mere regular
568   expression. (Jonathan Lange, #791889)
569
570 * ``FixtureSuite`` added, allows test suites to run with a given fixture.
571   (Jonathan Lange)
572
573 * Hide testtools's own stack frames when displaying tracebacks, making it
574   easier for test authors to focus on their errors.
575   (Jonathan Lange, Martin [gz], #788974)
576
577 * Less boilerplate displayed in test failures and errors.
578   (Jonathan Lange, #660852)
579
580 * ``MatchesException`` now allows you to match exceptions against any matcher,
581   rather than just regular expressions.  (Jonathan Lange, #791889)
582
583 * ``MatchesException`` now permits a tuple of types rather than a single type
584   (when using the type matching mode).  (Robert Collins)
585
586 * ``MatchesStructure.byEquality`` added to make the common case of matching
587   many attributes by equality much easier.  ``MatchesStructure.byMatcher``
588   added in case folk want to match by things other than equality.
589   (Jonathan Lange)
590
591 * New convenience assertions, ``assertIsNone`` and ``assertIsNotNone``.
592   (Christian Kampka)
593
594 * New matchers:
595
596   * ``AllMatch`` matches many values against a single matcher.
597     (Jonathan Lange, #615108)
598
599   * ``Contains``. (Robert Collins)
600
601   * ``GreaterThan``. (Christian Kampka)
602
603 * New helper, ``safe_hasattr`` added. (Jonathan Lange)
604
605 * ``reraise`` added to ``testtools.compat``. (Jonathan Lange)
606
607
608 0.9.11
609 ~~~~~~
610
611 This release brings consistent use of super for better compatibility with
612 multiple inheritance, fixed Python3 support, improvements in fixture and mather
613 outputs and a compat helper for testing libraries that deal with bytestrings.
614
615 Changes
616 -------
617
618 * ``TestCase`` now uses super to call base ``unittest.TestCase`` constructor,
619   ``setUp`` and ``tearDown``. (Tim Cole, #771508)
620
621 * If, when calling ``useFixture`` an error occurs during fixture set up, we
622   still attempt to gather details from the fixture. (Gavin Panella)
623
624
625 Improvements
626 ------------
627
628 * Additional compat helper for ``BytesIO`` for libraries that build on
629   testtools and are working on Python 3 porting. (Robert Collins)
630
631 * Corrected documentation for ``MatchesStructure`` in the test authors
632   document.  (Jonathan Lange)
633
634 * ``LessThan`` error message now says something that is logically correct.
635   (Gavin Panella, #762008)
636
637 * Multiple details from a single fixture are now kept separate, rather than
638   being mooshed together. (Gavin Panella, #788182)
639
640 * Python 3 support now back in action. (Martin [gz], #688729)
641
642 * ``try_import`` and ``try_imports`` have a callback that is called whenever
643   they fail to import a module.  (Martin Pool)
644
645
646 0.9.10
647 ~~~~~~
648
649 The last release of testtools could not be easy_installed.  This is considered
650 severe enough for a re-release.
651
652 Improvements
653 ------------
654
655 * Include ``doc/`` in the source distribution, making testtools installable
656   from PyPI again (Tres Seaver, #757439)
657
658
659 0.9.9
660 ~~~~~
661
662 Many, many new matchers, vastly expanded documentation, stacks of bug fixes,
663 better unittest2 integration.  If you've ever wanted to try out testtools but
664 been afraid to do so, this is the release to try.
665
666
667 Changes
668 -------
669
670 * The timestamps generated by ``TestResult`` objects when no timing data has
671   been received are now datetime-with-timezone, which allows them to be
672   sensibly serialised and transported. (Robert Collins, #692297)
673
674 Improvements
675 ------------
676
677 * ``AnnotatedMismatch`` now correctly returns details.
678   (Jonathan Lange, #724691)
679
680 * distutils integration for the testtools test runner. Can now use it for
681   'python setup.py test'. (Christian Kampka, #693773)
682
683 * ``EndsWith`` and ``KeysEqual`` now in testtools.matchers.__all__.
684   (Jonathan Lange, #692158)
685
686 * ``MatchesException`` extended to support a regular expression check against
687   the str() of a raised exception.  (Jonathan Lange)
688
689 * ``MultiTestResult`` now forwards the ``time`` API. (Robert Collins, #692294)
690
691 * ``MultiTestResult`` now documented in the manual. (Jonathan Lange, #661116)
692
693 * New content helpers ``content_from_file``, ``content_from_stream`` and
694   ``attach_file`` make it easier to attach file-like objects to a
695   test. (Jonathan Lange, Robert Collins, #694126)
696
697 * New ``ExpectedException`` context manager to help write tests against things
698   that are expected to raise exceptions. (Aaron Bentley)
699
700 * New matchers:
701
702   * ``MatchesListwise`` matches an iterable of matchers against an iterable
703     of values. (Michael Hudson-Doyle)
704
705   * ``MatchesRegex`` matches a string against a regular expression.
706     (Michael Hudson-Doyle)
707
708   * ``MatchesStructure`` matches attributes of an object against given
709     matchers.  (Michael Hudson-Doyle)
710
711   * ``AfterPreproccessing`` matches values against a matcher after passing them
712     through a callable.  (Michael Hudson-Doyle)
713
714   * ``MatchesSetwise`` matches an iterable of matchers against an iterable of
715     values, without regard to order.  (Michael Hudson-Doyle)
716
717 * ``setup.py`` can now build a snapshot when Bazaar is installed but the tree
718   is not a Bazaar tree. (Jelmer Vernooij)
719
720 * Support for running tests using distutils (Christian Kampka, #726539)
721
722 * Vastly improved and extended documentation. (Jonathan Lange)
723
724 * Use unittest2 exception classes if available. (Jelmer Vernooij)
725
726
727 0.9.8
728 ~~~~~
729
730 In this release we bring some very interesting improvements:
731
732 * new matchers for exceptions, sets, lists, dicts and more.
733
734 * experimental (works but the contract isn't supported) twisted reactor
735   support.
736
737 * The built in runner can now list tests and filter tests (the -l and
738   --load-list options).
739
740 Changes
741 -------
742
743 * addUnexpectedSuccess is translated to addFailure for test results that don't
744   know about addUnexpectedSuccess.  Further, it fails the entire result for
745   all testtools TestResults (i.e. wasSuccessful() returns False after
746   addUnexpectedSuccess has been called). Note that when using a delegating
747   result such as ThreadsafeForwardingResult, MultiTestResult or
748   ExtendedToOriginalDecorator then the behaviour of addUnexpectedSuccess is
749   determined by the delegated to result(s).
750   (Jonathan Lange, Robert Collins, #654474, #683332)
751
752 * startTestRun will reset any errors on the result.  That is, wasSuccessful()
753   will always return True immediately after startTestRun() is called. This
754   only applies to delegated test results (ThreadsafeForwardingResult,
755   MultiTestResult and ExtendedToOriginalDecorator) if the delegated to result
756   is a testtools test result - we cannot reliably reset the state of unknown
757   test result class instances. (Jonathan Lange, Robert Collins, #683332)
758
759 * Responsibility for running test cleanups has been moved to ``RunTest``.
760   This change does not affect public APIs and can be safely ignored by test
761   authors.  (Jonathan Lange, #662647)
762
763 Improvements
764 ------------
765
766 * New matchers:
767
768   * ``EndsWith`` which complements the existing ``StartsWith`` matcher.
769     (Jonathan Lange, #669165)
770
771   * ``MatchesException`` matches an exception class and parameters. (Robert
772     Collins)
773
774   * ``KeysEqual`` matches a dictionary with particular keys.  (Jonathan Lange)
775
776 * ``assertIsInstance`` supports a custom error message to be supplied, which
777   is necessary when using ``assertDictEqual`` on Python 2.7 with a
778   ``testtools.TestCase`` base class. (Jelmer Vernooij)
779
780 * Experimental support for running tests that return Deferreds.
781   (Jonathan Lange, Martin [gz])
782
783 * Provide a per-test decorator, run_test_with, to specify which RunTest
784   object to use for a given test.  (Jonathan Lange, #657780)
785
786 * Fix the runTest parameter of TestCase to actually work, rather than raising
787   a TypeError.  (Jonathan Lange, #657760)
788
789 * Non-release snapshots of testtools will now work with buildout.
790   (Jonathan Lange, #613734)
791
792 * Malformed SyntaxErrors no longer blow up the test suite.  (Martin [gz])
793
794 * ``MismatchesAll.describe`` no longer appends a trailing newline.
795   (Michael Hudson-Doyle, #686790)
796
797 * New helpers for conditionally importing modules, ``try_import`` and
798   ``try_imports``.  (Jonathan Lange)
799
800 * ``Raises`` added to the ``testtools.matchers`` module - matches if the
801   supplied callable raises, and delegates to an optional matcher for validation
802   of the exception. (Robert Collins)
803
804 * ``raises`` added to the ``testtools.matchers`` module - matches if the
805   supplied callable raises and delegates to ``MatchesException`` to validate
806   the exception. (Jonathan Lange)
807
808 * Tests will now pass on Python 2.6.4 : an ``Exception`` change made only in
809   2.6.4 and reverted in Python 2.6.5 was causing test failures on that version.
810   (Martin [gz], #689858).
811
812 * ``testtools.TestCase.useFixture`` has been added to glue with fixtures nicely.
813   (Robert Collins)
814
815 * ``testtools.run`` now supports ``-l`` to list tests rather than executing
816   them. This is useful for integration with external test analysis/processing
817   tools like subunit and testrepository. (Robert Collins)
818
819 * ``testtools.run`` now supports ``--load-list``, which takes a file containing
820   test ids, one per line, and intersects those ids with the tests found. This
821   allows fine grained control of what tests are run even when the tests cannot
822   be named as objects to import (e.g. due to test parameterisation via
823   testscenarios). (Robert Collins)
824
825 * Update documentation to say how to use testtools.run() on Python 2.4.
826   (Jonathan Lange, #501174)
827
828 * ``text_content`` conveniently converts a Python string to a Content object.
829   (Jonathan Lange, James Westby)
830
831
832
833 0.9.7
834 ~~~~~
835
836 Lots of little cleanups in this release; many small improvements to make your
837 testing life more pleasant.
838
839 Improvements
840 ------------
841
842 * Cleanups can raise ``testtools.MultipleExceptions`` if they have multiple
843   exceptions to report. For instance, a cleanup which is itself responsible for
844   running several different internal cleanup routines might use this.
845
846 * Code duplication between assertEqual and the matcher Equals has been removed.
847
848 * In normal circumstances, a TestCase will no longer share details with clones
849   of itself. (Andrew Bennetts, bug #637725)
850
851 * Less exception object cycles are generated (reduces peak memory use between
852   garbage collection). (Martin [gz])
853
854 * New matchers 'DoesNotStartWith' and 'StartsWith' contributed by Canonical
855   from the Launchpad project. Written by James Westby.
856
857 * Timestamps as produced by subunit protocol clients are now forwarded in the
858   ThreadsafeForwardingResult so correct test durations can be reported.
859   (Martin [gz], Robert Collins, #625594)
860
861 * With unittest from Python 2.7 skipped tests will now show only the reason
862   rather than a serialisation of all details. (Martin [gz], #625583)
863
864 * The testtools release process is now a little better documented and a little
865   smoother.  (Jonathan Lange, #623483, #623487)
866
867
868 0.9.6
869 ~~~~~
870
871 Nothing major in this release, just enough small bits and pieces to make it
872 useful enough to upgrade to.
873
874 In particular, a serious bug in assertThat() has been fixed, it's easier to
875 write Matchers, there's a TestCase.patch() method for those inevitable monkey
876 patches and TestCase.assertEqual gives slightly nicer errors.
877
878 Improvements
879 ------------
880
881 * 'TestCase.assertEqual' now formats errors a little more nicely, in the
882   style of bzrlib.
883
884 * Added `PlaceHolder` and `ErrorHolder`, TestCase-like objects that can be
885   used to add results to a `TestResult`.
886
887 * 'Mismatch' now takes optional description and details parameters, so
888   custom Matchers aren't compelled to make their own subclass.
889
890 * jml added a built-in UTF8_TEXT ContentType to make it slightly easier to
891   add details to test results. See bug #520044.
892
893 * Fix a bug in our built-in matchers where assertThat would blow up if any
894   of them failed. All built-in mismatch objects now provide get_details().
895
896 * New 'Is' matcher, which lets you assert that a thing is identical to
897   another thing.
898
899 * New 'LessThan' matcher which lets you assert that a thing is less than
900   another thing.
901
902 * TestCase now has a 'patch()' method to make it easier to monkey-patching
903   objects in tests. See the manual for more information. Fixes bug #310770.
904
905 * MultiTestResult methods now pass back return values from the results it
906   forwards to.
907
908 0.9.5
909 ~~~~~
910
911 This release fixes some obscure traceback formatting issues that probably
912 weren't affecting you but were certainly breaking our own test suite.
913
914 Changes
915 -------
916
917 * Jamu Kakar has updated classes in testtools.matchers and testtools.runtest
918   to be new-style classes, fixing bug #611273.
919
920 Improvements
921 ------------
922
923 * Martin[gz] fixed traceback handling to handle cases where extract_tb returns
924   a source line of None. Fixes bug #611307.
925
926 * Martin[gz] fixed an unicode issue that was causing the tests to fail,
927   closing bug #604187.
928
929 * testtools now handles string exceptions (although why would you want to use
930   them?) and formats their tracebacks correctly. Thanks to Martin[gz] for
931   fixing bug #592262.
932
933 0.9.4
934 ~~~~~
935
936 This release overhauls the traceback formatting layer to deal with Python 2
937 line numbers and traceback objects often being local user encoded strings
938 rather than unicode objects. Test discovery has also been added and Python 3.1
939 is also supported. Finally, the Mismatch protocol has been extended to let
940 Matchers collaborate with tests in supplying detailed data about failures.
941
942 Changes
943 -------
944
945 * testtools.utils has been renamed to testtools.compat. Importing
946   testtools.utils will now generate a deprecation warning.
947
948 Improvements
949 ------------
950
951 * Add machinery for Python 2 to create unicode tracebacks like those used by
952   Python 3. This means testtools no longer throws on encountering non-ascii
953   filenames, source lines, or exception strings when displaying test results.
954   Largely contributed by Martin[gz] with some tweaks from Robert Collins.
955
956 * James Westby has supplied test discovery support using the Python 2.7
957   TestRunner in testtools.run. This requires the 'discover' module. This
958   closes bug #250764.
959
960 * Python 3.1 is now supported, thanks to Martin[gz] for a partial patch.
961   This fixes bug #592375.
962
963 * TestCase.addCleanup has had its docstring corrected about when cleanups run.
964
965 * TestCase.skip is now deprecated in favour of TestCase.skipTest, which is the
966   Python2.7 spelling for skip. This closes bug #560436.
967
968 * Tests work on IronPython patch from Martin[gz] applied.
969
970 * Thanks to a patch from James Westby testtools.matchers.Mismatch can now
971   supply a get_details method, which assertThat will query to provide
972   additional attachments. This can be used to provide additional detail
973   about the mismatch that doesn't suite being included in describe(). For
974   instance, if the match process was complex, a log of the process could be
975   included, permitting debugging.
976
977 * testtools.testresults.real._StringException will now answer __str__ if its
978   value is unicode by encoding with UTF8, and vice versa to answer __unicode__.
979   This permits subunit decoded exceptions to contain unicode and still format
980   correctly.
981
982 0.9.3
983 ~~~~~
984
985 More matchers, Python 2.4 support, faster test cloning by switching to copy
986 rather than deepcopy and better output when exceptions occur in cleanups are
987 the defining characteristics of this release.
988
989 Improvements
990 ------------
991
992 * New matcher "Annotate" that adds a simple string message to another matcher,
993   much like the option 'message' parameter to standard library assertFoo
994   methods.
995
996 * New matchers "Not" and "MatchesAll". "Not" will invert another matcher, and
997   "MatchesAll" that needs a successful match for all of its arguments.
998
999 * On Python 2.4, where types.FunctionType cannot be deepcopied, testtools will
1000   now monkeypatch copy._deepcopy_dispatch using the same trivial patch that
1001   added such support to Python 2.5. The monkey patch is triggered by the
1002   absence of FunctionType from the dispatch dict rather than a version check.
1003   Bug #498030.
1004
1005 * On windows the test 'test_now_datetime_now' should now work reliably.
1006
1007 * TestCase.getUniqueInteger and TestCase.getUniqueString now have docstrings.
1008
1009 * TestCase.getUniqueString now takes an optional prefix parameter, so you can
1010   now use it in circumstances that forbid strings with '.'s, and such like.
1011
1012 * testtools.testcase.clone_test_with_new_id now uses copy.copy, rather than
1013   copy.deepcopy. Tests that need a deeper copy should use the copy protocol to
1014   control how they are copied. Bug #498869.
1015
1016 * The backtrace test result output tests should now pass on windows and other
1017   systems where os.sep is not '/'.
1018
1019 * When a cleanUp or tearDown exception occurs, it is now accumulated as a new
1020   traceback in the test details, rather than as a separate call to addError / 
1021   addException. This makes testtools work better with most TestResult objects
1022   and fixes bug #335816.
1023
1024
1025 0.9.2
1026 ~~~~~
1027
1028 Python 3 support, more matchers and better consistency with Python 2.7 --
1029 you'd think that would be enough for a point release. Well, we here on the
1030 testtools project think that you deserve more.
1031
1032 We've added a hook so that user code can be called just-in-time whenever there
1033 is an exception, and we've also factored out the "run" logic of test cases so
1034 that new outcomes can be added without fiddling with the actual flow of logic.
1035
1036 It might sound like small potatoes, but it's changes like these that will
1037 bring about the end of test frameworks.
1038
1039
1040 Improvements
1041 ------------
1042
1043 * A failure in setUp and tearDown now report as failures not as errors.
1044
1045 * Cleanups now run after tearDown to be consistent with Python 2.7's cleanup
1046   feature.
1047
1048 * ExtendedToOriginalDecorator now passes unrecognised attributes through
1049   to the decorated result object, permitting other extensions to the
1050   TestCase -> TestResult protocol to work.
1051
1052 * It is now possible to trigger code just-in-time after an exception causes
1053   a test outcome such as failure or skip. See the testtools MANUAL or
1054   ``pydoc testtools.TestCase.addOnException``. (bug #469092)
1055
1056 * New matcher Equals which performs a simple equality test.
1057
1058 * New matcher MatchesAny which looks for a match of any of its arguments.
1059
1060 * TestCase no longer breaks if a TestSkipped exception is raised with no
1061   parameters.
1062
1063 * TestCase.run now clones test cases before they are run and runs the clone.
1064   This reduces memory footprint in large test runs - state accumulated on
1065   test objects during their setup and execution gets freed when test case
1066   has finished running unless the TestResult object keeps a reference.
1067   NOTE: As test cloning uses deepcopy, this can potentially interfere if
1068   a test suite has shared state (such as the testscenarios or testresources
1069   projects use).  Use the __deepcopy__ hook to control the copying of such
1070   objects so that the shared references stay shared.
1071
1072 * Testtools now accepts contributions without copyright assignment under some
1073   circumstances. See HACKING for details.
1074
1075 * Testtools now provides a convenient way to run a test suite using the
1076   testtools result object: python -m testtools.run testspec [testspec...].
1077
1078 * Testtools now works on Python 3, thanks to Benjamin Peterson.
1079
1080 * Test execution now uses a separate class, testtools.RunTest to run single
1081   tests. This can be customised and extended in a more consistent fashion than
1082   the previous run method idiom. See pydoc for more information.
1083
1084 * The test doubles that testtools itself uses are now available as part of
1085   the testtools API in testtols.testresult.doubles.
1086
1087 * TracebackContent now sets utf8 as the charset encoding, rather than not
1088   setting one and encoding with the default encoder.
1089
1090 * With python2.7 testtools.TestSkipped will be the unittest.case.SkipTest
1091   exception class making skips compatible with code that manually raises the
1092   standard library exception. (bug #490109)
1093
1094 Changes
1095 -------
1096
1097 * TestCase.getUniqueInteger is now implemented using itertools.count. Thanks
1098   to Benjamin Peterson for the patch. (bug #490111)
1099
1100
1101 0.9.1
1102 ~~~~~
1103
1104 The new matcher API introduced in 0.9.0 had a small flaw where the matchee
1105 would be evaluated twice to get a description of the mismatch. This could lead
1106 to bugs if the act of matching caused side effects to occur in the matchee.
1107 Since having such side effects isn't desirable, we have changed the API now
1108 before it has become widespread.
1109
1110 Changes
1111 -------
1112
1113 * Matcher API changed to avoid evaluating matchee twice. Please consult
1114   the API documentation.
1115
1116 * TestCase.getUniqueString now uses the test id, not the test method name,
1117   which works nicer with parameterised tests.
1118
1119 Improvements
1120 ------------
1121
1122 * Python2.4 is now supported again.
1123
1124
1125 0.9.0
1126 ~~~~~
1127
1128 This release of testtools is perhaps the most interesting and exciting one
1129 it's ever had. We've continued in bringing together the best practices of unit
1130 testing from across a raft of different Python projects, but we've also
1131 extended our mission to incorporating unit testing concepts from other
1132 languages and from our own research, led by Robert Collins.
1133
1134 We now support skipping and expected failures. We'll make sure that you
1135 up-call setUp and tearDown, avoiding unexpected testing weirdnesses. We're
1136 now compatible with Python 2.5, 2.6 and 2.7 unittest library.
1137
1138 All in all, if you are serious about unit testing and want to get the best
1139 thinking from the whole Python community, you should get this release.
1140
1141 Improvements
1142 ------------
1143
1144 * A new TestResult API has been added for attaching details to test outcomes.
1145   This API is currently experimental, but is being prepared with the intent
1146   of becoming an upstream Python API. For more details see pydoc
1147   testtools.TestResult and the TestCase addDetail / getDetails methods.
1148
1149 * assertThat has been added to TestCase. This new assertion supports
1150   a hamcrest-inspired matching protocol. See pydoc testtools.Matcher for
1151   details about writing matchers, and testtools.matchers for the included
1152   matchers. See http://code.google.com/p/hamcrest/.
1153
1154 * Compatible with Python 2.6 and Python 2.7
1155
1156 * Failing to upcall in setUp or tearDown will now cause a test failure.
1157   While the base methods do nothing, failing to upcall is usually a problem
1158   in deeper hierarchies, and checking that the root method is called is a
1159   simple way to catch this common bug.
1160
1161 * New TestResult decorator ExtendedToOriginalDecorator which handles
1162   downgrading extended API calls like addSkip to older result objects that
1163   do not support them. This is used internally to make testtools simpler but
1164   can also be used to simplify other code built on or for use with testtools.
1165
1166 * New TextTestResult supporting the extended APIs that testtools provides.
1167
1168 * Nose will no longer find 'runTest' tests in classes derived from
1169    testtools.testcase.TestCase (bug #312257).
1170
1171 * Supports the Python 2.7/3.1 addUnexpectedSuccess and addExpectedFailure
1172   TestResult methods, with a support function 'knownFailure' to let tests
1173   trigger these outcomes.
1174
1175 * When using the skip feature with TestResult objects that do not support it
1176   a test success will now be reported. Previously an error was reported but
1177   production experience has shown that this is too disruptive for projects that
1178   are using skips: they cannot get a clean run on down-level result objects.
1179
1180
1181 .. _testtools: http://pypi.python.org/pypi/testtools