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

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

index d11307447b26a30c38cc4bb85c0f94320519d253..cb9e7203fc640b79c06178673f2bade9dcb47edd 100644 (file)
@@ -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