summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2018-11-08 11:52:04 +0100
committerDamjan Marion <dmarion@me.com>2018-11-08 12:47:44 +0000
commit7d6afb3c94613f6537f20087674042e8bf440a89 (patch)
tree0fb0c566d1c6c2ab710ed3df847cd5c095deaf50
parent03a3e76ff8859cff7ce9f3ae2f3030a1f90aeeb6 (diff)
make test: bfd refactor
Change-Id: I14a126521d8c8138904c8b9da05d4144c72c51a5 Signed-off-by: Klement Sekera <ksekera@cisco.com>
-rw-r--r--test/test_bfd.py2
-rw-r--r--test/vpp_papi_provider.py17
2 files changed, 14 insertions, 5 deletions
diff --git a/test/test_bfd.py b/test/test_bfd.py
index a7f2b93982b..423832b55a2 100644
--- a/test/test_bfd.py
+++ b/test/test_bfd.py
@@ -84,7 +84,7 @@ class BFDAPITestCase(VppTestCase):
session = VppBFDUDPSession(self, self.pg0, self.pg0.remote_ip4)
session.add_vpp_config()
- with self.vapi.expect_negative_api_retval():
+ with self.vapi.assert_negative_api_retval():
session.add_vpp_config()
session.remove_vpp_config()
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 9f7968bbbb7..82990bcf280 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -78,14 +78,23 @@ class VppPapiProvider(object):
def __enter__(self):
return self
- def expect_negative_api_retval(self):
- """ Expect API failure """
+ def assert_negative_api_retval(self):
+ """ Expect API failure - used with with, e.g.:
+ with self.vapi.assert_negative_api_retval():
+ self.vapi.<api call expected to fail>
+ """
self._expect_stack.append(self._expect_api_retval)
self._expect_api_retval = self._negative
return self
- def expect_zero_api_retval(self):
- """ Expect API success """
+ def assert_zero_api_retval(self):
+ """ Expect API success - used with with, e.g.:
+ with self.vapi.assert_negative_api_retval():
+ self.vapi.<api call expected to succeed>
+
+ note: this is useful only inside another with block
+ as success is the default expected value
+ """
self._expect_stack.append(self._expect_api_retval)
self._expect_api_retval = self._zero
return self