]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Document use of ANY in test assertions (GH-94060)
authorThomas Grainger <tagrain@gmail.com>
Sat, 17 Feb 2024 13:13:34 +0000 (13:13 +0000)
committerGitHub <noreply@github.com>
Sat, 17 Feb 2024 13:13:34 +0000 (13:13 +0000)
Doc/library/unittest.mock.rst

index eca20b94ec8e740a93c082ac11b9f7a782ced128..b0a5d96c38d375b346da6ba5624e3daa6dcc657c 100644 (file)
@@ -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