Use six.reprlib. Uses repr for python 2 and reprlib for python 3.
Change-Id: Ia343a492d533bd511ed57166381e10a37e452d36
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
import os
import unittest
import os
import unittest
from multiprocessing import Process, Pipe
from multiprocessing import Process, Pipe
-from pickle import dumps, PicklingError
+from pickle import dumps
+
+import six
+
from framework import VppTestCase
from framework import VppTestCase
self._pipe = Pipe() # pipe for input/output arguments
def __repr__(self):
self._pipe = Pipe() # pipe for input/output arguments
def __repr__(self):
- return repr(RemoteClassAttr(self, None))
+ return six.reprlib(RemoteClassAttr(self, None))
def __str__(self):
return str(RemoteClassAttr(self, None))
def __str__(self):
return str(RemoteClassAttr(self, None))
def _get_local_repr(self, path):
try:
obj = self._get_local_object(path)
def _get_local_repr(self, path):
try:
obj = self._get_local_object(path)
+ return six.reprlib(obj)
except AttributeError:
return None
except AttributeError:
return None
""" BFD tests """
from __future__ import division
""" BFD tests """
from __future__ import division
-import unittest
-import hashlib
-from struct import pack, unpack
from random import randint, shuffle, getrandbits
from socket import AF_INET, AF_INET6, inet_ntop
from random import randint, shuffle, getrandbits
from socket import AF_INET, AF_INET6, inet_ntop
-from scapy.packet import Raw
-from scapy.layers.l2 import Ether
+from struct import pack, unpack
+
+import six
from scapy.layers.inet import UDP, IP
from scapy.layers.inet6 import IPv6
from scapy.layers.inet import UDP, IP
from scapy.layers.inet6 import IPv6
+from scapy.layers.l2 import Ether
+from scapy.packet import Raw
+
from bfd import VppBFDAuthKey, BFD, BFDAuthType, VppBFDUDPSession, \
BFDDiagCode, BFDState, BFD_vpp_echo
from framework import VppTestCase, VppTestRunner, running_extended_tests
from bfd import VppBFDAuthKey, BFD, BFDAuthType, VppBFDUDPSession, \
BFDDiagCode, BFDState, BFD_vpp_echo
from framework import VppTestCase, VppTestRunner, running_extended_tests
-from vpp_pg_interface import CaptureTimeoutError, is_ipv6_misc
-from vpp_lo_interface import VppLoInterface
-from vpp_papi_provider import UnexpectedApiReturnValueError
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_lo_interface import VppLoInterface
+from vpp_papi_provider import UnexpectedApiReturnValueError
+from vpp_pg_interface import CaptureTimeoutError, is_ipv6_misc
def verify_event(test, event, expected_state):
""" Verify correctness of event values. """
e = event
def verify_event(test, event, expected_state):
""" Verify correctness of event values. """
e = event
- test.logger.debug("BFD: Event: %s" % repr(e))
+ test.logger.debug("BFD: Event: %s" % six.reprlib(e))
test.assert_equal(e.sw_if_index,
test.vpp_session.interface.sw_if_index,
"BFD interface index")
test.assert_equal(e.sw_if_index,
test.vpp_session.interface.sw_if_index,
"BFD interface index")
-from abc import abstractmethod, ABCMeta
+from abc import abstractmethod, ABCMeta
+
+import six
from util import Host, mk_ll_addr, mactobinary
from util import Host, mk_ll_addr, mactobinary
raise Exception(
"Could not find interface with sw_if_index %d "
"in interface dump %s" %
raise Exception(
"Could not find interface with sw_if_index %d "
"in interface dump %s" %
- (self.sw_if_index, repr(r)))
+ (self.sw_if_index, six.reprlib(r)))
self._local_ip6_ll = mk_ll_addr(self.local_mac)
self._local_ip6n_ll = socket.inet_pton(socket.AF_INET6,
self.local_ip6_ll)
self._local_ip6_ll = mk_ll_addr(self.local_mac)
self._local_ip6n_ll = socket.inet_pton(socket.AF_INET6,
self.local_ip6_ll)
from abc import ABCMeta, abstractmethod
from abc import ABCMeta, abstractmethod
class VppObject(object):
""" Abstract vpp object """
class VppObject(object):
""" Abstract vpp object """
if failed:
logger.error("REG: Couldn't remove configuration for object(s):")
for obj in failed:
if failed:
logger.error("REG: Couldn't remove configuration for object(s):")
for obj in failed:
- logger.error(repr(obj))
+ logger.error(six.reprlib(obj))
raise Exception("Couldn't remove configuration for object(s): %s" %
(", ".join(str(x) for x in failed)))
raise Exception("Couldn't remove configuration for object(s): %s" %
(", ".join(str(x) for x in failed)))
from collections import deque
from collections import deque
+import six
+
+from hook import Hook
+
# Sphinx creates auto-generated documentation by importing the python source
# files and collecting the docstrings from them. The NO_VPP_PAPI flag allows
# the vpp_papi_provider.py file to be importable without having to build
# Sphinx creates auto-generated documentation by importing the python source
# files and collecting the docstrings from them. The NO_VPP_PAPI flag allows
# the vpp_papi_provider.py file to be importable without having to build
if hasattr(reply, 'retval') and reply.retval >= 0:
msg = "API call passed unexpectedly: expected negative "\
"return value instead of %d in %s" % \
if hasattr(reply, 'retval') and reply.retval >= 0:
msg = "API call passed unexpectedly: expected negative "\
"return value instead of %d in %s" % \
- (reply.retval, repr(reply))
+ (reply.retval, six.reprlib(reply))
self.test_class.logger.info(msg)
raise UnexpectedApiReturnValueError(msg)
elif self._expect_api_retval == self._zero:
if hasattr(reply, 'retval') and reply.retval != expected_retval:
msg = "API call failed, expected %d return value instead "\
"of %d in %s" % (expected_retval, reply.retval,
self.test_class.logger.info(msg)
raise UnexpectedApiReturnValueError(msg)
elif self._expect_api_retval == self._zero:
if hasattr(reply, 'retval') and reply.retval != expected_retval:
msg = "API call failed, expected %d return value instead "\
"of %d in %s" % (expected_retval, reply.retval,
self.test_class.logger.info(msg)
raise UnexpectedApiReturnValueError(msg)
else:
self.test_class.logger.info(msg)
raise UnexpectedApiReturnValueError(msg)
else: