aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-03-06 08:23:58 -0800
committerOle Trøan <otroan@employees.org>2019-03-07 22:29:00 +0000
commitea2450fa2d1e8ba0295ea9861a404796100dad1e (patch)
treeabc11c27a65c8af6f839ea0af73cac5560933c3b /test
parent4a4cea02ef82793232cab4d878baca5cf0134966 (diff)
VPP-1508: Python3 tests. Explicitly specify string formatting.
.format() doesn't understand what to do with binary values by default. Specify that we expect coersion to string. Change-Id: Ic4b697f70852124dc85ab231f76b7934d0d71f4d Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'test')
-rw-r--r--test/framework.py2
-rw-r--r--test/lisp.py4
-rw-r--r--test/log.py2
-rw-r--r--test/test_acl_plugin_macip.py3
-rw-r--r--test/test_classifier.py12
-rw-r--r--test/test_classifier_ip6.py12
-rw-r--r--test/test_classify_l2_acl.py8
-rw-r--r--test/test_ip4.py4
-rw-r--r--test/test_lisp.py2
-rw-r--r--test/test_p2p_ethernet.py3
-rw-r--r--test/test_srv6.py4
11 files changed, 29 insertions, 27 deletions
diff --git a/test/framework.py b/test/framework.py
index 38a49859e14..dc7d6107722 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -1163,7 +1163,7 @@ class VppTestResult(unittest.TestResult):
if isinstance(test, unittest.suite._ErrorHolder):
test_name = str(test)
else:
- test_name = "'{}' ({})".format(
+ test_name = "'{!s}' ({!s})".format(
get_testcase_doc_name(test), test.id())
self.current_test_case_info.core_crash_test = test_name
self.core_crash_test_cases_info.add(
diff --git a/test/lisp.py b/test/lisp.py
index b1a185ab713..339493cb457 100644
--- a/test/lisp.py
+++ b/test/lisp.py
@@ -135,7 +135,7 @@ class LispEID(object):
self.prefix_length = 0
self.data_length = 6
else:
- raise Exception('Unsupported EID format {}!'.format(eid))
+ raise Exception('Unsupported EID format {!s}!'.format(eid))
def __str__(self):
if self.eid_type == LispEIDType.IP4:
@@ -144,7 +144,7 @@ class LispEID(object):
return socket.inet_pton(socket.AF_INET6, self.eid_address)
elif self.eid_type == LispEIDType.MAC:
return Exception('Unimplemented')
- raise Exception('Unknown EID type {}!'.format(self.eid_type))
+ raise Exception('Unknown EID type {!s}!'.format(self.eid_type))
class VppLispMapping(VppObject):
diff --git a/test/log.py b/test/log.py
index de127fefb27..b0254f9abee 100644
--- a/test/log.py
+++ b/test/log.py
@@ -57,7 +57,7 @@ def get_logger(name):
def get_parallel_logger(stream):
- logger = logging.getLogger('parallel_logger_{}'.format(stream))
+ logger = logging.getLogger('parallel_logger_{!s}'.format(stream))
logger.propagate = False
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(stream)
diff --git a/test/test_acl_plugin_macip.py b/test/test_acl_plugin_macip.py
index f277076aaab..d2d684abc11 100644
--- a/test/test_acl_plugin_macip.py
+++ b/test/test_acl_plugin_macip.py
@@ -237,7 +237,8 @@ class MethodHolder(VppTestCase):
mac = ':'.join(re.findall('..', '{:02x}'.format(
src_mac))[:3])+":00:00:00"
else:
- mac = ':'.join(re.findall('..', '{:02x}'.format(src_mac)))
+ mac = ':'.join(re.findall(
+ '..', '{:02x}'.format(src_mac)))
if ip_type == self.EXACT_IP:
ip4[3] = random.randint(100, 200)
diff --git a/test/test_classifier.py b/test/test_classifier.py
index 8d4bde8e730..c0b85468170 100644
--- a/test/test_classifier.py
+++ b/test/test_classifier.py
@@ -202,7 +202,7 @@ class TestClassifier(VppTestCase):
:param str dst_port: destination port number <0-ffff>
"""
- return ('{:0>20}{:0>12}{:0>8}{:0>4}{:0>4}'.format(
+ return ('{!s:0>20}{!s:0>12}{!s:0>8}{!s:0>4}{!s:0>4}'.format(
proto, src_ip, dst_ip, src_port, dst_port)).rstrip('0')
@staticmethod
@@ -221,7 +221,7 @@ class TestClassifier(VppTestCase):
if dst_ip:
dst_ip = binascii.hexlify(socket.inet_aton(dst_ip))
- return ('{:0>20}{:0>12}{:0>8}{:0>4}{:0>4}'.format(
+ return ('{!s:0>20}{!s:0>12}{!s:0>8}{!s:0>4}{!s:0>4}'.format(
hex(proto)[2:], src_ip, dst_ip, hex(src_port)[2:],
hex(dst_port)[2:])).rstrip('0')
@@ -234,8 +234,8 @@ class TestClassifier(VppTestCase):
:param str ether_type: ethernet type <0-ffff>
"""
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
@staticmethod
def build_mac_match(dst_mac='', src_mac='', ether_type=''):
@@ -250,8 +250,8 @@ class TestClassifier(VppTestCase):
if src_mac:
src_mac = src_mac.replace(':', '')
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
def create_classify_table(self, key, mask, data_offset=0):
"""Create Classify Table
diff --git a/test/test_classifier_ip6.py b/test/test_classifier_ip6.py
index f6d12c7b3db..30ad48c8531 100644
--- a/test/test_classifier_ip6.py
+++ b/test/test_classifier_ip6.py
@@ -168,7 +168,7 @@ class TestClassifier(VppTestCase):
:param str dst_port: destination port number <0-ffff>
"""
- return ('{:0>14}{:0>34}{:0>32}{:0>4}{:0>4}'.format(
+ return ('{!s:0>14}{!s:0>34}{!s:0>32}{!s:0>4}{!s:0>4}'.format(
nh, src_ip, dst_ip, src_port, dst_port)).rstrip('0')
@staticmethod
@@ -190,7 +190,7 @@ class TestClassifier(VppTestCase):
dst_ip = binascii.hexlify(socket.inet_pton(
socket.AF_INET6, dst_ip))
- return ('{:0>14}{:0>34}{:0>32}{:0>4}{:0>4}'.format(
+ return ('{!s:0>14}{!s:0>34}{!s:0>32}{!s:0>4}{!s:0>4}'.format(
hex(nh)[2:], src_ip, dst_ip, hex(src_port)[2:],
hex(dst_port)[2:])).rstrip('0')
@@ -203,8 +203,8 @@ class TestClassifier(VppTestCase):
:param str ether_type: ethernet type <0-ffff>
"""
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
@staticmethod
def build_mac_match(dst_mac='', src_mac='', ether_type=''):
@@ -219,8 +219,8 @@ class TestClassifier(VppTestCase):
if src_mac:
src_mac = src_mac.replace(':', '')
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
def create_classify_table(self, key, mask, data_offset=0):
"""Create Classify Table
diff --git a/test/test_classify_l2_acl.py b/test/test_classify_l2_acl.py
index 5c9ccc9ae8d..0795907b76e 100644
--- a/test/test_classify_l2_acl.py
+++ b/test/test_classify_l2_acl.py
@@ -174,8 +174,8 @@ class TestClassifyAcl(VppTestCase):
:param str ether_type: ethernet type <0-ffff>
"""
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
@staticmethod
def build_mac_match(dst_mac='', src_mac='', ether_type=''):
@@ -190,8 +190,8 @@ class TestClassifyAcl(VppTestCase):
if src_mac:
src_mac = src_mac.replace(':', '')
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
def create_classify_table(self, key, mask, data_offset=0, is_add=1):
"""Create Classify Table
diff --git a/test/test_ip4.py b/test/test_ip4.py
index b13a30445aa..b6553dba7c2 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -395,7 +395,7 @@ class TestIPv4FibCrud(VppTestCase):
for ip in ips:
self.assertTrue(_ip_in_route_dump(ip, fib_dump),
- 'IP {} is not in fib dump.'.format(ip))
+ 'IP {!s} is not in fib dump.'.format(ip))
def verify_not_in_route_dump(self, fib_dump, ips):
@@ -406,7 +406,7 @@ class TestIPv4FibCrud(VppTestCase):
for ip in ips:
self.assertFalse(_ip_in_route_dump(ip, fib_dump),
- 'IP {} is in fib dump.'.format(ip))
+ 'IP {!s} is in fib dump.'.format(ip))
@classmethod
def setUpClass(cls):
diff --git a/test/test_lisp.py b/test/test_lisp.py
index 6ca16811b8b..03a5c2a526d 100644
--- a/test/test_lisp.py
+++ b/test/test_lisp.py
@@ -154,7 +154,7 @@ class TestLisp(VppTestCase):
self.deid_ip4_net = self.faf.net
self.deid_ip4 = self.faf.get_ip4()
- self.seid_ip4 = '{}/{}'.format(self.pg0.local_ip4, 32)
+ self.seid_ip4 = '{!s}/{!s}'.format(self.pg0.local_ip4, 32)
self.rloc_ip4 = self.pg1.remote_ip4n
test_cases = [
diff --git a/test/test_p2p_ethernet.py b/test/test_p2p_ethernet.py
index 75c39014417..b0d546e4d1f 100644
--- a/test/test_p2p_ethernet.py
+++ b/test/test_p2p_ethernet.py
@@ -77,7 +77,8 @@ class P2PEthernetAPI(VppTestCase):
for i in range(1, clients+1):
try:
- macs.append(':'.join(re.findall('..', '{:02x}'.format(mac+i))))
+ macs.append(':'.join(re.findall('..', '{:02x}'.format(
+ mac+i))))
self.vapi.p2p_ethernet_add(self.pg2.sw_if_index,
mac_pton(macs[i-1]),
i)
diff --git a/test/test_srv6.py b/test/test_srv6.py
index 46660f5bbb0..890e7ffbf3b 100644
--- a/test/test_srv6.py
+++ b/test/test_srv6.py
@@ -1224,7 +1224,7 @@ class TestSRv6(VppTestCase):
# add classify table
# mask on dst ip address prefix a7::/8
- mask = '{:0<16}'.format('ff')
+ mask = '{!s:0<16}'.format('ff')
r = self.vapi.classify_add_del_table(
1,
binascii.unhexlify(mask),
@@ -1239,7 +1239,7 @@ class TestSRv6(VppTestCase):
'sr-pl-rewrite-insert')
inacl_next_node_index = r.node_index
- match = '{:0<16}'.format('a7')
+ match = '{!s:0<16}'.format('a7')
r = self.vapi.classify_add_del_session(
1,
table_index,