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>
diff --git a/test/test_bfd.py b/test/test_bfd.py
index b56df33..d047b5a 100644
--- a/test/test_bfd.py
+++ b/test/test_bfd.py
@@ -42,14 +42,11 @@
         """ 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 """