Exemplo n.º 1
0
    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)'"
        )
Exemplo n.º 2
0
    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)'"
        )
Exemplo n.º 3
0
 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()'")
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
 def test_mock_call_same_strict(self):
     m = Mock()
     m.foo(1, 2, x=3)
     compare(m.mock_calls, m.mock_calls, strict=True)
Exemplo n.º 6
0
 def test_mock_call_same(self):
     m = Mock()
     m.foo(1, 2, x=3)
     compare(m.mock_calls, m.mock_calls)
Exemplo n.º 7
0
 def test_mock_call_same_strict(self):
     m = Mock()
     m.foo(1, 2, x=3)
     compare(m.mock_calls, m.mock_calls, strict=True)
Exemplo n.º 8
0
 def test_mock_call_same(self):
     m = Mock()
     m.foo(1, 2, x=3)
     compare(m.mock_calls, m.mock_calls)