Skip to content

Commit

Permalink
Document use of ANY in test assertions (pythonGH-94060)
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert authored and diegorusso committed Apr 17, 2024
1 parent 4561a2c commit 59424e9
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 @@ -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
Expand Down

0 comments on commit 59424e9

Please sign in to comment.