aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_bfd.py
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2017-01-25 08:00:40 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-01-25 15:57:14 +0000
commite0545ef85ab136a51c42319935834d08a35eaa90 (patch)
tree4ccb026e7b6cfbbdd6e76a0dd35e0e5fae1e7f07 /test/test_bfd.py
parentd2c97d988b2fbc28f0905d1826b428967d09348a (diff)
make test: elegantly handle expected API failures
Allow writing simple code to expect API failure when needed: with self.vapi.expect_negative_api_retval(): do_api_call() # expected to return negative retval in response Change-Id: Id58d91d9ce38d20ad6ff7a43a6897e79ffbd23bf Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test/test_bfd.py')
-rw-r--r--test/test_bfd.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/test/test_bfd.py b/test/test_bfd.py
index b56df3398d5..d047b5a3b99 100644
--- a/test/test_bfd.py
+++ b/test/test_bfd.py
@@ -42,14 +42,11 @@ class BFDAPITestCase(VppTestCase):
""" create the same BFD session twice (negative case) """
session = VppBFDUDPSession(self, self.pg0, self.pg0.remote_ip4)
session.add_vpp_config()
- try:
+
+ with self.vapi.expect_negative_api_retval():
session.add_vpp_config()
- except:
- session.remove_vpp_config()
- return
+
session.remove_vpp_config()
- raise Exception("Expected failure while adding duplicate "
- "configuration")
def test_add_two(self):
""" create two BFD sessions """