Skip to content

Commit 94c9904

Browse files
[watchdog] Fix python syntax error in test_watchdog.py (#2022)
* Fix python syntax issues in test_watchdog.py Change-Id: I93a51f80ac8a6fc72d408031c5f0404e748ec14d * Fix tuple index out of range issue Change-Id: I45e46d926b5a8334d3dbfa8f47e1d42256e483b1
1 parent f5d9eaa commit 94c9904

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/platform_tests/api/test_watchdog.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_arm_disarm_states(self, duthost, localhost, platform_api_conn, conf):
8585

8686
if self.expect(remaining_time is not None, "Failed to get the remaining time of watchdog"):
8787
if self.expect(isinstance(remaining_time, int), "remaining_time appears incorrect"):
88-
self.expect(remaining_time <= watchdog_timeout, "Watchdog remaining_time {} seconds appears wrong compared to watchdog timeout {} seocnds".format(remaining_time))
88+
self.expect(remaining_time <= watchdog_timeout, "Watchdog remaining_time {} seconds appears wrong compared to watchdog timeout {} seocnds".format(remaining_time, watchdog_timeout))
8989

9090
watchdog_status = watchdog.disarm(platform_api_conn)
9191
if self.expect(watchdog_status is not None, "Watchdog.disarm is not supported"):
@@ -119,7 +119,7 @@ def test_remaining_time(self, duthost, platform_api_conn, conf):
119119

120120
if self.expect(actual_timeout >= watchdog_timeout, "watchdog arm with {} seconds failed".format(watchdog_timeout)):
121121
if self.expect(remaining_time > 0, "Remaining_time {} seconds is not valid".format(remaining_time)):
122-
self.expect(remaining_time <= actual_timeout, "Remaining_time {} seconds should be less than watchdog armed timeout {} seconds".format(remaining_timeout, actual_timeout))
122+
self.expect(remaining_time <= actual_timeout, "Remaining_time {} seconds should be less than watchdog armed timeout {} seconds".format(remaining_time, actual_timeout))
123123

124124
remaining_time = watchdog.get_remaining_time(platform_api_conn)
125125
time.sleep(TEST_WAIT_TIME_SECONDS)
@@ -138,8 +138,8 @@ def test_periodic_arm(self, duthost, platform_api_conn, conf):
138138
actual_timeout_new = watchdog.arm(platform_api_conn, watchdog_timeout)
139139
remaining_time_new = watchdog.get_remaining_time(platform_api_conn)
140140

141-
self.expect(actual_timeout == actual_timeout_new, "{}: new watchdog timeout {} seconds setting should be same as the previous actual watchdog timeout {} seconds".format(test_periodic_arm.__name__, actual_timeout_new, actual_timeout))
142-
self.expect(remaining_time_new > remaining_time, "{}: new remaining timeout {} seconds should be greater than the previous remaining timeout {} seconds by {} seconds".format(test_periodic_arm.__name__, remaining_time_new, remaining_time, TEST_WAIT_TIME_SECONDS))
141+
self.expect(actual_timeout == actual_timeout_new, "{}: new watchdog timeout {} seconds setting should be same as the previous actual watchdog timeout {} seconds".format(self.test_periodic_arm.__name__, actual_timeout_new, actual_timeout))
142+
self.expect(remaining_time_new > remaining_time, "{}: new remaining timeout {} seconds should be greater than the previous remaining timeout {} seconds by {} seconds".format(self.test_periodic_arm.__name__, remaining_time_new, remaining_time, TEST_WAIT_TIME_SECONDS))
143143
self.assert_expectations()
144144

145145
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
@@ -155,9 +155,9 @@ def test_arm_different_timeout_greater(self, duthost, platform_api_conn, conf):
155155
actual_timeout = watchdog.arm(platform_api_conn, watchdog_timeout)
156156
remaining_time = watchdog.get_remaining_time(platform_api_conn)
157157
actual_timeout_greater = watchdog.arm(platform_api_conn, watchdog_timeout_greater)
158-
self.expect(actual_timeout < actual_timeout_greater, "{}: 1st timeout {} seconds should be less than 2nd timeout {} seconds".format(test_arm_different_timeout_greater.__name__, actual_timeout, actual_timeout_greater))
158+
self.expect(actual_timeout < actual_timeout_greater, "{}: 1st timeout {} seconds should be less than 2nd timeout {} seconds".format(self.test_arm_different_timeout_greater.__name__, actual_timeout, actual_timeout_greater))
159159
remaining_time_greater = watchdog.get_remaining_time(platform_api_conn)
160-
self.expect(remaining_time_greater > remaining_time, "{}: 2nd remaining_timeout {} seconds should be greater than 1st remaining timeout {} seconds".format(test_arm_different_timeout_greater.__name__, remaining_time_greater, remaining_time))
160+
self.expect(remaining_time_greater > remaining_time, "{}: 2nd remaining_timeout {} seconds should be greater than 1st remaining timeout {} seconds".format(self.test_arm_different_timeout_greater.__name__, remaining_time_greater, remaining_time))
161161
self.assert_expectations()
162162

163163
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
@@ -174,9 +174,9 @@ def test_arm_different_timeout_smaller(self, duthost, platform_api_conn, conf):
174174
remaining_time = watchdog.get_remaining_time(platform_api_conn)
175175
actual_timeout_smaller = watchdog.arm(platform_api_conn, watchdog_timeout_smaller)
176176

177-
self.expect(actual_timeout > actual_timeout_smaller, "{}: 1st timeout {} seconds should be greater than 2nd timeout {} seconds".format(test_arm_different_timeout_smaller.__name__, actual_timeout, actual_timeout_smaller))
177+
self.expect(actual_timeout > actual_timeout_smaller, "{}: 1st timeout {} seconds should be greater than 2nd timeout {} seconds".format(self.test_arm_different_timeout_smaller.__name__, actual_timeout, actual_timeout_smaller))
178178
remaining_time_smaller = watchdog.get_remaining_time(platform_api_conn)
179-
self.expect(remaining_time_smaller < remaining_time, "{}: 2nd remaining_timeout {} seconds should be less than 1st remaining timeout {} seconds".format(test_arm_different_timeout_smaller.__name__, remaining_time_smaller, remaining_time))
179+
self.expect(remaining_time_smaller < remaining_time, "{}: 2nd remaining_timeout {} seconds should be less than 1st remaining timeout {} seconds".format(self.test_arm_different_timeout_smaller.__name__, remaining_time_smaller, remaining_time))
180180
self.assert_expectations()
181181

182182
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
@@ -189,7 +189,7 @@ def test_arm_too_big_timeout(self, duthost, platform_api_conn, conf):
189189
if watchdog_timeout is None:
190190
pytest.skip('"too_big_timeout" parameter is required for this test case')
191191
actual_timeout = watchdog.arm(platform_api_conn, watchdog_timeout)
192-
self.expect(actual_timeout == -1, "{}: Watchdog should be disarmed, but returned timeout of {} seconds".format(test_arm_too_big_timeout.__name__, watchdog_timeout))
192+
self.expect(actual_timeout == -1, "{}: Watchdog should be disarmed, but returned timeout of {} seconds".format(self.test_arm_too_big_timeout.__name__, watchdog_timeout))
193193
self.assert_expectations()
194194

195195
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
@@ -198,6 +198,6 @@ def test_arm_negative_timeout(self, duthost, platform_api_conn):
198198

199199
watchdog_timeout = -1
200200
actual_timeout = watchdog.arm(platform_api_conn, watchdog_timeout)
201-
self.expect(actual_timeout == -1, "{}: Watchdog should be disarmed, but returned timeout of {} seconds".format(test_arm_negative_timeout.__name__, watchdog_timeout))
201+
self.expect(actual_timeout == -1, "{}: Watchdog should be disarmed, but returned timeout of {} seconds".format(self.test_arm_negative_timeout.__name__, watchdog_timeout))
202202
self.assert_expectations()
203203

0 commit comments

Comments
 (0)