@@ -176,17 +176,18 @@ def test_write_json_map(builder):
176176 os .remove (dest_path )
177177
178178
179- def test_generate_json_map (builder , example_json_map ):
180- screen_path = Path ("tests/test_files/test_bob.bob" )
181- dest_path = Path ("tests/test_files/" )
179+ def test_generate_json_map (builder_with_test_files , example_json_map , test_files ):
180+ screen_path , dest_path = test_files
182181
183182 # We don't want to access the _get_action_group function in this test
184183 with patch ("techui_builder.builder._get_action_group" ) as mock_get_action_group :
185184 mock_xml = objectify .Element ("action" )
186185 mock_xml ["file" ] = "test_child_bob.bob"
187186 mock_get_action_group .return_value = mock_xml
188187
189- test_json_map = builder ._generate_json_map (screen_path , dest_path )
188+ test_json_map = builder_with_test_files ._generate_json_map (
189+ screen_path .absolute (), dest_path
190+ )
190191
191192 assert test_json_map == example_json_map
192193
@@ -204,9 +205,10 @@ def test_generate_json_map(builder, example_json_map):
204205# assert test_json_map == example_json_map
205206
206207
207- def test_generate_json_map_get_macros (builder , example_json_map ):
208- screen_path = Path ("tests/test_files/test_bob.bob" )
209- dest_path = Path ("tests/test_files/" )
208+ def test_generate_json_map_get_macros (
209+ builder_with_test_files , example_json_map , test_files
210+ ):
211+ screen_path , dest_path = test_files
210212
211213 # Set a custom macro to test against
212214 example_json_map .children [0 ].macros = {"macro" : "value" }
@@ -220,43 +222,49 @@ def test_generate_json_map_get_macros(builder, example_json_map):
220222 macros ["macro" ] = "value"
221223 mock_get_action_group .return_value = mock_xml
222224
223- test_json_map = builder ._generate_json_map (screen_path , dest_path )
225+ test_json_map = builder_with_test_files ._generate_json_map (
226+ screen_path , dest_path
227+ )
224228
225229 assert test_json_map == example_json_map
226230
227231
228- def test_generate_json_map_visited_node (builder , example_json_map ):
229- screen_path = Path ("tests/test_files/test_bob.bob" )
230- dest_path = Path ("tests/test_files/" )
232+ def test_generate_json_map_visited_node (
233+ builder_with_test_files , example_json_map , test_files
234+ ):
235+ screen_path , dest_path = test_files
231236
232237 visited = {screen_path }
233238 # Clear children as they will never be read
234239 example_json_map .children = []
235240 # Need to set this to true too
236241 example_json_map .duplicate = True
237242
238- test_json_map = builder ._generate_json_map (screen_path , dest_path , visited )
243+ test_json_map = builder_with_test_files ._generate_json_map (
244+ screen_path , dest_path , visited
245+ )
239246
240247 assert test_json_map == example_json_map
241248
242249
243- def test_generate_json_map_xml_parse_error (builder ):
244- screen_path = Path ("tests/test_files/test_bob_bad.bob" )
245- dest_path = Path ( "tests/ test_files/" )
250+ def test_generate_json_map_xml_parse_error (builder_with_test_files , test_files ):
251+ screen_path = Path ("tests/test_files/test_bob_bad.bob" ). absolute ()
252+ _ , dest_path = test_files
246253
247- test_json_map = builder ._generate_json_map (screen_path , dest_path )
254+ test_json_map = builder_with_test_files ._generate_json_map (screen_path , dest_path )
248255
249256 assert test_json_map .error .startswith ("XML parse error:" )
250257
251258
252- def test_generate_json_map_other_exception (builder ):
253- screen_path = Path ("tests/test_files/test_bob.bob" )
254- dest_path = Path ("tests/test_files/" )
259+ def test_generate_json_map_other_exception (builder_with_test_files , test_files ):
260+ screen_path , dest_path = test_files
255261
256262 with patch ("techui_builder.builder._get_action_group" ) as mock_get_action_group :
257263 mock_get_action_group .side_effect = Exception ("Some exception" )
258264
259- test_json_map = builder ._generate_json_map (screen_path , dest_path )
265+ test_json_map = builder_with_test_files ._generate_json_map (
266+ screen_path , dest_path
267+ )
260268
261269 assert test_json_map .error != ""
262270
@@ -265,7 +273,7 @@ def test_serialise_json_map(example_json_map):
265273 json_ = _serialise_json_map (example_json_map ) # type: ignore
266274
267275 assert json_ == {
268- "file" : "tests/test_files/ test_bob.bob" ,
276+ "file" : "test_bob.bob" ,
269277 "children" : [{"file" : "test_child_bob.bob" , "exists" : False }],
270278 }
271279
0 commit comments