Beispiel #1
0
    def test_patching_event_firing(self):
        class A(object):
            def f(self):
                pass;

        patcher.add_start_end_reporting("event1",A,"f")
        patcher.add_start_end_reporting("event2",A,"f")

        events=[]
        with EventCatcher(events):
            a= A()
            a.f()

        self.assertEqual(events,
                [
                    ("event2","start",None),
                    ("event1","start",None),
                    ("event1","end",None),
                    ("event2","end",None),
                ]
            )
Beispiel #2
0
    def test_patching_dedup(self):
        class A(object):
            def f(self):
                pass;

        patcher.add_start_end_reporting("event1",A,"f")
        patcher.add_start_end_reporting("event2",A,"f")
        patcher.add_start_end_reporting("event1",A,"f")

        self.assertEqual(patcher._get_existing_wrapped_events(A.f), ["event1","event2"])