Beispiel #1
0
    def test_nop_visit(self):
        obj = Base(None, None)
        obj.not_called = Mock()

        obj.visit("missing_method")

        obj.not_called.assert_not_called()
Beispiel #2
0
    def test_non_empty_visit(self):
        obj1 = Base(None, None)
        obj1.called = Mock()
        obj2 = Base(None, None)
        obj2.not_called = Mock()

        ListWrapper([obj1, obj2], None).visit("called", "with", keyword="args")

        obj1.called.assert_called_once_with("with", keyword="args")
        obj2.not_called.assert_not_called()
Beispiel #3
0
    def test_visit(self):
        obj1 = Base(None, None)
        obj1.called = Mock()
        obj2 = Base(None, None)
        obj2.not_called = Mock()

        MapWrapper({"a": obj1, "b": obj2}, None).visit(
            "called", "with", keyword="args",
        )

        obj1.called.assert_called_once_with("with", keyword="args")
        obj2.not_called.assert_not_called()