-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update documentation for the default repeat limit, add constant for r…
…etrying "forever". Originally the default was to repeat forever, which was changed to 3 at some point, without updating the documentation. FUTURE_COPYBARA_INTEGRATE_REVIEW=#1176 from google:dependabot/pip/pip-9d732ab251 f1af8f8 PiperOrigin-RevId: 691477516
- Loading branch information
1 parent
e980042
commit fc82e95
Showing
3 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2022 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Unit tests for phase_executor module.""" | ||
|
||
import unittest | ||
|
||
import openhtf | ||
from openhtf.core import phase_descriptor | ||
|
||
|
||
class PhaseExecutorTest(unittest.TestCase): | ||
|
||
def _run_repeating_phase(self, phase_options, expected_call_count): | ||
call_count = 0 | ||
|
||
@phase_options | ||
def repeating_phase(): | ||
nonlocal call_count | ||
call_count += 1 | ||
if call_count < phase_descriptor.DEFAULT_REPEAT_LIMIT + 1: | ||
return phase_descriptor.PhaseResult.REPEAT | ||
return phase_descriptor.PhaseResult.STOP | ||
|
||
test = openhtf.Test(repeating_phase) | ||
test.execute() | ||
self.assertEqual(call_count, expected_call_count) | ||
|
||
def test_execute_phase_with_repeat_limit_unspecified_uses_default_limit(self): | ||
self._run_repeating_phase( | ||
openhtf.PhaseOptions(), | ||
expected_call_count=phase_descriptor.DEFAULT_REPEAT_LIMIT, | ||
) | ||
|
||
def test_execute_phase_with_repeat_limit_none_uses_default_limit(self): | ||
self._run_repeating_phase( | ||
openhtf.PhaseOptions(repeat_limit=None), | ||
expected_call_count=phase_descriptor.DEFAULT_REPEAT_LIMIT, | ||
) | ||
|
||
def test_execute_phase_with_repeat_limit_max_exceeds_default_limit(self): | ||
self._run_repeating_phase( | ||
openhtf.PhaseOptions(repeat_limit=phase_descriptor.MAX_REPEAT_LIMIT), | ||
expected_call_count=phase_descriptor.DEFAULT_REPEAT_LIMIT + 1, | ||
) |