From c726d1cc677d02795473a2aea5c4c66d41490293 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sat, 17 Feb 2024 14:24:20 +0100 Subject: [3.12] Document use of ANY in test assertions (GH-94060) (GH-115607) (cherry picked from commit 04005f5021a17b191dae319faaadf1c942af3fe9) Co-authored-by: Thomas Grainger --- Doc/library/unittest.mock.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index d113074..cb9e720 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -2377,6 +2377,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 -- cgit v0.12