diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-02-05 22:58:21 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-02-05 22:58:21 (GMT) |
commit | 1c42b12b35a66c32367346580fe034f6380d284d (patch) | |
tree | 255121df8b7045fd42c1b6184b51e0c28b225a3c /Lib | |
parent | f5c851aa0405ff6442ed348720bc8949327eacd5 (diff) | |
download | cpython-1c42b12b35a66c32367346580fe034f6380d284d.zip cpython-1c42b12b35a66c32367346580fe034f6380d284d.tar.gz cpython-1c42b12b35a66c32367346580fe034f6380d284d.tar.bz2 |
Merged revisions 78003 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78003 | michael.foord | 2010-02-05 22:55:09 +0000 (Fri, 05 Feb 2010) | 1 line
Improving docstrings in unittest.TestCase
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/unittest/case.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 8b839c8..18d977f 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -231,10 +231,6 @@ class TestCase(object): """Returns both the test method name and first line of its docstring. If no docstring is given, only returns the method name. - - This method overrides unittest.TestCase.shortDescription(), which - only returns the first line of the docstring, obscuring the name - of the test upon failure. """ desc = str(self) doc_first_line = None @@ -397,8 +393,17 @@ class TestCase(object): If called with callableObj omitted or None, will return a context object used like this:: - with self.assertRaises(some_error_class): + with self.assertRaises(SomeException): do_something() + + The context manager keeps a reference to the exception as + the exc_value attribute. This allows you to inspect the + exception after the assertion:: + + with self.assertRaises(SomeException) as cm: + do_something() + the_exception = cm.exc_value + self.assertEquals(the_exception.error_code, 3) """ context = _AssertRaisesContext(excClass, self, callableObj) if callableObj is None: @@ -746,6 +751,11 @@ class TestCase(object): Raises with an error message listing which elements of expected_seq are missing from actual_seq and vice versa if any. + + Duplicate elements are ignored when comparing *expected_seq* and + *actual_seq*. It is the equivalent of ``assertEqual(set(expected), + set(actual))`` but it works with sequences of unhashable objects as + well. """ try: expected = set(expected_seq) |