]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] Document use of ANY in test assertions (GH-94060) (GH-115608)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 17 Feb 2024 13:24:40 +0000 (14:24 +0100)
committerGitHub <noreply@github.com>
Sat, 17 Feb 2024 13:24:40 +0000 (13:24 +0000)
(cherry picked from commit 04005f5021a17b191dae319faaadf1c942af3fe9)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Doc/library/unittest.mock.rst

index 75d8a6c9bdee3fc5e42b03996b422344523132c1..837eb14d4c81141fe38e175c723ff9ce0dee0a92 100644 (file)
@@ -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