Merge "[FT] Add more information to `IpRouteCommandTestCase` if fails"

This commit is contained in:
Zuul 2024-01-11 19:33:23 +00:00 committed by Gerrit Code Review
commit a89b5e5772

View File

@ -931,14 +931,15 @@ class IpRouteCommandTestCase(functional_base.BaseSudoTestCase):
def _assert_route(self, ip_version, table=None, source_prefix=None, def _assert_route(self, ip_version, table=None, source_prefix=None,
cidr=None, scope=None, via=None, metric=None, cidr=None, scope=None, via=None, metric=None,
not_in=False): not_in=False):
routes = self.device.route.list_routes(ip_version, table=table)
if not_in: if not_in:
fn = lambda: cmp not in self.device.route.list_routes(ip_version, fn = lambda: cmp not in routes
table=table) msg = 'Route found: %s\nRoutes present: {routes}'.format(
msg = 'Route found: %s' routes=routes)
else: else:
fn = lambda: cmp in self.device.route.list_routes(ip_version, fn = lambda: cmp in routes
table=table) msg = 'Route not found: %s\nRoutes present: {routes}'.format(
msg = 'Route not found: %s' routes=routes)
if cidr: if cidr:
ip_version = utils.get_ip_version(cidr) ip_version = utils.get_ip_version(cidr)