Commit Graph

100 Commits

Author SHA1 Message Date
Serhiy Storchaka 48fbe52ac7 bpo-30664: The description of a unittest subtest now preserves the (#2265)
order of keyword arguments of TestCase.subTest().
2017-06-23 21:47:39 +03:00
Giampaolo Rodola 5d7a8d0c13 bpo-30190: improved error msg for assertAlmostEqual(delta=...) (#1331)
* #30190 / unittest / assertAlmostEqual(delta=...) / error msg: show the difference between the 2 numbers in case of failure

* safe_repr() diff

* also show difference when passing 'places' argument

* refactoring

* update Misc/NEWS
2017-05-01 18:18:56 +02:00
Victor Stinner bbd3cf8f1e Fix ref cycles in TestCase.assertRaises() (#193)
bpo-23890: unittest.TestCase.assertRaises() now manually breaks a
reference cycle to not keep objects alive longer than expected.
2017-03-28 00:56:28 +02:00
Berker Peksag 16ea19fc66 Issue #25651: Allow falsy values to be used for msg parameter of subTest() 2016-09-21 19:34:15 +03:00
Martin Panter eb9957065a Issue #27626: Spelling fixes in docs, comments and internal names
Based on patch by Ville Skyttä.
2016-07-28 01:11:04 +00:00
Serhiy Storchaka 685fbed7f9 Issue #26837: assertSequenceEqual() now correctly outputs non-stringified
differing items (like bytes in the -b mode).  This affects assertListEqual()
and assertTupleEqual().
2016-04-25 08:58:25 +03:00
Robert Collins 079fc7faff Issue #21112: Fix regression in unittest.expectedFailure on subclasses.
Patch from Berker Peksag.
2015-08-28 10:35:14 +12:00
Robert Collins ed599b7c84 Issue #21112: Fix regression in unittest.expectedFailure on subclasses.
Patch from Berker Peksag.
2015-08-28 10:34:51 +12:00
Robert Collins be6caca534 Issue #20362: Honour TestCase.longMessage correctly in assertRegex.
Patch from Ilia Kurenkov.
2015-08-20 11:13:09 +12:00
Serhiy Storchaka 041dd8eef1 Issue #15836: assertRaises(), assertRaisesRegex(), assertWarns() and
assertWarnsRegex() assertments now check the type of the first argument
to prevent possible user error.  Based on patch by Daniel Wagner-Hall.
2015-05-21 20:15:40 +03:00
Serhiy Storchaka df573d6ad8 Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() and
assertWarnsRegex() checks now emits a deprecation warning when callable is
None or keyword arguments except msg is passed in the context manager mode.
2015-05-16 16:29:50 +03:00
Serhiy Storchaka 4b5367c46d Fixed English in error message. 2015-05-06 19:21:00 +03:00
Serhiy Storchaka e130503c7b Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() and
assertWarnsRegex() checks are not longer successful if the callable is None.

Added tests for assertRaises().
2015-05-06 19:13:11 +03:00
Serhiy Storchaka a7d00c207f Reverted issue #24134 changes (except new tests). 2015-05-16 16:25:43 +03:00
Serhiy Storchaka f4b7a02e93 Issue #21408: The default __ne__() now returns NotImplemented if __eq__()
returned NotImplemented.  Removed incorrect implementations of __ne__().
2015-01-26 09:57:07 +02:00
Antoine Pitrou 9681022f1e Issue #9815: assertRaises now tries to clear references to local variables in the exception's traceback. 2014-04-29 01:23:50 +02:00
R David Murray ef1c26798c backport: #20145: assert[Raises|Warns]Regex now raise TypeError on bad regex.
Previously a non-string, non-regex second argument and missing callable
argument could cause the test to appear to always pass.

Initial patch by Kamilla Holanda.
2014-03-25 15:31:50 -04:00
Victor Stinner 031bd532c4 Close #19880: Fix a reference leak in unittest.TestCase. Explicitly break
reference cycles between frames and the _Outcome instance.
2013-12-09 01:52:50 +01:00
Serhiy Storchaka 77622f55c2 Issue #18996: TestCase.assertEqual() now more cleverly shorten differing
strings in error report.
2013-09-23 23:07:00 +03:00
Antoine Pitrou 0715b9fad3 Issue #18937: Add an assertLogs() context manager to unittest.TestCase to ensure that a block of code emits a message using the logging module. 2013-09-14 19:45:47 +02:00
Ezio Melotti 85a25222bc #8906: merge with 3.3. 2013-03-29 03:43:38 +02:00
Ezio Melotti 31797e5efe #8906: document failureException, longMessage, and maxDiff in the class docstring. Patch by Boris Feld. 2013-03-29 03:42:29 +02:00
Ezio Melotti 67ddccafc3 #17329: merge with 3.3. 2013-03-27 20:13:59 +02:00
Ezio Melotti 184e59357e #17329: merge with 3.2. 2013-03-27 20:12:55 +02:00
Ezio Melotti 265281ac02 #17329: document unittest.SkipTest. Initial patch by Zachary Ware. 2013-03-27 20:11:55 +02:00
Antoine Pitrou c9b3ef2df0 Issue #16997: unittest.TestCase now provides a subTest() context manager to procedurally generate, in an easy way, small test instances. 2013-03-20 20:16:47 +01:00
Andrew Svetlov 5b89840d9c Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:26:36 +02:00
Andrew Svetlov 737fb89dd1 Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:14:22 +02:00
Ezio Melotti 9cfa1ff891 #16433: merge with 3.2. 2012-11-08 11:09:13 +02:00
Ezio Melotti 90eea97a33 #16433: fix docstring of assertNotEqual. 2012-11-08 11:08:39 +02:00
Benjamin Peterson b29614e047 compare singletons by identity not equality (closes #16712)
Patch from Serhiy Storchaka.
2012-10-09 11:16:03 -04:00
Antoine Pitrou f99983dacb Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a test class that doesn't inherit from TestCase (i.e. a mixin). 2012-04-25 14:58:17 +02:00
Antoine Pitrou b05ac864f0 Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a test class that doesn't inherit from TestCase (i.e. a mixin). 2012-04-25 14:56:46 +02:00
Florent Xicluna c53ae58954 Drop unused import in unittest package. 2011-11-04 08:25:54 +01:00
Ezio Melotti d8b509b192 #13012: use splitlines(keepends=True/False) instead of splitlines(0/1). 2011-09-28 17:37:55 +03:00
Benjamin Peterson 0850638957 merge 3.2 (#12544) 2011-07-12 19:23:43 -05:00
Benjamin Peterson 34b2b263db this can be done without a custom dict (also fixes #12544) 2011-07-12 19:21:42 -05:00
Ezio Melotti b4dc2502ad Issue #10775: assertRaises, assertRaisesRegex, assertWarns, and assertWarnsRegex now accept a keyword argument 'msg' when used as context managers. Initial patch by Winston Ewert. 2011-05-06 15:01:41 +03:00
Ezio Melotti 9490af2150 #11763: merge with 3.2. 2011-04-27 10:21:51 +03:00
Ezio Melotti edd117fd27 #11763: merge with 3.1. 2011-04-27 10:20:38 +03:00
Ezio Melotti 0f535013c5 #11282: add back the fail* methods and assertDictContainsSubset. 2011-04-03 18:02:13 +03:00
Ezio Melotti b7af620747 #11282: merge with 3.2. 2011-04-03 17:39:19 +03:00
Ezio Melotti 361467e522 #11282: the fail* methods will stay around a few more versions. 2011-04-03 17:37:58 +03:00
Michael Foord 1341bb0019 Closes issue 11407. TestCase.run returns the result object used or created 2011-03-14 19:01:46 -04:00
Georg Brandl 2cebdd4865 Remove unittest methods scheduled for removal in 3.3 -- makes the unittest test suite pass again. 2011-02-20 11:18:09 +00:00
Michael Foord e180d3953f Issue 10573: revert unittest docs to first / second
Minor internal change to unittest.TestCase.assertCountEqual
Reviewed by R. David Murray
2011-01-28 19:51:48 +00:00
Michael Foord 32e1d8340c Enable unittest.TestCase to be instantiated without providing a method name.
Changed unittestgui to show number of discovered tests in the status bar.
2011-01-03 17:00:11 +00:00
Raymond Hettinger 57bd00a15b Adopt symmetric names for arguments (actual/expected --> first/second). 2010-12-24 21:51:48 +00:00
Raymond Hettinger 9d668dac68 Put diff output in useful order (when the elements were first seen). 2010-12-24 11:20:30 +00:00
Raymond Hettinger 93e233d6e5 Improve diff for assertCountEqual() to actually show the differing counts.
New output looks like this:

Traceback (most recent call last):
  File "test.py", line 5, in test_ce
    self.assertCountEqual('abracadabra xx', 'simsalabim xx')
AssertionError: Element counts were not equal:
Expected 5, got 2:  'a'
Expected 2, got 1:  'b'
Expected 0, got 2:  'i'
Expected 0, got 2:  'm'
Expected 0, got 1:  'l'
Expected 0, got 2:  's'
Expected 1, got 0:  'c'
Expected 1, got 0:  'd'
Expected 2, got 0:  'r'
2010-12-24 10:02:22 +00:00