summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-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