[Asterisk-code-review] matcher.py: Always check final conditions (testsuite[15])
Kevin Harwell
asteriskteam at digium.com
Fri Jun 22 13:36:44 CDT 2018
Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/9280
Change subject: matcher.py: Always check final conditions
......................................................................
matcher.py: Always check final conditions
The matcher functionality was checking the final conditions only if the test
was marked as passed. Since the initial default value for that the test_case
variable is 'None' this could cause the test to fail, but not error messages
were output.
This patch makes it so the final condtions in matcher are always checked when
the test ends. Also if all final conditions pass then the test object is set
to passing (passed=true). Lastly the error message output was updated to make
it a little more readable.
Change-Id: Ibdd3041e8fb023b9396d80ec766ade934e50bcaa
---
M lib/python/asterisk/matcher.py
1 file changed, 11 insertions(+), 8 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/80/9280/1
diff --git a/lib/python/asterisk/matcher.py b/lib/python/asterisk/matcher.py
index 87c62be..958c9ad 100644
--- a/lib/python/asterisk/matcher.py
+++ b/lib/python/asterisk/matcher.py
@@ -128,9 +128,13 @@
def error(self):
"""Error out the conditional."""
- return ("\nCondition: '{0}'\nExpected >= {1} and <= {2} but "
- "received {3}".format(self.pattern, self.minimum,
- self.maximum, self.count))
+ if self.minimum == self.maximum:
+ expected = "{0}".format(self.minimum)
+ else:
+ expected = ">= {0} and <= {1}".format(self.minimum, self.maximum)
+
+ return ("\nCondition: '{0}'\nExpected {1} but received {2}".format(
+ self.pattern, expected, self.count))
class Conditions(object):
@@ -274,11 +278,10 @@
self.fail_and_stop(e)
def check_final(self):
- if self.test_object.passed:
- try:
- self.conditions.check_final()
- except ConditionError as e:
- self.fail_and_stop(e)
+ try:
+ self.test_object.set_passed(self.conditions.check_final())
+ except ConditionError as e:
+ self.fail_and_stop(e)
return self.test_object.passed
def __handle_stop(self, *args):
--
To view, visit https://gerrit.asterisk.org/9280
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdd3041e8fb023b9396d80ec766ade934e50bcaa
Gerrit-Change-Number: 9280
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180622/657df050/attachment-0001.html>
More information about the asterisk-code-review
mailing list