Exemple #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)
Exemple #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)
Exemple #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)
    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)
 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)
Exemple #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)
Exemple #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)
Exemple #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)
    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)
Exemple #10
0
    def test_call_on_instance(self):
        injector = Injector(a=self.closer)
        injector.a
        injector.close()

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

        self.assertEqual([], self.call_list)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #15
0
    def test_do_not_call_on_class_level(self):
        injector = Injector(a=self.closer)
        injector.close()

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

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