From: Thomas Grainger Date: Sat, 17 Feb 2024 13:13:34 +0000 (+0000) Subject: Document use of ANY in test assertions (GH-94060) X-Git-Tag: v3.13.0a5~359 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=04005f5021a17b191dae319faaadf1c942af3fe9;p=thirdparty%2FPython%2Fcpython.git Document use of ANY in test assertions (GH-94060) --- diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index eca20b94ec8e..b0a5d96c38d3 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -2426,6 +2426,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