File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed 
infrahub_sdk/pytest_plugin/items Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 1+ Fix relative imports for the pytest plugin, note that the relative imports can't be at the top level of the repository alongside .infrahub.yml. They have to be located within a subfolder.
Original file line number Diff line number Diff line change 11from  __future__ import  annotations 
22
33import  asyncio 
4+ from  pathlib  import  Path 
45from  typing  import  TYPE_CHECKING , Any , Optional 
56
67import  ujson 
78from  httpx  import  HTTPStatusError 
89
9- from  ...checks  import  get_check_class_instance 
1010from  ..exceptions  import  CheckDefinitionError , CheckResultError 
1111from  ..models  import  InfrahubTestExpectedResult 
1212from  .base  import  InfrahubItem 
@@ -33,10 +33,10 @@ def __init__(
3333        self .check_instance : InfrahubCheck 
3434
3535    def  instantiate_check (self ) ->  None :
36-         self .check_instance  =  get_check_class_instance (
37-             check_config = self .resource_config ,  # type: ignore[arg-type] 
38-             search_path = self .session .infrahub_config_path .parent ,  # type: ignore[attr-defined] 
36+         relative_path  =  (
37+             str (self .resource_config .file_path .parent ) if  self .resource_config .file_path .parent  !=  Path () else  None   # type: ignore[attr-defined] 
3938        )
39+         self .check_instance  =  self .resource_config .load_class (import_root = str (Path .cwd ()), relative_path = relative_path )  # type: ignore[attr-defined] 
4040
4141    def  run_check (self , variables : dict [str , Any ]) ->  Any :
4242        self .instantiate_check ()
Original file line number Diff line number Diff line change 11from  __future__ import  annotations 
22
33import  asyncio 
4+ from  pathlib  import  Path 
45from  typing  import  TYPE_CHECKING , Any , Optional 
56
67import  ujson 
78from  httpx  import  HTTPStatusError 
89
9- from  ...transforms  import  get_transform_class_instance 
1010from  ..exceptions  import  OutputMatchError , PythonTransformDefinitionError 
1111from  ..models  import  InfrahubTestExpectedResult 
1212from  .base  import  InfrahubItem 
@@ -33,9 +33,11 @@ def __init__(
3333        self .transform_instance : InfrahubTransform 
3434
3535    def  instantiate_transform (self ) ->  None :
36-         self .transform_instance  =  get_transform_class_instance (
37-             transform_config = self .resource_config ,  # type: ignore[arg-type] 
38-             search_path = self .session .infrahub_config_path .parent ,  # type: ignore[attr-defined] 
36+         relative_path  =  (
37+             str (self .resource_config .file_path .parent ) if  self .resource_config .file_path .parent  !=  Path () else  None   # type: ignore[attr-defined] 
38+         )
39+         self .transform_instance  =  self .resource_config .load_class (  # type: ignore[attr-defined] 
40+             import_root = str (Path .cwd ()), relative_path = relative_path 
3941        )
4042
4143    def  run_transform (self , variables : dict [str , Any ]) ->  Any :
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments