File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed 
infrahub_sdk/pytest_plugin Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 1+ import  os 
12from  pathlib  import  Path 
23from  typing  import  Optional , Union 
34
@@ -34,6 +35,7 @@ def pytest_addoption(parser: Parser) -> None:
3435        action = "store" ,
3536        dest = "infrahub_key" ,
3637        metavar = "INFRAHUB_TESTS_API_KEY" ,
38+         default = os .getenv ("INFRAHUB_API_TOKEN" ),
3739        help = "Key to use when querying the Infrahub instance for live testing" ,
3840    )
3941    group .addoption (
@@ -74,12 +76,11 @@ def pytest_sessionstart(session: Session) -> None:
7476        "default_branch" : session .config .option .infrahub_branch ,
7577    }
7678    if  hasattr (session .config .option , "infrahub_key" ):
77-         client_config   =  { "api_token" :  session .config .option .infrahub_key } 
79+         client_config [ "api_token" ]  =   session .config .option .infrahub_key 
7880    elif  hasattr (session .config .option , "infrahub_username" ) and  hasattr (session .config .option , "infrahub_password" ):
79-         client_config  =  {
80-             "username" : session .config .option .infrahub_username ,
81-             "password" : session .config .option .infrahub_password ,
82-         }
81+         client_config .pop ("api_token" )
82+         client_config ["username" ] =  session .config .option .infrahub_username 
83+         client_config ["password" ] =  session .config .option .infrahub_password 
8384
8485    infrahub_client  =  InfrahubClientSync (config = client_config )
8586    session .infrahub_client  =  infrahub_client   # type: ignore[attr-defined] 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments