From 5536e4e18bbb528cf844d2c81c6a8f66dcf396bf Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Mon, 14 Sep 2020 06:47:53 +0000 Subject: [PATCH] [crm] Fix test_crm teardown If fixtures failed during setup, there will no `rep_call` attribute for `item`. Checking the setup's success first to guarantee this. Signed-off-by: Longxiang Lyu --- tests/crm/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/crm/conftest.py b/tests/crm/conftest.py index a970a3f6dc0..654c65555fc 100755 --- a/tests/crm/conftest.py +++ b/tests/crm/conftest.py @@ -21,7 +21,7 @@ def pytest_runtest_teardown(item, nextitem): restore_cmd = "bash -c \"sonic-db-cli CONFIG_DB hset 'CRM|Config' {threshold_name}_threshold_type percentage \ && sonic-db-cli CONFIG_DB hset 'CRM|Config' {threshold_name}_high_threshold {high} \ && sonic-db-cli CONFIG_DB hset 'CRM|Config' {threshold_name}_low_threshold {low}\"" - if not item.rep_call.skipped: + if item.rep_setup.passed and not item.rep_call.skipped: # Restore CRM threshods if crm_threshold_name: crm_thresholds = item.funcargs["crm_thresholds"]