def test_calls_different(self): m1 =Mock() m2 =Mock() m1.foo(1, 2, x=3, y=4) m2.bar(1, 3, x=7, y=4) self.check_raises( m1.mock_calls, m2.mock_calls, "sequence not as expected:\n" "\n" "same:\n" "[]\n" "\n" "first:\n" "[call.foo(1, 2, x=3, y=4)]\n" "\n" "second:\n" "[call.bar(1, 3, x=7, y=4)]" "\n\n" 'While comparing [0]: \n' "'call.foo(1, 2, x=3, y=4)'\n" '!=\n' "'call.bar(1, 3, x=7, y=4)'" )
def test_calls_different(self): m1 =Mock() m2 =Mock() m1.foo(1, 2, x=3, y=4) m2.bar(1, 3, x=7, y=4) self.check_raises( m1.mock_calls, m2.mock_calls, "sequence not as expected:\n" "\n" "same:\n" "[]\n" "\n" "first:\n" "[call.foo(1, 2, x=3, y=4)]\n" "\n" "second:\n" "[call.bar(1, 3, x=7, y=4)]" "\n\n" 'While comparing [0]: \n' "'call.foo(1, 2, x=3, y=4)'\n" '!=\n' "'call.bar(1, 3, x=7, y=4)'" )
def test_non_root_call_not_equal(self): m = Mock() m.foo().bar() self.check_raises( m.mock_calls[-1], call.baz().bar(), '\n' "'call.foo().bar()'\n" '!=\n' "'call.baz().bar()'")
def test_non_root_params_not_equal(self): m = Mock() m.foo(x=1).bar() # surprising and annoying (and practically unsolvable :-/): assert m.mock_calls[-1] == call.foo(y=2).bar()
def test_mock_call_same_strict(self): m = Mock() m.foo(1, 2, x=3) compare(m.mock_calls, m.mock_calls, strict=True)
def test_mock_call_same(self): m = Mock() m.foo(1, 2, x=3) compare(m.mock_calls, m.mock_calls)
def test_mock_call_same_strict(self): m = Mock() m.foo(1, 2, x=3) compare(m.mock_calls, m.mock_calls, strict=True)
def test_mock_call_same(self): m = Mock() m.foo(1, 2, x=3) compare(m.mock_calls, m.mock_calls)