11import unittest
2- import warnings
32from abc import (
43 ABC ,
54)
5+ from contextlib import (
6+ suppress ,
7+ )
68from itertools import (
79 starmap ,
810)
1113)
1214from typing import (
1315 Any ,
16+ Union ,
1417)
1518from uuid import (
1619 uuid4 ,
2629)
2730from .injections import (
2831 DependencyInjector ,
32+ InjectableMixin ,
2933)
3034from .pools import (
3135 PoolFactory ,
@@ -42,37 +46,32 @@ def setUp(self) -> None:
4246 self .injector = DependencyInjector (self .config , self .get_injections ())
4347 self .injector .wire_injections ()
4448
45- def get_config (self ):
46- """ "TODO"""
49+ def get_config (self ) -> Config :
4750 return Config (self .get_config_file_path ())
4851
4952 def get_config_file_path (self ) -> Path :
50- """TODO"""
51- warnings .warn (
52- "`CONFIG_FILE_PATH` variable has been deprecated by `get_config_file_path` method" ,
53- DeprecationWarning ,
54- )
5553 return self .CONFIG_FILE_PATH
5654
57- def get_injections (self ):
55+ def get_injections (self ) -> list [ Union [ InjectableMixin , type [ InjectableMixin ], str ]] :
5856 return []
5957
60- async def asyncSetUp (self ):
58+ async def asyncSetUp (self ) -> None :
6159 await super ().asyncSetUp ()
6260 await self .injector .setup_injections ()
6361
64- async def asyncTearDown (self ):
62+ async def asyncTearDown (self ) -> None :
6563 await self .injector .destroy_injections ()
6664 await super ().asyncTearDown ()
6765
6866 def tearDown (self ) -> None :
6967 self .injector .unwire_injections ()
7068 super ().tearDown ()
7169
72- def __getattr__ (self , item ) :
70+ def __getattr__ (self , item : str ) -> Any :
7371 if item != "injector" :
74- return getattr (self .injector , item )
75- raise AttributeError
72+ with suppress (Exception ):
73+ return getattr (self .injector , item )
74+ raise AttributeError (f"{ type (self ).__name__ !r} does not contain the { item !r} attribute." )
7675
7776
7877class PostgresAsyncTestCase (MinosTestCase , ABC ):
@@ -95,7 +94,7 @@ def setUp(self):
9594
9695 super ().setUp ()
9796
98- def get_config (self ):
97+ def get_config (self ) -> Config :
9998 return Config (
10099 self .get_config_file_path (),
101100 repository_database = self .repository_db ["database" ],
@@ -106,7 +105,7 @@ def get_config(self):
106105 snapshot_user = self .snapshot_db ["user" ],
107106 )
108107
109- def get_injections (self ):
108+ def get_injections (self ) -> list [ Union [ InjectableMixin , type [ InjectableMixin ], str ]] :
110109 return [PoolFactory .from_config (self .config , default_classes = {"database" : DatabaseClientPool })]
111110
112111 async def asyncSetUp (self ):
0 commit comments