Skip to content

Commit f27dea0

Browse files
[route_check] remove check-frr_patch mock (#2732)
The test fails with python3.7 (works in 3.9) when stopping patch which hasn't been started. We can always mock check_output call and if FRR_ROUTES is not defined return empty dictionary by the mock. #### What I did Removed check_frr_patch mock to fix UT running on python3.7 #### How I did it Removed the mock #### How to verify it Run unit test in stretch env
1 parent 2d95529 commit f27dea0

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

tests/route_check_test.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,12 @@ def test_route_check(self, mock_dbs, test_num):
277277
with patch('sys.argv', ct_data[ARGS].split()), \
278278
patch('route_check.subprocess.check_output') as mock_check_output:
279279

280-
check_frr_patch = patch('route_check.check_frr_pending_routes', lambda: [])
280+
routes = ct_data.get(FRR_ROUTES, {})
281281

282-
if FRR_ROUTES in ct_data:
283-
routes = ct_data[FRR_ROUTES]
282+
def side_effect(*args, **kwargs):
283+
return json.dumps(routes)
284284

285-
def side_effect(*args, **kwargs):
286-
return json.dumps(routes)
287-
288-
mock_check_output.side_effect = side_effect
289-
else:
290-
check_frr_patch.start()
285+
mock_check_output.side_effect = side_effect
291286

292287
ret, res = route_check.main()
293288
expect_ret = ct_data[RET] if RET in ct_data else 0
@@ -299,8 +294,6 @@ def side_effect(*args, **kwargs):
299294
assert ret == expect_ret
300295
assert res == expect_res
301296

302-
check_frr_patch.stop()
303-
304297
def test_timeout(self, mock_dbs, force_hang):
305298
# Test timeout
306299
ex_raised = False

0 commit comments

Comments
 (0)