Skip to content

Commit

Permalink
[3.12] Document use of ANY in test assertions (GH-94060) (GH-115607)
Browse files Browse the repository at this point in the history
(cherry picked from commit 04005f5)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
  • Loading branch information
miss-islington and graingert authored Feb 17, 2024
1 parent a086dd3 commit c726d1c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Doc/library/unittest.mock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c726d1c

Please sign in to comment.