File tree Expand file tree Collapse file tree 2 files changed +9
-11
lines changed 
examples/miniapps/fastapi-simple Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change 1- import  sys 
2- 
31from  fastapi  import  FastAPI , Depends 
42from  dependency_injector  import  containers , providers 
5- from  dependency_injector .wiring  import  inject ,  Provide 
3+ from  dependency_injector .wiring  import  Provide ,  inject 
64
75
86class  Service :
97 async  def  process (self ) ->  str :
10-  return  'Ok' 
8+  return  "OK" 
119
1210
1311class  Container (containers .DeclarativeContainer ):
@@ -18,12 +16,12 @@ class Container(containers.DeclarativeContainer):
1816app  =  FastAPI ()
1917
2018
21- @app .api_route ('/' ) 
19+ @app .api_route ("/" ) 
2220@inject  
2321async  def  index (service : Service  =  Depends (Provide [Container .service ])):
2422 result  =  await  service .process ()
25-  return  {' result' result }
23+  return  {" result" result }
2624
2725
2826container  =  Container ()
29- container .wire (modules = [sys . modules [ __name__ ] ])
27+ container .wire (modules = [__name__ ])
Original file line number Diff line number Diff line change 88
99@pytest .fixture  
1010def  client (event_loop ):
11-  client  =  AsyncClient (app = app , base_url = ' http://test' 
11+  client  =  AsyncClient (app = app , base_url = " http://test" 
1212 yield  client 
1313 event_loop .run_until_complete (client .aclose ())
1414
1515
1616@pytest .mark .asyncio  
1717async  def  test_index (client ):
1818 service_mock  =  mock .AsyncMock (spec = Service )
19-  service_mock .process .return_value  =  ' Foo' 
19+  service_mock .process .return_value  =  " Foo" 
2020
2121 with  container .service .override (service_mock ):
22-  response  =  await  client .get ('/' )
22+  response  =  await  client .get ("/" )
2323
2424 assert  response .status_code  ==  200 
25-  assert  response .json () ==  {' result' :  ' Foo' 
25+  assert  response .json () ==  {" result" :  " Foo" 
                         You can’t perform that action at this time. 
           
                  
0 commit comments