Skip to content

Commit

Permalink
[route_check] remove check-frr_patch mock (#2732)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stepanblyschak authored Mar 17, 2023
1 parent 2d95529 commit f27dea0
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions tests/route_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,12 @@ def test_route_check(self, mock_dbs, test_num):
with patch('sys.argv', ct_data[ARGS].split()), \
patch('route_check.subprocess.check_output') as mock_check_output:

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

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

def side_effect(*args, **kwargs):
return json.dumps(routes)

mock_check_output.side_effect = side_effect
else:
check_frr_patch.start()
mock_check_output.side_effect = side_effect

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

check_frr_patch.stop()

def test_timeout(self, mock_dbs, force_hang):
# Test timeout
ex_raised = False
Expand Down

0 comments on commit f27dea0

Please sign in to comment.