From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 17 Feb 2024 13:24:40 +0000 (+0100) Subject: [3.11] Document use of ANY in test assertions (GH-94060) (GH-115608) X-Git-Tag: v3.11.9~187 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a6776cdc53cf372318a3b3b3b79afadcc2349a8d;p=thirdparty%2FPython%2Fcpython.git [3.11] Document use of ANY in test assertions (GH-94060) (GH-115608) (cherry picked from commit 04005f5021a17b191dae319faaadf1c942af3fe9) Co-authored-by: Thomas Grainger --- diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 75d8a6c9bdee..837eb14d4c81 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -2375,6 +2375,14 @@ passed in. >>> m.mock_calls == [call(1), call(1, 2), ANY] True +:data:`ANY` is not limited to comparisons with call objects and so +can also be used in test assertions:: + + class TestStringMethods(unittest.TestCase): + + def test_split(self): + s = 'hello world' + self.assertEqual(s.split(), ['hello', ANY]) FILTER_DIR