Example #1
0
    def test_close_made_in_sequence(self):
        injector = Injector(a=lambda b: self.closer('A'),
                            b=lambda: self.closer('B'))
        injector.a
        injector.close()

        self.assertEqual(['A', 'B'], self.call_list)
Example #2
0
 def test_close_only_called_once(self):
     injector = Injector(a=lambda: self.closer('A'))
     sub = injector.sub(b=lambda: self.closer('B'))
     sub.b
     injector.a
     sub.close()
     injector.close()
     self.assertEqual(['B', 'A'], self.call_list)
Example #3
0
    def test_close_shared_among_subinjectors(self):
        injector = Injector(a=lambda: self.closer('A'))
        sub = injector.sub(b=lambda: self.closer('B'))
        sub.b
        injector.a
        injector.close()

        self.assertEqual(['B', 'A'], self.call_list)
Example #4
0
    def test_close_shared_among_subinjectors(self):
        injector = Injector(a=lambda: self.closer('A'))
        sub = injector.sub(b=lambda: self.closer('B'))
        sub.b
        injector.a
        injector.close()

        self.assertEqual(['B', 'A'], self.call_list)
Example #5
0
 def test_close_only_called_once(self):
     injector = Injector(a=lambda: self.closer('A'))
     sub = injector.sub(b=lambda: self.closer('B'))
     sub.b
     injector.a
     sub.close()
     injector.close()
     self.assertEqual(['B', 'A'], self.call_list)
Example #6
0
    def test_close_propagates_to_created_child_as_well(self):
        injector = Injector(a=self.closer('A'), b=lambda: self.closer('B'))
        injector.b
        injector.close()

        self.assertEqual(['B', 'A'], self.call_list)
Example #7
0
    def test_async_closing(self):
        injector = Injector(loop=asyncio.get_event_loop, a=self.async_closer)
        injector.a
        injector.close()

        self.assertEqual(['Default'], self.call_list)
Example #8
0
    def test_close_propagates_to_initial_child(self):
        injector = Injector(a=self.closer('A'), b=lambda: self.closer('B'))
        injector.close()

        self.assertEqual(['A'], self.call_list)
Example #9
0
    def test_close_propagates_to_initial_child(self):
        injector = Injector(a=self.closer('A'), b=lambda: self.closer('B'))
        injector.close()

        self.assertEqual(['A'], self.call_list)
Example #10
0
    def test_call_on_instance(self):
        injector = Injector(a=self.closer)
        injector.a
        injector.close()

        self.assertEqual(['Default'], self.call_list)
Example #11
0
    def test_do_not_call_on_class_level(self):
        injector = Injector(a=self.closer)
        injector.close()

        self.assertEqual([], self.call_list)
Example #12
0
    def test_close_made_in_sequence(self):
        injector = Injector(a=lambda b: self.closer('A'), b=lambda: self.closer('B'))
        injector.a
        injector.close()

        self.assertEqual(['A', 'B'], self.call_list)
Example #13
0
    def test_close_propagates_to_created_child_as_well(self):
        injector = Injector(a=self.closer('A'), b=lambda: self.closer('B'))
        injector.b
        injector.close()

        self.assertEqual(['B', 'A'], self.call_list)
Example #14
0
    def test_async_closing(self):
        injector = Injector(loop=asyncio.get_event_loop, a=self.async_closer)
        injector.a
        injector.close()

        self.assertEqual(['Default'], self.call_list)
Example #15
0
    def test_do_not_call_on_class_level(self):
        injector = Injector(a=self.closer)
        injector.close()

        self.assertEqual([], self.call_list)
Example #16
0
 def test_close_does_nothing_by_default(self):
     injector = Injector()
     injector.close()
Example #17
0
    def test_call_on_instance(self):
        injector = Injector(a=self.closer)
        injector.a
        injector.close()

        self.assertEqual(['Default'], self.call_list)
Example #18
0
 def test_close_does_nothing_by_default(self):
     injector = Injector()
     injector.close()