コード例 #1
0
def test_called_with_args_and_kwargs():
    """
    Test that :py:func:`.assert_called_once` works with args and kwargs.
    """
    m = Mock()
    m("test", test="test")
    assert_called_once(m, ("test",), {"test": "test"})
    assert_called_once(m, expected_kwargs={"test": "test"}, expected_args=("test",))
コード例 #2
0
def test_called_with_args_and_kwargs():
    """
    Test that :py:func:`.assert_called_once` works with args and kwargs.
    """
    m = Mock()
    m('test', test='test')
    assert_called_once(m, ('test',), {'test': 'test'})
    assert_called_once(m,
                       expected_kwargs={'test': 'test'},
                       expected_args=('test',))
コード例 #3
0
def test_called_with_only_args():
    """
    Test that :py:func:`.assert_called_once` works with only args.
    """
    m = Mock()
    m("test")
    assert_called_once(m, ("test",))
    assert_called_once(m, ("test",), {})
    assert_called_once(m, expected_args=("test",))
    assert_called_once(m, expected_kwargs={}, expected_args=("test",))
コード例 #4
0
def test_called_with_only_args():
    """
    Test that :py:func:`.assert_called_once` works with only args.
    """
    m = Mock()
    m('test')
    assert_called_once(m, ('test',))
    assert_called_once(m, ('test',), {})
    assert_called_once(m, expected_args=('test',))
    assert_called_once(m, expected_kwargs={}, expected_args=('test',))
コード例 #5
0
def test_called_with_only_kwargs():
    """
    Test that :py:func:`.assert_called_once` works with only kwargs.
    """
    m = Mock()
    m(test="test")
    assert_called_once(m, (), {"test": "test"})
    assert_called_once(m, expected_kwargs={"test": "test"})
    assert_called_once(m, expected_kwargs={"test": "test"}, expected_args=())
コード例 #6
0
def test_called_with_only_kwargs():
    """
    Test that :py:func:`.assert_called_once` works with only kwargs.
    """
    m = Mock()
    m(test='test')
    assert_called_once(m, (), {'test': 'test'})
    assert_called_once(m, expected_kwargs={'test': 'test'})
    assert_called_once(m, expected_kwargs={'test': 'test'}, expected_args=())