Hi, when doing API tests, sometimes it's expected that API fails. For example, one might test adding the same configuration twice, or removing non-existent configuration, expecting failure.
With my recent change https://gerrit.fd.io/r/#/c/4875/ merged, it's possible to easily write these scenarios using a simple: def test_api_fail(self): ... with self.vapi.expect_negative_api_retval(): self.vapi.api_call() # expected to fail self.vapi.other_api_call() # expected to pass the expect_negative_api_retval() changes internal state to expect failures, which is reverted back once the 'with' context is left. There is also expect_zero_api_retval() mostly for sake of completness, so one might write the above code also this way: def test_api_fail(self): ... self.vapi.expect_negative_api_retval() self.vapi.api_call() # expected to fail self.vapi.expect_zero_api_retval() self.vapi.other_api_call() # expected to pass I think the first one is simpler, more readable and less error prone (because of the guaranteed expectation rollback). Thanks, Klement _______________________________________________ vpp-dev mailing list vpp-dev@lists.fd.io https://lists.fd.io/mailman/listinfo/vpp-dev