diff options
author | Ole Troan <ot@cisco.com> | 2018-12-06 17:35:12 +0100 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2018-12-10 08:01:56 +0000 |
commit | 7f99183a20d60cd5c648cc23d7a2f30a594a215b (patch) | |
tree | bb3934aab296ce5fa531bfc5ab47921a113ffd26 /test/test_nat.py | |
parent | 521a8d7df423a0b5aaf259d49ca9230705bc25ee (diff) |
Test framework: StringIO fixes for Python3
Add 2/3 support to binarytomac and mactobinary and move to vpp_mac.py
Change-Id: I3dc7e4a24486aee22140c781aae7e44e58935877
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'test/test_nat.py')
-rw-r--r-- | test/test_nat.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/test_nat.py b/test/test_nat.py index c03cf08323b..b873074eccc 100644 --- a/test/test_nat.py +++ b/test/test_nat.py @@ -3,7 +3,6 @@ import socket import unittest import struct -import StringIO import random from framework import VppTestCase, VppTestRunner, running_extended_tests @@ -19,10 +18,11 @@ from util import ppp from ipfix import IPFIX, Set, Template, Data, IPFIXDecoder from time import sleep from util import ip4_range -from util import mactobinary +from vpp_mac import mactobinary from syslog_rfc5424_parser import SyslogMessage, ParseError from syslog_rfc5424_parser.constants import SyslogFacility, SyslogSeverity from vpp_papi_provider import SYSLOG_SEVERITY +from io import BytesIO class MethodHolder(VppTestCase): @@ -725,13 +725,13 @@ class MethodHolder(VppTestCase): :returns: Reassembled IPv4 packet """ - buffer = StringIO.StringIO() + buffer = BytesIO() for p in frags: self.assertEqual(p[IP].src, src) self.assertEqual(p[IP].dst, dst) self.assert_ip_checksum_valid(p) buffer.seek(p[IP].frag * 8) - buffer.write(p[IP].payload) + buffer.write(bytes(p[IP].payload)) ip = IP(src=frags[0][IP].src, dst=frags[0][IP].dst, proto=frags[0][IP].proto) if ip.proto == IP_PROTOS.tcp: @@ -754,12 +754,12 @@ class MethodHolder(VppTestCase): :returns: Reassembled IPv6 packet """ - buffer = StringIO.StringIO() + buffer = BytesIO() for p in frags: self.assertEqual(p[IPv6].src, src) self.assertEqual(p[IPv6].dst, dst) buffer.seek(p[IPv6ExtHdrFragment].offset * 8) - buffer.write(p[IPv6ExtHdrFragment].payload) + buffer.write(bytes(p[IPv6ExtHdrFragment].payload)) ip = IPv6(src=frags[0][IPv6].src, dst=frags[0][IPv6].dst, nh=frags[0][IPv6ExtHdrFragment].nh) if ip.nh == IP_PROTOS.tcp: |