MCPcopy Index your code
hub / github.com/python/cpython / _Call

Class _Call

Lib/unittest/mock.py:2560–2742  ·  view source on GitHub ↗

A tuple for holding the results of a call to a mock, either in the form `(args, kwargs)` or `(name, args, kwargs)`. If args or kwargs are empty then a call tuple will compare equal to a tuple without those values. This makes comparisons less verbose:: _Call(('name', (), {}

Source from the content-addressed store, hash-verified

2558
2559
2560class _Call(tuple):
2561 """
2562 A tuple for holding the results of a call to a mock, either in the form
2563 `(args, kwargs)` or `(name, args, kwargs)`.
2564
2565 If args or kwargs are empty then a call tuple will compare equal to
2566 a tuple without those values. This makes comparisons less verbose::
2567
2568 _Call(('name', (), {})) == ('name',)
2569 _Call(('name', (1,), {})) == ('name', (1,))
2570 _Call(((), {'a': 'b'})) == ({'a': 'b'},)
2571
2572 The `_Call` object provides a useful shortcut for comparing with call::
2573
2574 _Call(((1, 2), {'a': 3})) == call(1, 2, a=3)
2575 _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3)
2576
2577 If the _Call has no name then it will match any name.
2578 """
2579 def __new__(cls, value=(), name='', parent=None, two=False,
2580 from_kall=True):
2581 args = ()
2582 kwargs = {}
2583 _len = len(value)
2584 if _len == 3:
2585 name, args, kwargs = value
2586 elif _len == 2:
2587 first, second = value
2588 if isinstance(first, str):
2589 name = first
2590 if isinstance(second, tuple):
2591 args = second
2592 else:
2593 kwargs = second
2594 else:
2595 args, kwargs = first, second
2596 elif _len == 1:
2597 value, = value
2598 if isinstance(value, str):
2599 name = value
2600 elif isinstance(value, tuple):
2601 args = value
2602 else:
2603 kwargs = value
2604
2605 if two:
2606 return tuple.__new__(cls, (args, kwargs))
2607
2608 return tuple.__new__(cls, (name, args, kwargs))
2609
2610
2611 def __init__(self, value=(), name=None, parent=None, two=False,
2612 from_kall=True):
2613 self._mock_name = name
2614 self._mock_parent = parent
2615 self._mock_from_kall = from_kall
2616
2617

Callers 15

test_call_with_callMethod · 0.90
test_empty__CallMethod · 0.90
test_named_empty_callMethod · 0.90
test_call_with_argsMethod · 0.90
test_call_with_kwargsMethod · 0.90
test_call_neMethod · 0.90
test_call_non_tuplesMethod · 0.90
test_reprMethod · 0.90
test_two_args_callMethod · 0.90

Calls

no outgoing calls

Tested by 13

test_call_with_callMethod · 0.72
test_empty__CallMethod · 0.72
test_named_empty_callMethod · 0.72
test_call_with_argsMethod · 0.72
test_call_with_kwargsMethod · 0.72
test_call_neMethod · 0.72
test_call_non_tuplesMethod · 0.72
test_reprMethod · 0.72
test_two_args_callMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…