@@ -71,6 +71,9 @@ def create_test_run(request) -> typing.Generator[typing.Tuple[sv_run.Run, dict],
71
71
72
72
@pytest .fixture
73
73
def create_test_run_offline (mocker : pytest_mock .MockerFixture , request , monkeypatch : pytest .MonkeyPatch ) -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
74
+ def testing_exit (status : int ) -> None :
75
+ raise SystemExit (status )
76
+ mocker .patch ("os._exit" , testing_exit )
74
77
with tempfile .TemporaryDirectory () as temp_d :
75
78
monkeypatch .setenv ("SIMVUE_OFFLINE_DIRECTORY" , temp_d )
76
79
with sv_run .Run ("offline" ) as run :
@@ -79,7 +82,10 @@ def create_test_run_offline(mocker: pytest_mock.MockerFixture, request, monkeypa
79
82
80
83
81
84
@pytest .fixture
82
- def create_plain_run (request ) -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
85
+ def create_plain_run (request , mocker : pytest_mock .MockFixture ) -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
86
+ def testing_exit (status : int ) -> None :
87
+ raise SystemExit (status )
88
+ mocker .patch ("os._exit" , testing_exit )
83
89
with sv_run .Run () as run :
84
90
yield run , setup_test_run (run , False , request )
85
91
clear_out_files ()
@@ -102,7 +108,10 @@ def create_plain_run_offline(mocker: pytest_mock.MockerFixture, request, monkeyp
102
108
103
109
104
110
@pytest .fixture
105
- def create_run_object () -> sv_api_obj .Run :
111
+ def create_run_object (mocker : pytest_mock .MockFixture ) -> sv_api_obj .Run :
112
+ def testing_exit (status : int ) -> None :
113
+ raise SystemExit (status )
114
+ mocker .patch ("os._exit" , testing_exit )
106
115
_fix_use_id : str = str (uuid .uuid4 ()).split ('-' , 1 )[0 ]
107
116
_folder = sv_api_obj .Folder .new (path = f"/simvue_unit_testing/{ _fix_use_id } " )
108
117
_folder .commit ()
@@ -114,22 +123,24 @@ def create_run_object() -> sv_api_obj.Run:
114
123
115
124
def setup_test_run (run : sv_run .Run , create_objects : bool , request : pytest .FixtureRequest , created_only : bool = False ):
116
125
fix_use_id : str = str (uuid .uuid4 ()).split ('-' , 1 )[0 ]
126
+ _test_name : str = request .node .name .replace ("[" , "_" ).replace ("]" , "" )
117
127
TEST_DATA = {
118
128
"event_contains" : "sent event" ,
119
129
"metadata" : {
120
130
"test_engine" : "pytest" ,
121
- "test_identifier" : fix_use_id
131
+ "test_identifier" : f" { _test_name } _ { fix_use_id } "
122
132
},
123
133
"folder" : f"/simvue_unit_testing/{ fix_use_id } " ,
124
- "tags" : ["simvue_client_unit_tests" , request . node . name . replace ( "[" , "_" ). replace ( "]" , "" ) ]
134
+ "tags" : ["simvue_client_unit_tests" , _test_name ]
125
135
}
126
136
127
137
if os .environ .get ("CI" ):
128
138
TEST_DATA ["tags" ].append ("ci" )
129
139
130
140
run .config (suppress_errors = False )
141
+ run ._heartbeat_interval = 1
131
142
run .init (
132
- name = f"test_run_ { TEST_DATA ['metadata' ]['test_identifier' ]} _ { uuid . uuid4 () } " ,
143
+ name = TEST_DATA ['metadata' ]['test_identifier' ],
133
144
tags = TEST_DATA ["tags" ],
134
145
folder = TEST_DATA ["folder" ],
135
146
visibility = "tenant" if os .environ .get ("CI" ) else None ,
0 commit comments