From: Paul Vinciguerra Date: Fri, 4 Dec 2020 19:57:51 +0000 (-0500) Subject: tests: py2 cleanup - remove subclassing of object X-Git-Tag: v21.06-rc0~52 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F30285%2F6;p=vpp.git tests: py2 cleanup - remove subclassing of object Type: refactor Change-Id: I9096e3b473110350e1e8e5936e3c4c164f8969a7 Signed-off-by: Paul Vinciguerra --- diff --git a/src/plugins/ikev2/test/test_ikev2.py b/src/plugins/ikev2/test/test_ikev2.py index 073799072eb..3a1ab91f90d 100644 --- a/src/plugins/ikev2/test/test_ikev2.py +++ b/src/plugins/ikev2/test/test_ikev2.py @@ -12,6 +12,7 @@ from cryptography.hazmat.primitives.ciphers import ( modes, ) from ipaddress import IPv4Address, IPv6Address, ip_address +import unittest from scapy.layers.ipsec import ESP from scapy.layers.inet import IP, UDP, Ether from scapy.layers.inet6 import IPv6 diff --git a/src/plugins/nat/extras/nat_100ks.py b/src/plugins/nat/extras/nat_100ks.py index f54a6e8342d..c85a4591cd3 100644 --- a/src/plugins/nat/extras/nat_100ks.py +++ b/src/plugins/nat/extras/nat_100ks.py @@ -1,6 +1,6 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream (self): base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12) diff --git a/src/plugins/nat/extras/nat_10Ms.py b/src/plugins/nat/extras/nat_10Ms.py index 068ca5b54ba..6ce62a0b5e7 100644 --- a/src/plugins/nat/extras/nat_10Ms.py +++ b/src/plugins/nat/extras/nat_10Ms.py @@ -1,6 +1,6 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream (self): base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12) diff --git a/src/plugins/nat/extras/nat_10ks.py b/src/plugins/nat/extras/nat_10ks.py index 9bd7d8ffd6d..33c7196eb9e 100644 --- a/src/plugins/nat/extras/nat_10ks.py +++ b/src/plugins/nat/extras/nat_10ks.py @@ -1,6 +1,6 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream (self): base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12) diff --git a/src/plugins/nat/extras/nat_1Ms.py b/src/plugins/nat/extras/nat_1Ms.py index acee676043b..73a91a70985 100644 --- a/src/plugins/nat/extras/nat_1Ms.py +++ b/src/plugins/nat/extras/nat_1Ms.py @@ -1,6 +1,6 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream (self): base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12) diff --git a/src/plugins/nat/extras/nat_out2in_100ks.py b/src/plugins/nat/extras/nat_out2in_100ks.py index c1d42195f37..55ab5d42ee1 100644 --- a/src/plugins/nat/extras/nat_out2in_100ks.py +++ b/src/plugins/nat/extras/nat_out2in_100ks.py @@ -1,6 +1,6 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream (self): base_pkt = Ether()/IP(src="2.2.0.1")/UDP(sport=12) diff --git a/src/plugins/nat/extras/nat_out2in_10Ms.py b/src/plugins/nat/extras/nat_out2in_10Ms.py index fbd0643569a..48d3d199080 100644 --- a/src/plugins/nat/extras/nat_out2in_10Ms.py +++ b/src/plugins/nat/extras/nat_out2in_10Ms.py @@ -1,6 +1,6 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream (self): base_pkt = Ether()/IP(src="2.2.0.1")/UDP(sport=12) diff --git a/src/plugins/nat/extras/nat_out2in_10ks.py b/src/plugins/nat/extras/nat_out2in_10ks.py index 661381e8ec7..e961504fcf9 100644 --- a/src/plugins/nat/extras/nat_out2in_10ks.py +++ b/src/plugins/nat/extras/nat_out2in_10ks.py @@ -1,6 +1,6 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream (self): base_pkt = Ether()/IP(src="2.2.0.1")/UDP(sport=12) diff --git a/src/plugins/nat/extras/nat_out2in_1Ms.py b/src/plugins/nat/extras/nat_out2in_1Ms.py index 54ca5d5bd11..d2cb0810263 100644 --- a/src/plugins/nat/extras/nat_out2in_1Ms.py +++ b/src/plugins/nat/extras/nat_out2in_1Ms.py @@ -1,6 +1,6 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream (self): base_pkt = Ether()/IP(src="2.2.0.1")/UDP(sport=12) diff --git a/src/plugins/nat/extras/nat_ses_open.py b/src/plugins/nat/extras/nat_ses_open.py index 9f0f77e23f9..d614d4e7356 100644 --- a/src/plugins/nat/extras/nat_ses_open.py +++ b/src/plugins/nat/extras/nat_ses_open.py @@ -1,6 +1,6 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def __init__ (self): self.ip_range = {'local': {'start': "10.0.0.3", 'end': "10.1.255.255"}, diff --git a/src/plugins/nat/extras/nat_test_fast_path.py b/src/plugins/nat/extras/nat_test_fast_path.py index 97f8525fdc6..e869d40872a 100644 --- a/src/plugins/nat/extras/nat_test_fast_path.py +++ b/src/plugins/nat/extras/nat_test_fast_path.py @@ -1,7 +1,7 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream(self): # base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12) diff --git a/src/plugins/nat/extras/nat_test_slow_path.py b/src/plugins/nat/extras/nat_test_slow_path.py index 6da2fe6f6b9..a6351b98adf 100644 --- a/src/plugins/nat/extras/nat_test_slow_path.py +++ b/src/plugins/nat/extras/nat_test_slow_path.py @@ -1,7 +1,7 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream(self): # base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12) diff --git a/src/plugins/nat/extras/nat_test_slow_path_with_latency.py b/src/plugins/nat/extras/nat_test_slow_path_with_latency.py index 066e491c906..6c7663434c5 100644 --- a/src/plugins/nat/extras/nat_test_slow_path_with_latency.py +++ b/src/plugins/nat/extras/nat_test_slow_path_with_latency.py @@ -1,7 +1,7 @@ from trex_stl_lib.api import * -class STLS1(object): +class STLS1: def create_stream(self, port_id): # base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12) diff --git a/test/hook.py b/test/hook.py index 97b05d05153..7f2b8e01640 100644 --- a/test/hook.py +++ b/test/hook.py @@ -10,7 +10,7 @@ from log import RED, single_line_delim, double_line_delim from util import check_core_path, get_core_path -class Hook(object): +class Hook: """ Generic hooks before/after API/CLI calls """ diff --git a/test/ipfix.py b/test/ipfix.py index 5b32a85a2e7..bac6dfd4c2a 100644 --- a/test/ipfix.py +++ b/test/ipfix.py @@ -501,7 +501,7 @@ bind_layers(IPFIX, Set) bind_layers(UDP, IPFIX, dport=4739) -class IPFIXDecoder(object): +class IPFIXDecoder: """ IPFIX data set decoder """ def __init__(self): diff --git a/test/lisp.py b/test/lisp.py index a2e711f9d2a..bd5e1ab7c5f 100644 --- a/test/lisp.py +++ b/test/lisp.py @@ -102,19 +102,19 @@ class VppLispLocator(VppObject): return 'lisp-locator-%s-%d' % (self._ls_name, self._sw_if_index) -class LispEIDType(object): +class LispEIDType: PREFIX = 0 MAC = 1 NSH = 2 -class LispKeyIdType(object): +class LispKeyIdType: NONE = 0 SHA1 = 1 SHA256 = 2 -class LispEID(object): +class LispEID: """ Lisp endpoint identifier """ def __init__(self, eid): self.eid = eid @@ -155,7 +155,7 @@ class LispEID(object): return Exception('Unimplemented') -class LispKey(object): +class LispKey: """ Lisp Key """ def __init__(self, key_type, key): self._key_type = key_type @@ -244,7 +244,7 @@ class VppLocalMapping(VppLispMapping): return 'lisp-eid-local-mapping-%s[%d]' % (self._eid.address, self._vni) -class LispRemoteLocator(object): +class LispRemoteLocator: def __init__(self, addr, priority=1, weight=1): self.addr = addr self.priority = priority diff --git a/test/remote_test.py b/test/remote_test.py index c9686f57f06..134d90ffa83 100644 --- a/test/remote_test.py +++ b/test/remote_test.py @@ -12,7 +12,7 @@ import sys from enum import IntEnum, IntFlag -class SerializableClassCopy(object): +class SerializableClassCopy: """ Empty class used as a basis for a serializable copy of another class. """ @@ -22,7 +22,7 @@ class SerializableClassCopy(object): return '' % self.__dict__ -class RemoteClassAttr(object): +class RemoteClassAttr: """ Wrapper around attribute of a remotely executed class. """ diff --git a/test/template_ipsec.py b/test/template_ipsec.py index 7bd0b9ec81f..129f220c314 100644 --- a/test/template_ipsec.py +++ b/test/template_ipsec.py @@ -15,7 +15,7 @@ from util import ppp, reassemble4, fragment_rfc791, fragment_rfc8200 from vpp_papi import VppEnum -class IPsecIPv4Params(object): +class IPsecIPv4Params: addr_type = socket.AF_INET addr_any = "0.0.0.0" @@ -54,7 +54,7 @@ class IPsecIPv4Params(object): self.dscp = 0 -class IPsecIPv6Params(object): +class IPsecIPv6Params: addr_type = socket.AF_INET6 addr_any = "0::0" diff --git a/test/util.py b/test/util.py index b691deb642f..e21fdb81026 100644 --- a/test/util.py +++ b/test/util.py @@ -112,7 +112,7 @@ def check_core_path(logger, core_path): " current core pattern is: %s" % corefmt) -class NumericConstant(object): +class NumericConstant: desc_dict = {} @@ -131,7 +131,7 @@ class NumericConstant(object): return "" -class Host(object): +class Host: """ Generic test host "connected" to VPPs interface. """ @property diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py index c64ad5fb921..a50693c4f26 100644 --- a/test/vpp_ip_route.py +++ b/test/vpp_ip_route.py @@ -348,7 +348,7 @@ class VppIpInterfaceBind(VppObject): return "interface-bind-%s-%s" % (self.intf, self.table) -class VppMplsLabel(object): +class VppMplsLabel: def __init__(self, value, mode=MplsLspMode.PIPE, ttl=64, exp=0): self.value = value self.mode = mode @@ -380,7 +380,7 @@ class VppMplsLabel(object): return not (self == other) -class VppFibPathNextHop(object): +class VppFibPathNextHop: def __init__(self, addr, via_label=MPLS_LABEL_INVALID, next_hop_id=INVALID_INDEX): @@ -411,7 +411,7 @@ class VppFibPathNextHop(object): self.obj_id == other.obj_id) -class VppRoutePath(object): +class VppRoutePath: def __init__( self, @@ -691,7 +691,7 @@ class VppIpMRoute(VppObject): return c[0][self.stats_index] -class VppMFibSignal(object): +class VppMFibSignal: def __init__(self, test, route, interface, packet): self.route = route self.interface = interface diff --git a/test/vpp_object.py b/test/vpp_object.py index 2a993ff9e7c..8dd2afac97c 100644 --- a/test/vpp_object.py +++ b/test/vpp_object.py @@ -48,7 +48,7 @@ class VppObject(metaclass=abc.ABCMeta): return not self.__eq__(other) -class VppObjectRegistry(object): +class VppObjectRegistry: """ Class which handles automatic configuration cleanup. """ _shared_state = {}