diff --git a/.gitignore b/.gitignore index d8e22410..1e333ba9 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,6 @@ cover/ .coverage* !.coveragerc .tox -nosetests.xml .testrepository .stestr .venv diff --git a/os_ken/tests/base.py b/os_ken/tests/base.py deleted file mode 100644 index 1c30cdb5..00000000 --- a/os_ken/tests/base.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2010-2011 OpenStack Foundation -# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslotest import base - - -class TestCase(base.BaseTestCase): - - """Test case base class for all unit tests.""" diff --git a/os_ken/tests/integrated/bgp/base.py b/os_ken/tests/integrated/bgp/base.py index b2a2a98a..c4d87efb 100644 --- a/os_ken/tests/integrated/bgp/base.py +++ b/os_ken/tests/integrated/bgp/base.py @@ -32,42 +32,45 @@ class BgpSpeakerTestBase(unittest.TestCase): bridges = [] checktime = 120 - @classmethod - def setUpClass(cls): - cls.brdc1 = ctn_base.Bridge(name='brdc1', - subnet='192.168.10.0/24') - cls.bridges.append(cls.brdc1) + def setUp(self): + self.skipTest('These tests require to have "docker" configured in the ' + 'system. Regardless of if we move them to functional or ' + 'fix them, now we need to disable them.') + self.brdc1 = ctn_base.Bridge(name='brdc1', + subnet='192.168.10.0/24') + self.bridges.append(self.brdc1) - cls.dockerimg = ctn_base.DockerImage() + self.dockerimg = ctn_base.DockerImage() image = 'python:%d.%d' % ( sys.version_info.major, sys.version_info.minor) - cls.r_img = cls.dockerimg.create_os_ken(image=image, check_exist=True) - cls.images.append(cls.r_img) - cls.q_img = 'osrg/quagga' - cls.images.append(cls.q_img) + self.r_img = self.dockerimg.create_os_ken(image=image, + check_exist=True) + self.images.append(self.r_img) + self.q_img = 'osrg/quagga' + self.images.append(self.q_img) - cls.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512, - router_id='192.168.0.1', - ctn_image_name=cls.r_img) - cls.containers.append(cls.r1) - cls.r1.add_route('10.10.0.0/28') - cls.r1.run(wait=True) - cls.r1_ip_cidr = cls.brdc1.addif(cls.r1) - cls.r1_ip = cls.r1_ip_cidr.split('/')[0] + self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512, + router_id='192.168.0.1', + ctn_image_name=self.r_img) + self.containers.append(self.r1) + self.r1.add_route('10.10.0.0/28') + self.r1.run(wait=True) + self.r1_ip_cidr = self.brdc1.addif(self.r1) + self.r1_ip = self.r1_ip_cidr.split('/')[0] - cls.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522, - router_id='192.168.0.2', - ctn_image_name=cls.q_img) - cls.containers.append(cls.q1) - cls.q1.add_route('192.168.160.0/24') - cls.q1.run(wait=True) - cls.q1_ip_cidr = cls.brdc1.addif(cls.q1) - cls.q1_ip = cls.q1_ip_cidr.split('/')[0] + self.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522, + router_id='192.168.0.2', + ctn_image_name=self.q_img) + self.containers.append(self.q1) + self.q1.add_route('192.168.160.0/24') + self.q1.run(wait=True) + self.q1_ip_cidr = self.brdc1.addif(self.q1) + self.q1_ip = self.q1_ip_cidr.split('/')[0] - cls.r1.add_peer(cls.q1, bridge=cls.brdc1.name) - cls.q1.add_peer(cls.r1, bridge=cls.brdc1.name) + self.r1.add_peer(self.q1, bridge=self.brdc1.name) + self.q1.add_peer(self.r1, bridge=self.brdc1.name) - super(BgpSpeakerTestBase, cls).setUpClass() + super().setUp() @classmethod def tearDownClass(cls): diff --git a/os_ken/tests/integrated/bgp/base_ip6.py b/os_ken/tests/integrated/bgp/base_ip6.py index c4146c59..3d63360c 100644 --- a/os_ken/tests/integrated/bgp/base_ip6.py +++ b/os_ken/tests/integrated/bgp/base_ip6.py @@ -32,42 +32,44 @@ class BgpSpeakerTestBase(unittest.TestCase): bridges = [] checktime = 120 - @classmethod - def setUpClass(cls): - cls.brdc1 = ctn_base.Bridge(name='brip6dc1', - subnet='2001:10::/32') - cls.bridges.append(cls.brdc1) + def setUp(self): + self.skipTest('These tests require to have "docker" configured in the ' + 'system. Regardless of if we move them to functional or ' + 'fix them, now we need to disable them.') + self.brdc1 = ctn_base.Bridge(name='brip6dc1', subnet='2001:10::/32') + self.bridges.append(self.brdc1) - cls.dockerimg = ctn_base.DockerImage() + self.dockerimg = ctn_base.DockerImage() image = 'python:%d.%d' % ( sys.version_info.major, sys.version_info.minor) - cls.r_img = cls.dockerimg.create_os_ken(image=image, check_exist=True) - cls.images.append(cls.r_img) - cls.q_img = 'osrg/quagga' - cls.images.append(cls.q_img) + self.r_img = self.dockerimg.create_os_ken(image=image, + check_exist=True) + self.images.append(self.r_img) + self.q_img = 'osrg/quagga' + self.images.append(self.q_img) - cls.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512, - router_id='192.168.0.1', - ctn_image_name=cls.r_img) - cls.containers.append(cls.r1) - cls.r1.add_route('fc00:10::/64', route_info={'rf': 'ipv6'}) - cls.r1.run(wait=True) - cls.r1_ip_cidr = cls.brdc1.addif(cls.r1) - cls.r1_ip = cls.r1_ip_cidr.split('/')[0] + self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512, + router_id='192.168.0.1', + ctn_image_name=self.r_img) + self.containers.append(self.r1) + self.r1.add_route('fc00:10::/64', route_info={'rf': 'ipv6'}) + self.r1.run(wait=True) + self.r1_ip_cidr = self.brdc1.addif(self.r1) + self.r1_ip = self.r1_ip_cidr.split('/')[0] - cls.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522, - router_id='192.168.0.2', - ctn_image_name=cls.q_img) - cls.containers.append(cls.q1) - cls.q1.add_route('fc00:100::/64', route_info={'rf': 'ipv6'}) - cls.q1.run(wait=True) - cls.q1_ip_cidr = cls.brdc1.addif(cls.q1) - cls.q1_ip = cls.q1_ip_cidr.split('/')[0] + self.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522, + router_id='192.168.0.2', + ctn_image_name=self.q_img) + self.containers.append(self.q1) + self.q1.add_route('fc00:100::/64', route_info={'rf': 'ipv6'}) + self.q1.run(wait=True) + self.q1_ip_cidr = self.brdc1.addif(self.q1) + self.q1_ip = self.q1_ip_cidr.split('/')[0] - cls.r1.add_peer(cls.q1, bridge=cls.brdc1.name, v6=True) - cls.q1.add_peer(cls.r1, bridge=cls.brdc1.name, v6=True) + self.r1.add_peer(self.q1, bridge=self.brdc1.name, v6=True) + self.q1.add_peer(self.r1, bridge=self.brdc1.name, v6=True) - super(BgpSpeakerTestBase, cls).setUpClass() + super().setUp() @classmethod def tearDownClass(cls): diff --git a/os_ken/tests/integrated/bgp/test_basic.py b/os_ken/tests/integrated/bgp/test_basic.py index 3ad3260a..03a4ed69 100644 --- a/os_ken/tests/integrated/bgp/test_basic.py +++ b/os_ken/tests/integrated/bgp/test_basic.py @@ -22,7 +22,7 @@ from . import base class BgpSpeakerBasicTest(base.BgpSpeakerTestBase): def setUp(self): - super(BgpSpeakerBasicTest, self).setUp() + super().setUp() self.r1.stop_os_kenbgp(retry=True) self.r1.start_os_kenbgp(retry=True) diff --git a/os_ken/tests/integrated/bgp/test_ip6_basic.py b/os_ken/tests/integrated/bgp/test_ip6_basic.py index 6bfe1462..3d359400 100644 --- a/os_ken/tests/integrated/bgp/test_ip6_basic.py +++ b/os_ken/tests/integrated/bgp/test_ip6_basic.py @@ -22,7 +22,7 @@ from . import base_ip6 as base class BgpSpeakerBasicTest(base.BgpSpeakerTestBase): def setUp(self): - super(BgpSpeakerBasicTest, self).setUp() + super().setUp() self.r1.stop_os_kenbgp(retry=True) self.r1.start_os_kenbgp(retry=True) diff --git a/os_ken/tests/integrated/run_tests_with_ovs12.py b/os_ken/tests/integrated/run_tests_with_ovs12.py index 3b78242e..b7c7ea32 100755 --- a/os_ken/tests/integrated/run_tests_with_ovs12.py +++ b/os_ken/tests/integrated/run_tests_with_ovs12.py @@ -15,7 +15,6 @@ # limitations under the License. import unittest -from nose.tools import ok_, eq_, timed, nottest from subprocess import Popen, PIPE, STDOUT import time @@ -59,30 +58,24 @@ class TestWithOVS12(unittest.TestCase): def tearDownClass(cls): cls.mn.stop() - @timed(TIMEOUT) def test_add_flow_v10(self): app = 'os_ken/tests/integrated/test_add_flow_v10.py' self._run_os_ken_manager_and_check_output(app) - @timed(TIMEOUT) def test_request_reply_v12(self): app = 'os_ken/tests/integrated/test_request_reply_v12.py' self._run_os_ken_manager_and_check_output(app) - @timed(TIMEOUT) def test_add_flow_v12_actions(self): app = 'os_ken/tests/integrated/test_add_flow_v12_actions.py' self._run_os_ken_manager_and_check_output(app) - @timed(TIMEOUT) def test_add_flow_v12_matches(self): app = 'os_ken/tests/integrated/test_add_flow_v12_matches.py' self._run_os_ken_manager_and_check_output(app) - @nottest def test_of_config(self): - # OVS 1.10 does not support of_config - pass + self.skipTest('OVS 1.10 does not support of_config') def _run_os_ken_manager_and_check_output(self, app): cmd = [PYTHON_BIN, OSKEN_MGR, app] @@ -99,11 +92,7 @@ class TestWithOVS12(unittest.TestCase): print("osken-manager: %s" % line) if line.find('TEST_FINISHED') != -1: - ok_(line.find('Completed=[True]') != -1) + self.assertTrue(line.find('Completed=[True]') != -1) p.terminate() p.communicate() # wait for subprocess is terminated break - - -if __name__ == '__main__': - unittest.main() diff --git a/os_ken/tests/run_tests.py b/os_ken/tests/run_tests.py deleted file mode 100755 index 3706d905..00000000 --- a/os_ken/tests/run_tests.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python - - -import os -import sys - -from nose import config -from nose import core - -sys.path.append(os.getcwd()) -sys.path.append(os.path.dirname(__file__)) - - -import os_ken.tests.unit -from os_ken.tests.test_lib import run_tests - - -if __name__ == '__main__': - exit_status = False - - # if a single test case was specified, - # we should only invoked the tests once - invoke_once = len(sys.argv) > 1 - - cwd = os.getcwd() - c = config.Config(stream=sys.stdout, - env=os.environ, - verbosity=int(os.environ.get('NOSE_VERBOSE', 3)), - includeExe=True, - traverseNamespace=True, - plugins=core.DefaultPluginManager()) - c.configureWhere(os_ken.tests.unit.__path__) - - exit_status = run_tests(c) - sys.exit(exit_status) diff --git a/os_ken/tests/test_lib.py b/os_ken/tests/test_lib.py deleted file mode 100644 index f80ea10a..00000000 --- a/os_ken/tests/test_lib.py +++ /dev/null @@ -1,274 +0,0 @@ -# Copyright (C) 2013,2014,2015 Nippon Telegraph and Telephone Corporation. -# Copyright (C) 2013,2014,2015 YAMAMOTO Takashi -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import gettext -import os -import unittest -import six -import sys -import types -import logging - -from nose import result -from nose import core -from nose import config - - -class _AnsiColorizer(object): - """ - A colorizer is an object that loosely wraps around a stream, allowing - callers to write text to the stream in a particular color. - - Colorizer classes must implement C{supported()} and C{write(text, color)}. - """ - _colors = dict(black=30, red=31, green=32, yellow=33, - blue=34, magenta=35, cyan=36, white=37) - - def __init__(self, stream): - self.stream = stream - - def supported(cls, stream=sys.stdout): - """ - A class method that returns True if the current platform supports - coloring terminal output using this method. Returns False otherwise. - """ - if not stream.isatty(): - return False # auto color only on TTYs - try: - import curses - except ImportError: - return False - else: - try: - try: - return curses.tigetnum("colors") > 2 - except curses.error: - curses.setupterm() - return curses.tigetnum("colors") > 2 - except: - # guess false in case of error - return False - supported = classmethod(supported) - - def write(self, text, color): - """ - Write the given text to the stream in the given color. - - @param text: Text to be written to the stream. - - @param color: A string label for a color. e.g. 'red', 'white'. - """ - color = self._colors[color] - self.stream.write('\x1b[%s;1m%s\x1b[0m' % (color, text)) - - -class _Win32Colorizer(object): - """ - See _AnsiColorizer docstring. - """ - - def __init__(self, stream): - from win32console import GetStdHandle, STD_OUT_HANDLE - from win32console import FOREGROUND_RED, FOREGROUND_BLUE - from win32console import FOREGROUND_GREEN, FOREGROUND_INTENSITY - red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN, - FOREGROUND_BLUE, FOREGROUND_INTENSITY) - self.stream = stream - self.screenBuffer = GetStdHandle(STD_OUT_HANDLE) - self._colors = { - 'normal': red | green | blue, - 'red': red | bold, - 'green': green | bold, - 'blue': blue | bold, - 'yellow': red | green | bold, - 'magenta': red | blue | bold, - 'cyan': green | blue | bold, - 'white': red | green | blue | bold} - - def supported(cls, stream=sys.stdout): - try: - import win32console - screenBuffer = win32console.GetStdHandle( - win32console.STD_OUT_HANDLE) - except ImportError: - return False - import pywintypes - try: - screenBuffer.SetConsoleTextAttribute( - win32console.FOREGROUND_RED | - win32console.FOREGROUND_GREEN | - win32console.FOREGROUND_BLUE) - except pywintypes.error: - return False - else: - return True - supported = classmethod(supported) - - def write(self, text, color): - color = self._colors[color] - self.screenBuffer.SetConsoleTextAttribute(color) - self.stream.write(text) - self.screenBuffer.SetConsoleTextAttribute(self._colors['normal']) - - -class _NullColorizer(object): - """ - See _AnsiColorizer docstring. - """ - - def __init__(self, stream): - self.stream = stream - - def supported(cls, stream=sys.stdout): - return True - supported = classmethod(supported) - - def write(self, text, color): - self.stream.write(text) - - -class OSKenTestResult(result.TextTestResult): - def __init__(self, *args, **kw): - result.TextTestResult.__init__(self, *args, **kw) - self._last_case = None - self.colorizer = None - # NOTE(vish, tfukushima): reset stdout for the terminal check - stdout = sys.__stdout__ - sys.stdout = sys.__stdout__ - for colorizer in [_Win32Colorizer, _AnsiColorizer, _NullColorizer]: - if colorizer.supported(): - self.colorizer = colorizer(self.stream) - break - sys.stdout = stdout - - def getDescription(self, test): - return str(test) - - # NOTE(vish, tfukushima): copied from unittest with edit to add color - def addSuccess(self, test): - unittest.TestResult.addSuccess(self, test) - if self.showAll: - self.colorizer.write("OK", 'green') - self.stream.writeln() - elif self.dots: - self.stream.write('.') - self.stream.flush() - - # NOTE(vish, tfukushima): copied from unittest with edit to add color - def addFailure(self, test, err): - unittest.TestResult.addFailure(self, test, err) - if self.showAll: - self.colorizer.write("FAIL", 'red') - self.stream.writeln() - elif self.dots: - self.stream.write('F') - self.stream.flush() - - # NOTE(vish, tfukushima): copied from unittest with edit to add color - def addError(self, test, err): - """Overrides normal addError to add support for errorClasses. - If the exception is a registered class, the error will be added - to the list for that class, not errors. - """ - stream = getattr(self, 'stream', None) - ec, ev, tb = err - try: - exc_info = self._exc_info_to_string(err, test) - except TypeError: - # This is for compatibility with Python 2.3. - exc_info = self._exc_info_to_string(err) - for cls, (storage, label, isfail) in self.errorClasses.items(): - if result.isclass(ec) and issubclass(ec, cls): - if isfail: - test.passwd = False - storage.append((test, exc_info)) - # Might get patched into a streamless result - if stream is not None: - if self.showAll: - message = [label] - detail = result._exception_detail(err[1]) - if detail: - message.append(detail) - stream.writeln(": ".join(message)) - elif self.dots: - stream.write(label[:1]) - return - self.errors.append((test, exc_info)) - test.passed = False - if stream is not None: - if self.showAll: - self.colorizer.write("ERROR", 'red') - self.stream.writeln() - elif self.dots: - stream.write('E') - - def startTest(self, test): - unittest.TestResult.startTest(self, test) - current_case = test.test.__class__.__name__ - - if self.showAll: - if current_case != self._last_case: - self.stream.writeln(current_case) - self._last_case = current_case - # NOTE(salvatore-orlando): - # slightly changed in order to print test case class - # together with unit test name - self.stream.write( - ' %s' % str(test.test).ljust(60)) - self.stream.flush() - - -class OSKenTestRunner(core.TextTestRunner): - def _makeResult(self): - return OSKenTestResult(self.stream, - self.descriptions, - self.verbosity, - self.config) - - -def run_tests(c=None): - logger = logging.getLogger() - hdlr = logging.StreamHandler() - formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') - hdlr.setFormatter(formatter) - logger.addHandler(hdlr) - logger.setLevel(logging.DEBUG) - - # NOTE(bgh): I'm not entirely sure why but nose gets confused here when - # calling run_tests from a plugin directory run_tests.py (instead of the - # main run_tests.py). It will call run_tests with no arguments and the - # testing of run_tests will fail (though the plugin tests will pass). For - # now we just return True to let the run_tests test pass. - if not c: - return True - - runner = OSKenTestRunner(stream=c.stream, - verbosity=c.verbosity, - config=c) - return not core.run(config=c, testRunner=runner) - - -def add_method(cls, method_name, method): - """Add the method to the class dynamically, keeping unittest/nose happy.""" - method.func_name = method_name - method.__name__ = method_name - if six.PY3: - methodtype = types.MethodType(method, cls) - if not hasattr(method, "__qualname__"): - method.__qualname__ = "%s.%s" % (cls.__qualname__, method_name) - else: - methodtype = types.MethodType(method, None, cls) - setattr(cls, method_name, methodtype) diff --git a/os_ken/tests/test_os_ken.py b/os_ken/tests/test_os_ken.py deleted file mode 100644 index 1f27312a..00000000 --- a/os_ken/tests/test_os_ken.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -test_os_ken ----------------------------------- - -Tests for `os_ken` module. -""" - -from os_ken.tests import base - - -class TestOs_ken(base.TestCase): - - def test_something(self): - pass diff --git a/os_ken/tests/unit/cmd/test_manager.py b/os_ken/tests/unit/cmd/test_manager.py index 79f11d21..6c3e2382 100644 --- a/os_ken/tests/unit/cmd/test_manager.py +++ b/os_ken/tests/unit/cmd/test_manager.py @@ -14,18 +14,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import unittest from unittest import mock -from nose.tools import eq_, raises - -try: - # Python 3 - from imp import reload -except ImportError: - # Python 2 - pass +from imp import reload from os_ken.cmd.manager import main @@ -43,15 +35,13 @@ class Test_Manager(unittest.TestCase): def tearDown(self): pass - @raises(SystemExit) @mock.patch('sys.argv', new=['osken-manager', '--version']) def test_version(self): - main() + self.assertRaises(SystemExit, main) - @raises(SystemExit) @mock.patch('sys.argv', new=['osken-manager', '--help']) def test_help(self): - main() + self.assertRaises(SystemExit, main) @staticmethod def _reset_globals(): diff --git a/os_ken/tests/unit/controller/test_controller.py b/os_ken/tests/unit/controller/test_controller.py index 99b8d292..7973fd0e 100644 --- a/os_ken/tests/unit/controller/test_controller.py +++ b/os_ken/tests/unit/controller/test_controller.py @@ -22,11 +22,10 @@ import sys import warnings import logging import random +import testtools import unittest from unittest import mock -from nose.tools import eq_, raises - from os_ken.base import app_manager # To suppress cyclic import from os_ken.controller import controller from os_ken.controller import handler @@ -40,36 +39,35 @@ hub.patch() LOG = logging.getLogger('test_controller') -class TestUtils(unittest.TestCase): +class TestUtils(testtools.TestCase): """ Test cases for utilities defined in controller module. """ def test_split_addr_with_ipv4(self): addr, port = controller._split_addr('127.0.0.1:6653') - eq_('127.0.0.1', addr) - eq_(6653, port) + self.assertEqual('127.0.0.1', addr) + self.assertEqual(6653, port) def test_split_addr_with_ipv6(self): addr, port = controller._split_addr('[::1]:6653') - eq_('::1', addr) - eq_(6653, port) + self.assertEqual('::1', addr) + self.assertEqual(6653, port) - @raises(ValueError) def test_split_addr_with_invalid_addr(self): - controller._split_addr('127.0.0.1') + self.assertRaises(ValueError, controller._split_addr, '127.0.0.1') - @raises(ValueError) def test_split_addr_with_invalid_ipv4_addr(self): - controller._split_addr('xxx.xxx.xxx.xxx:6653') + self.assertRaises(ValueError, controller._split_addr, + 'xxx.xxx.xxx.xxx:6653') - @raises(ValueError) def test_split_addr_with_invalid_ipv6_addr(self): - controller._split_addr('[::xxxx]:6653') + self.assertRaises(ValueError, controller._split_addr, + '[::xxxx]:6653') - @raises(ValueError) def test_split_addr_with_non_bracketed_ipv6_addr(self): - controller._split_addr('::1:6653') + self.assertRaises(ValueError, controller._split_addr, + '::1:6653') class Test_Datapath(unittest.TestCase): @@ -176,53 +174,3 @@ class Test_Datapath(unittest.TestCase): self.assertEqual(state, handler.MAIN_DISPATCHER) self.assertEqual(kwargs, {}) self.assertEqual(expected_json, output_json) - - -class TestOpenFlowController(unittest.TestCase): - """ - Test cases for OpenFlowController - """ - @mock.patch("os_ken.controller.controller.CONF") - def _test_ssl(self, this_dir, port, conf_mock): - conf_mock.ofp_ssl_listen_port = port - conf_mock.ofp_listen_host = "127.0.0.1" - conf_mock.ca_certs = None - conf_mock.ciphers = None - conf_mock.ctl_cert = os.path.join(this_dir, 'cert.crt') - conf_mock.ctl_privkey = os.path.join(this_dir, 'cert.key') - c = controller.OpenFlowController() - c() - - def test_ssl(self): - """Tests SSL server functionality.""" - # TODO: TLS version enforcement is necessary to avoid - # vulnerable versions. Currently, this only tests TLS - # connectivity. - this_dir = os.path.dirname(sys.modules[__name__].__file__) - saved_exception = None - try: - ssl_version = ssl.PROTOCOL_TLS - except AttributeError: - # For compatibility with older pythons. - ssl_version = ssl.PROTOCOL_TLSv1 - for i in range(3): - try: - # Try a few times as this can fail with EADDRINUSE - port = random.randint(5000, 10000) - server = hub.spawn(self._test_ssl, this_dir, port) - hub.sleep(1) - client = hub.StreamClient(("127.0.0.1", port), - timeout=5, - ssl_version=ssl_version) - if client.connect() is not None: - break - except Exception as e: - saved_exception = e - continue - finally: - try: - hub.kill(server) - except Exception: - pass - else: - self.fail("Failed to connect: " + str(saved_exception)) diff --git a/os_ken/tests/unit/lib/test_sockaddr.py b/os_ken/tests/unit/lib/test_sockaddr.py index 5ea3cc2c..66037566 100644 --- a/os_ken/tests/unit/lib/test_sockaddr.py +++ b/os_ken/tests/unit/lib/test_sockaddr.py @@ -13,13 +13,12 @@ # under the License. import unittest -import logging import platform import sys -from nose.tools import eq_ from os_ken.lib import sockaddr + system = platform.system() @@ -38,7 +37,7 @@ class Test_sockaddr(unittest.TestCase): addr = '127.0.0.1' expected_result = (b'\x02\x00\x00\x00' b'\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00') - eq_(expected_result, sockaddr.sa_in4(addr)) + self.assertEqual(expected_result, sockaddr.sa_in4(addr)) def test_sockaddr_linux_sa_in6(self): if system != 'Linux' or sys.byteorder != 'little': @@ -47,9 +46,9 @@ class Test_sockaddr(unittest.TestCase): addr = 'dead:beef::1' expected_result = (b'\n\x00\x00\x00\x00\x00\x00\x00\xde\xad\xbe\xef' b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00') - eq_(expected_result, sockaddr.sa_in6(addr)) + self.assertEqual(expected_result, sockaddr.sa_in6(addr)) def test_sockaddr_sa_to_ss(self): addr = b'\x01' expected_result = b'\x01' + 127 * b'\x00' - eq_(expected_result, sockaddr.sa_to_ss(addr)) + self.assertEqual(expected_result, sockaddr.sa_to_ss(addr)) diff --git a/os_ken/tests/unit/ofproto/test_ether.py b/os_ken/tests/unit/ofproto/test_ether.py index 4dd2675b..32707b5d 100644 --- a/os_ken/tests/unit/ofproto/test_ether.py +++ b/os_ken/tests/unit/ofproto/test_ether.py @@ -17,7 +17,6 @@ import unittest import logging -from nose.tools import eq_ from os_ken.ofproto.ether import * @@ -29,9 +28,9 @@ class TestInet(unittest.TestCase): """ def test_ether_type(self): - eq_(ETH_TYPE_IP, 0x0800) - eq_(ETH_TYPE_ARP, 0x0806) - eq_(ETH_TYPE_8021Q, 0x8100) - eq_(ETH_TYPE_IPV6, 0x86dd) - eq_(ETH_TYPE_MPLS, 0x8847) - eq_(ETH_TYPE_SLOW, 0x8809) + self.assertEqual(ETH_TYPE_IP, 0x0800) + self.assertEqual(ETH_TYPE_ARP, 0x0806) + self.assertEqual(ETH_TYPE_8021Q, 0x8100) + self.assertEqual(ETH_TYPE_IPV6, 0x86dd) + self.assertEqual(ETH_TYPE_MPLS, 0x8847) + self.assertEqual(ETH_TYPE_SLOW, 0x8809) diff --git a/os_ken/tests/unit/ofproto/test_inet.py b/os_ken/tests/unit/ofproto/test_inet.py index f38d35d3..5c6c57ee 100644 --- a/os_ken/tests/unit/ofproto/test_inet.py +++ b/os_ken/tests/unit/ofproto/test_inet.py @@ -17,7 +17,6 @@ import unittest import logging -from nose.tools import eq_ from os_ken.ofproto.inet import * @@ -29,15 +28,15 @@ class TestInet(unittest.TestCase): """ def test_ip_proto(self): - eq_(IPPROTO_IP, 0) - eq_(IPPROTO_HOPOPTS, 0) - eq_(IPPROTO_ICMP, 1) - eq_(IPPROTO_TCP, 6) - eq_(IPPROTO_UDP, 17) - eq_(IPPROTO_ROUTING, 43) - eq_(IPPROTO_FRAGMENT, 44) - eq_(IPPROTO_AH, 51) - eq_(IPPROTO_ICMPV6, 58) - eq_(IPPROTO_NONE, 59) - eq_(IPPROTO_DSTOPTS, 60) - eq_(IPPROTO_SCTP, 132) + self.assertEqual(IPPROTO_IP, 0) + self.assertEqual(IPPROTO_HOPOPTS, 0) + self.assertEqual(IPPROTO_ICMP, 1) + self.assertEqual(IPPROTO_TCP, 6) + self.assertEqual(IPPROTO_UDP, 17) + self.assertEqual(IPPROTO_ROUTING, 43) + self.assertEqual(IPPROTO_FRAGMENT, 44) + self.assertEqual(IPPROTO_AH, 51) + self.assertEqual(IPPROTO_ICMPV6, 58) + self.assertEqual(IPPROTO_NONE, 59) + self.assertEqual(IPPROTO_DSTOPTS, 60) + self.assertEqual(IPPROTO_SCTP, 132) diff --git a/os_ken/tests/unit/ofproto/test_ofproto.py b/os_ken/tests/unit/ofproto/test_ofproto.py index 2272d604..6e92da61 100644 --- a/os_ken/tests/unit/ofproto/test_ofproto.py +++ b/os_ken/tests/unit/ofproto/test_ofproto.py @@ -16,16 +16,10 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -try: - # Python 3 - from imp import reload -except ImportError: - # Python 2 - pass +from imp import reload import unittest import logging -from nose.tools import eq_ LOG = logging.getLogger('test_ofproto') @@ -53,19 +47,22 @@ class TestOfprotCommon(unittest.TestCase): import os_ken.ofproto.ofproto_v1_3 import os_ken.ofproto.ofproto_v1_4 import os_ken.ofproto.ofproto_v1_5 - eq_(set(ofp_modules.keys()), set([os_ken.ofproto.ofproto_v1_0.OFP_VERSION, - os_ken.ofproto.ofproto_v1_2.OFP_VERSION, - os_ken.ofproto.ofproto_v1_3.OFP_VERSION, - os_ken.ofproto.ofproto_v1_4.OFP_VERSION, - os_ken.ofproto.ofproto_v1_5.OFP_VERSION, - ])) + self.assertEqual(set(ofp_modules.keys()), + set([os_ken.ofproto.ofproto_v1_0.OFP_VERSION, + os_ken.ofproto.ofproto_v1_2.OFP_VERSION, + os_ken.ofproto.ofproto_v1_3.OFP_VERSION, + os_ken.ofproto.ofproto_v1_4.OFP_VERSION, + os_ken.ofproto.ofproto_v1_5.OFP_VERSION, + ])) consts_mods = set([ofp_mod[0] for ofp_mod in ofp_modules.values()]) - eq_(consts_mods, set([os_ken.ofproto.ofproto_v1_0, + self.assertEqual(consts_mods, + set([os_ken.ofproto.ofproto_v1_0, os_ken.ofproto.ofproto_v1_2, os_ken.ofproto.ofproto_v1_3, os_ken.ofproto.ofproto_v1_4, os_ken.ofproto.ofproto_v1_5, - ])) + ]) + ) parser_mods = set([ofp_mod[1] for ofp_mod in ofp_modules.values()]) import os_ken.ofproto.ofproto_v1_0_parser @@ -73,9 +70,11 @@ class TestOfprotCommon(unittest.TestCase): import os_ken.ofproto.ofproto_v1_3_parser import os_ken.ofproto.ofproto_v1_4_parser import os_ken.ofproto.ofproto_v1_5_parser - eq_(parser_mods, set([os_ken.ofproto.ofproto_v1_0_parser, + self.assertEqual(parser_mods, + set([os_ken.ofproto.ofproto_v1_0_parser, os_ken.ofproto.ofproto_v1_2_parser, os_ken.ofproto.ofproto_v1_3_parser, os_ken.ofproto.ofproto_v1_4_parser, os_ken.ofproto.ofproto_v1_5_parser, - ])) + ]) + ) diff --git a/os_ken/tests/unit/ofproto/test_ofproto_common.py b/os_ken/tests/unit/ofproto/test_ofproto_common.py index 3eafb777..4dab8278 100644 --- a/os_ken/tests/unit/ofproto/test_ofproto_common.py +++ b/os_ken/tests/unit/ofproto/test_ofproto_common.py @@ -17,7 +17,6 @@ import unittest import logging -from nose.tools import eq_ from os_ken.ofproto.ofproto_common import * @@ -29,9 +28,9 @@ class TestOfprotCommon(unittest.TestCase): """ def test_struct_ofp_header(self): - eq_(OFP_HEADER_PACK_STR, '!BBHI') - eq_(OFP_HEADER_SIZE, 8) + self.assertEqual(OFP_HEADER_PACK_STR, '!BBHI') + self.assertEqual(OFP_HEADER_SIZE, 8) def test_define_constants(self): - eq_(OFP_TCP_PORT, 6653) - eq_(OFP_SSL_PORT, 6653) + self.assertEqual(OFP_TCP_PORT, 6653) + self.assertEqual(OFP_SSL_PORT, 6653) diff --git a/os_ken/tests/unit/ofproto/test_ofproto_parser.py b/os_ken/tests/unit/ofproto/test_ofproto_parser.py index 570c43d9..c156fe67 100644 --- a/os_ken/tests/unit/ofproto/test_ofproto_parser.py +++ b/os_ken/tests/unit/ofproto/test_ofproto_parser.py @@ -19,7 +19,6 @@ import six import binascii import unittest -from nose.tools import * import struct from os_ken import exception @@ -68,10 +67,10 @@ class TestOfproto_Parser(unittest.TestCase): msg_type, msg_len, xid) = ofproto_parser.header(self.bufHello) - eq_(version, 1) - eq_(msg_type, 0) - eq_(msg_len, 8) - eq_(xid, 1) + self.assertEqual(version, 1) + self.assertEqual(msg_type, 0) + self.assertEqual(msg_len, 8) + self.assertEqual(xid, 1) def testFeaturesReply(self): (version, @@ -87,11 +86,11 @@ class TestOfproto_Parser(unittest.TestCase): self.bufFeaturesReply) LOG.debug(msg) - ok_(isinstance(msg, ofproto_v1_0_parser.OFPSwitchFeatures)) + self.assertTrue(isinstance(msg, ofproto_v1_0_parser.OFPSwitchFeatures)) LOG.debug(msg.ports[65534]) - ok_(isinstance(msg.ports[1], ofproto_v1_0_parser.OFPPhyPort)) - ok_(isinstance(msg.ports[2], ofproto_v1_0_parser.OFPPhyPort)) - ok_(isinstance(msg.ports[65534], ofproto_v1_0_parser.OFPPhyPort)) + self.assertTrue(isinstance(msg.ports[1], ofproto_v1_0_parser.OFPPhyPort)) + self.assertTrue(isinstance(msg.ports[2], ofproto_v1_0_parser.OFPPhyPort)) + self.assertTrue(isinstance(msg.ports[65534], ofproto_v1_0_parser.OFPPhyPort)) def testPacketIn(self): (version, @@ -106,9 +105,8 @@ class TestOfproto_Parser(unittest.TestCase): xid, self.bufPacketIn) LOG.debug(msg) - ok_(isinstance(msg, ofproto_v1_0_parser.OFPPacketIn)) + self.assertTrue(isinstance(msg, ofproto_v1_0_parser.OFPPacketIn)) - @raises(AssertionError) def test_check_msg_len(self): (version, msg_type, @@ -116,14 +114,9 @@ class TestOfproto_Parser(unittest.TestCase): xid) = ofproto_parser.header(self.bufPacketIn) msg_len = len(self.bufPacketIn) + 1 - ofproto_parser.msg(self, - version, - msg_type, - msg_len, - xid, - self.bufPacketIn) + self.assertRaises(AssertionError, ofproto_parser.msg, self, version, + msg_type, msg_len, xid, self.bufPacketIn) - @raises(exception.OFPUnknownVersion) def test_check_msg_parser(self): (version, msg_type, @@ -131,12 +124,9 @@ class TestOfproto_Parser(unittest.TestCase): xid) = ofproto_parser.header(self.bufPacketIn) version = 0xff - ofproto_parser.msg(self, - version, - msg_type, - msg_len, - xid, - self.bufPacketIn) + self.assertRaises(exception.OFPUnknownVersion, ofproto_parser.msg, + self, version, msg_type, msg_len, xid, + self.bufPacketIn) class TestMsgBase(unittest.TestCase): @@ -156,14 +146,13 @@ class TestMsgBase(unittest.TestCase): xid = 3841413783 c = ofproto_parser.MsgBase(object) c.set_xid(xid) - eq_(xid, c.xid) + self.assertEqual(xid, c.xid) - @raises(AssertionError) def test_set_xid_check_xid(self): xid = 2160492514 c = ofproto_parser.MsgBase(object) c.xid = xid - c.set_xid(xid) + self.assertRaises(AssertionError, c.set_xid, xid) def _test_parser(self, msg_type=ofproto_v1_0.OFPT_HELLO): version = ofproto_v1_0.OFP_VERSION @@ -178,11 +167,11 @@ class TestMsgBase(unittest.TestCase): res = ofproto_v1_0_parser.OFPHello.parser( object, version, msg_type, msg_len, xid, bytearray(buf)) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(buffer(buf), res.buf) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(buffer(buf), res.buf) # test __str__() list_ = ('version', 'msg_type', 'msg_len', 'xid') @@ -193,19 +182,19 @@ class TestMsgBase(unittest.TestCase): if k in list_: check[k] = v - eq_(hex(ofproto_v1_0.OFP_VERSION), check['version']) - eq_(hex(ofproto_v1_0.OFPT_HELLO), check['msg_type']) - eq_(hex(msg_len), check['msg_len']) - eq_(hex(xid), check['xid']) + self.assertEqual(hex(ofproto_v1_0.OFP_VERSION), check['version']) + self.assertEqual(hex(ofproto_v1_0.OFPT_HELLO), check['msg_type']) + self.assertEqual(hex(msg_len), check['msg_len']) + self.assertEqual(hex(xid), check['xid']) return True def test_parser(self): - ok_(self._test_parser()) + self.assertTrue(self._test_parser()) - @raises(AssertionError) def test_parser_check_msg_type(self): - self._test_parser(ofproto_v1_0.OFPT_ERROR) + self.assertRaises(AssertionError, self._test_parser, + ofproto_v1_0.OFPT_ERROR) def _test_serialize(self): @@ -216,14 +205,14 @@ class TestMsgBase(unittest.TestCase): c = ofproto_v1_0_parser.OFPHello(Datapath) c.serialize() - eq_(ofproto_v1_0.OFP_VERSION, c.version) - eq_(ofproto_v1_0.OFPT_HELLO, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto_v1_0.OFP_VERSION, c.version) + self.assertEqual(ofproto_v1_0.OFPT_HELLO, c.msg_type) + self.assertEqual(0, c.xid) return True def test_serialize(self): - ok_(self._test_serialize()) + self.assertTrue(self._test_serialize()) class TestMsgStrAttr(unittest.TestCase): @@ -240,5 +229,5 @@ class TestMsgStrAttr(unittest.TestCase): res = ofproto_parser.msg_str_attr(c, buf, ('check',)) str_ = str(res) str_ = str_.rsplit() - eq_('check', str_[0]) - eq_('msg_str_attr_test', str_[1]) + self.assertEqual('check', str_[0]) + self.assertEqual('msg_str_attr_test', str_[1]) diff --git a/os_ken/tests/unit/ofproto/test_ofproto_v12.py b/os_ken/tests/unit/ofproto/test_ofproto_v12.py index 25fbc8ab..d8d38dc6 100644 --- a/os_ken/tests/unit/ofproto/test_ofproto_v12.py +++ b/os_ken/tests/unit/ofproto/test_ofproto_v12.py @@ -17,7 +17,6 @@ import unittest import logging -from nose.tools import eq_ from os_ken.ofproto.ofproto_v1_2 import * @@ -29,621 +28,621 @@ class TestOfprot12(unittest.TestCase): """ def test_struct_ofp_header(self): - eq_(OFP_HEADER_PACK_STR, '!BBHI') - eq_(OFP_HEADER_SIZE, 8) + self.assertEqual(OFP_HEADER_PACK_STR, '!BBHI') + self.assertEqual(OFP_HEADER_SIZE, 8) def test_enum_ofp_type(self): - eq_(OFPT_HELLO, 0) - eq_(OFPT_ERROR, 1) - eq_(OFPT_ECHO_REQUEST, 2) - eq_(OFPT_ECHO_REPLY, 3) - eq_(OFPT_EXPERIMENTER, 4) - eq_(OFPT_FEATURES_REQUEST, 5) - eq_(OFPT_FEATURES_REPLY, 6) - eq_(OFPT_GET_CONFIG_REQUEST, 7) - eq_(OFPT_GET_CONFIG_REPLY, 8) - eq_(OFPT_SET_CONFIG, 9) - eq_(OFPT_PACKET_IN, 10) - eq_(OFPT_FLOW_REMOVED, 11) - eq_(OFPT_PORT_STATUS, 12) - eq_(OFPT_PACKET_OUT, 13) - eq_(OFPT_FLOW_MOD, 14) - eq_(OFPT_GROUP_MOD, 15) - eq_(OFPT_PORT_MOD, 16) - eq_(OFPT_TABLE_MOD, 17) - eq_(OFPT_STATS_REQUEST, 18) - eq_(OFPT_STATS_REPLY, 19) - eq_(OFPT_BARRIER_REQUEST, 20) - eq_(OFPT_BARRIER_REPLY, 21) - eq_(OFPT_QUEUE_GET_CONFIG_REQUEST, 22) - eq_(OFPT_QUEUE_GET_CONFIG_REPLY, 23) - eq_(OFPT_ROLE_REQUEST, 24) - eq_(OFPT_ROLE_REPLY, 25) + self.assertEqual(OFPT_HELLO, 0) + self.assertEqual(OFPT_ERROR, 1) + self.assertEqual(OFPT_ECHO_REQUEST, 2) + self.assertEqual(OFPT_ECHO_REPLY, 3) + self.assertEqual(OFPT_EXPERIMENTER, 4) + self.assertEqual(OFPT_FEATURES_REQUEST, 5) + self.assertEqual(OFPT_FEATURES_REPLY, 6) + self.assertEqual(OFPT_GET_CONFIG_REQUEST, 7) + self.assertEqual(OFPT_GET_CONFIG_REPLY, 8) + self.assertEqual(OFPT_SET_CONFIG, 9) + self.assertEqual(OFPT_PACKET_IN, 10) + self.assertEqual(OFPT_FLOW_REMOVED, 11) + self.assertEqual(OFPT_PORT_STATUS, 12) + self.assertEqual(OFPT_PACKET_OUT, 13) + self.assertEqual(OFPT_FLOW_MOD, 14) + self.assertEqual(OFPT_GROUP_MOD, 15) + self.assertEqual(OFPT_PORT_MOD, 16) + self.assertEqual(OFPT_TABLE_MOD, 17) + self.assertEqual(OFPT_STATS_REQUEST, 18) + self.assertEqual(OFPT_STATS_REPLY, 19) + self.assertEqual(OFPT_BARRIER_REQUEST, 20) + self.assertEqual(OFPT_BARRIER_REPLY, 21) + self.assertEqual(OFPT_QUEUE_GET_CONFIG_REQUEST, 22) + self.assertEqual(OFPT_QUEUE_GET_CONFIG_REPLY, 23) + self.assertEqual(OFPT_ROLE_REQUEST, 24) + self.assertEqual(OFPT_ROLE_REPLY, 25) def test_struct_ofp_port(self): - eq_(OFP_PORT_PACK_STR, '!I4x6s2x16sIIIIIIII') - eq_(OFP_PORT_SIZE, 64) + self.assertEqual(OFP_PORT_PACK_STR, '!I4x6s2x16sIIIIIIII') + self.assertEqual(OFP_PORT_SIZE, 64) def test_enum_ofp_port_config(self): - eq_(OFPPC_PORT_DOWN, 1 << 0) - eq_(OFPPC_NO_RECV, 1 << 2) - eq_(OFPPC_NO_FWD, 1 << 5) - eq_(OFPPC_NO_PACKET_IN, 1 << 6) + self.assertEqual(OFPPC_PORT_DOWN, 1 << 0) + self.assertEqual(OFPPC_NO_RECV, 1 << 2) + self.assertEqual(OFPPC_NO_FWD, 1 << 5) + self.assertEqual(OFPPC_NO_PACKET_IN, 1 << 6) def test_enum_ofp_port_state(self): - eq_(OFPPS_LINK_DOWN, 1 << 0) - eq_(OFPPS_BLOCKED, 1 << 1) - eq_(OFPPS_LIVE, 1 << 2) + self.assertEqual(OFPPS_LINK_DOWN, 1 << 0) + self.assertEqual(OFPPS_BLOCKED, 1 << 1) + self.assertEqual(OFPPS_LIVE, 1 << 2) def test_enum_ofp_port_no(self): - eq_(OFPP_MAX, 0xffffff00) - eq_(OFPP_IN_PORT, 0xfffffff8) - eq_(OFPP_TABLE, 0xfffffff9) - eq_(OFPP_NORMAL, 0xfffffffa) - eq_(OFPP_FLOOD, 0xfffffffb) - eq_(OFPP_ALL, 0xfffffffc) - eq_(OFPP_CONTROLLER, 0xfffffffd) - eq_(OFPP_LOCAL, 0xfffffffe) - eq_(OFPP_ANY, 0xffffffff) - eq_(OFPQ_ALL, 0xffffffff) + self.assertEqual(OFPP_MAX, 0xffffff00) + self.assertEqual(OFPP_IN_PORT, 0xfffffff8) + self.assertEqual(OFPP_TABLE, 0xfffffff9) + self.assertEqual(OFPP_NORMAL, 0xfffffffa) + self.assertEqual(OFPP_FLOOD, 0xfffffffb) + self.assertEqual(OFPP_ALL, 0xfffffffc) + self.assertEqual(OFPP_CONTROLLER, 0xfffffffd) + self.assertEqual(OFPP_LOCAL, 0xfffffffe) + self.assertEqual(OFPP_ANY, 0xffffffff) + self.assertEqual(OFPQ_ALL, 0xffffffff) def test_enum_ofp_port_features(self): - eq_(OFPPF_10MB_HD, 1 << 0) - eq_(OFPPF_10MB_FD, 1 << 1) - eq_(OFPPF_100MB_HD, 1 << 2) - eq_(OFPPF_100MB_FD, 1 << 3) - eq_(OFPPF_1GB_HD, 1 << 4) - eq_(OFPPF_1GB_FD, 1 << 5) - eq_(OFPPF_10GB_FD, 1 << 6) - eq_(OFPPF_40GB_FD, 1 << 7) - eq_(OFPPF_100GB_FD, 1 << 8) - eq_(OFPPF_1TB_FD, 1 << 9) - eq_(OFPPF_OTHER, 1 << 10) - eq_(OFPPF_COPPER, 1 << 11) - eq_(OFPPF_FIBER, 1 << 12) - eq_(OFPPF_AUTONEG, 1 << 13) - eq_(OFPPF_PAUSE, 1 << 14) - eq_(OFPPF_PAUSE_ASYM, 1 << 15) + self.assertEqual(OFPPF_10MB_HD, 1 << 0) + self.assertEqual(OFPPF_10MB_FD, 1 << 1) + self.assertEqual(OFPPF_100MB_HD, 1 << 2) + self.assertEqual(OFPPF_100MB_FD, 1 << 3) + self.assertEqual(OFPPF_1GB_HD, 1 << 4) + self.assertEqual(OFPPF_1GB_FD, 1 << 5) + self.assertEqual(OFPPF_10GB_FD, 1 << 6) + self.assertEqual(OFPPF_40GB_FD, 1 << 7) + self.assertEqual(OFPPF_100GB_FD, 1 << 8) + self.assertEqual(OFPPF_1TB_FD, 1 << 9) + self.assertEqual(OFPPF_OTHER, 1 << 10) + self.assertEqual(OFPPF_COPPER, 1 << 11) + self.assertEqual(OFPPF_FIBER, 1 << 12) + self.assertEqual(OFPPF_AUTONEG, 1 << 13) + self.assertEqual(OFPPF_PAUSE, 1 << 14) + self.assertEqual(OFPPF_PAUSE_ASYM, 1 << 15) def test_struct_ofp_packet_queue(self): - eq_(OFP_PACKET_QUEUE_PACK_STR, '!IIH6x') - eq_(OFP_PACKET_QUEUE_SIZE, 16) + self.assertEqual(OFP_PACKET_QUEUE_PACK_STR, '!IIH6x') + self.assertEqual(OFP_PACKET_QUEUE_SIZE, 16) def test_enum_ofp_queue_properties(self): - eq_(OFPQT_MIN_RATE, 1) - eq_(OFPQT_MAX_RATE, 2) - eq_(OFPQT_EXPERIMENTER, 0xffff) + self.assertEqual(OFPQT_MIN_RATE, 1) + self.assertEqual(OFPQT_MAX_RATE, 2) + self.assertEqual(OFPQT_EXPERIMENTER, 0xffff) def test_struct_ofp_queue_prop_header(self): - eq_(OFP_QUEUE_PROP_HEADER_PACK_STR, '!HH4x') - eq_(OFP_QUEUE_PROP_HEADER_SIZE, 8) + self.assertEqual(OFP_QUEUE_PROP_HEADER_PACK_STR, '!HH4x') + self.assertEqual(OFP_QUEUE_PROP_HEADER_SIZE, 8) def test_struct_ofp_queue_prop_min_rate(self): - eq_(OFP_QUEUE_PROP_MIN_RATE_PACK_STR, '!H6x') - eq_(OFP_QUEUE_PROP_MIN_RATE_SIZE, 16) + self.assertEqual(OFP_QUEUE_PROP_MIN_RATE_PACK_STR, '!H6x') + self.assertEqual(OFP_QUEUE_PROP_MIN_RATE_SIZE, 16) def test_struct_ofp_queue_prop_max_rate(self): - eq_(OFP_QUEUE_PROP_MAX_RATE_PACK_STR, '!H6x') - eq_(OFP_QUEUE_PROP_MAX_RATE_SIZE, 16) + self.assertEqual(OFP_QUEUE_PROP_MAX_RATE_PACK_STR, '!H6x') + self.assertEqual(OFP_QUEUE_PROP_MAX_RATE_SIZE, 16) def test_struct_ofp_queue_prop_experimenter(self): - eq_(OFP_QUEUE_PROP_EXPERIMENTER_PACK_STR, '!I4x') - eq_(OFP_QUEUE_PROP_EXPERIMENTER_SIZE, 16) + self.assertEqual(OFP_QUEUE_PROP_EXPERIMENTER_PACK_STR, '!I4x') + self.assertEqual(OFP_QUEUE_PROP_EXPERIMENTER_SIZE, 16) def test_struct_ofp_match(self): - eq_(OFP_MATCH_PACK_STR, '!HHBBBB') - eq_(OFP_MATCH_SIZE, 8) + self.assertEqual(OFP_MATCH_PACK_STR, '!HHBBBB') + self.assertEqual(OFP_MATCH_SIZE, 8) def test_enum_ofp_match_type(self): - eq_(OFPMT_STANDARD, 0) - eq_(OFPMT_OXM, 1) + self.assertEqual(OFPMT_STANDARD, 0) + self.assertEqual(OFPMT_OXM, 1) def test_enum_ofp_oxm_class(self): - eq_(OFPXMC_NXM_0, 0x0000) - eq_(OFPXMC_NXM_1, 0x0001) - eq_(OFPXMC_OPENFLOW_BASIC, 0x8000) - eq_(OFPXMC_EXPERIMENTER, 0xFFFF) + self.assertEqual(OFPXMC_NXM_0, 0x0000) + self.assertEqual(OFPXMC_NXM_1, 0x0001) + self.assertEqual(OFPXMC_OPENFLOW_BASIC, 0x8000) + self.assertEqual(OFPXMC_EXPERIMENTER, 0xFFFF) def test_enmu_oxm_ofb_match_fields(self): - eq_(OFPXMT_OFB_IN_PORT, 0) - eq_(OFPXMT_OFB_IN_PHY_PORT, 1) - eq_(OFPXMT_OFB_METADATA, 2) - eq_(OFPXMT_OFB_ETH_DST, 3) - eq_(OFPXMT_OFB_ETH_SRC, 4) - eq_(OFPXMT_OFB_ETH_TYPE, 5) - eq_(OFPXMT_OFB_VLAN_VID, 6) - eq_(OFPXMT_OFB_VLAN_PCP, 7) - eq_(OFPXMT_OFB_IP_DSCP, 8) - eq_(OFPXMT_OFB_IP_ECN, 9) - eq_(OFPXMT_OFB_IP_PROTO, 10) - eq_(OFPXMT_OFB_IPV4_SRC, 11) - eq_(OFPXMT_OFB_IPV4_DST, 12) - eq_(OFPXMT_OFB_TCP_SRC, 13) - eq_(OFPXMT_OFB_TCP_DST, 14) - eq_(OFPXMT_OFB_UDP_SRC, 15) - eq_(OFPXMT_OFB_UDP_DST, 16) - eq_(OFPXMT_OFB_SCTP_SRC, 17) - eq_(OFPXMT_OFB_SCTP_DST, 18) - eq_(OFPXMT_OFB_ICMPV4_TYPE, 19) - eq_(OFPXMT_OFB_ICMPV4_CODE, 20) - eq_(OFPXMT_OFB_ARP_OP, 21) - eq_(OFPXMT_OFB_ARP_SPA, 22) - eq_(OFPXMT_OFB_ARP_TPA, 23) - eq_(OFPXMT_OFB_ARP_SHA, 24) - eq_(OFPXMT_OFB_ARP_THA, 25) - eq_(OFPXMT_OFB_IPV6_SRC, 26) - eq_(OFPXMT_OFB_IPV6_DST, 27) - eq_(OFPXMT_OFB_IPV6_FLABEL, 28) - eq_(OFPXMT_OFB_ICMPV6_TYPE, 29) - eq_(OFPXMT_OFB_ICMPV6_CODE, 30) - eq_(OFPXMT_OFB_IPV6_ND_TARGET, 31) - eq_(OFPXMT_OFB_IPV6_ND_SLL, 32) - eq_(OFPXMT_OFB_IPV6_ND_TLL, 33) - eq_(OFPXMT_OFB_MPLS_LABEL, 34) - eq_(OFPXMT_OFB_MPLS_TC, 35) + self.assertEqual(OFPXMT_OFB_IN_PORT, 0) + self.assertEqual(OFPXMT_OFB_IN_PHY_PORT, 1) + self.assertEqual(OFPXMT_OFB_METADATA, 2) + self.assertEqual(OFPXMT_OFB_ETH_DST, 3) + self.assertEqual(OFPXMT_OFB_ETH_SRC, 4) + self.assertEqual(OFPXMT_OFB_ETH_TYPE, 5) + self.assertEqual(OFPXMT_OFB_VLAN_VID, 6) + self.assertEqual(OFPXMT_OFB_VLAN_PCP, 7) + self.assertEqual(OFPXMT_OFB_IP_DSCP, 8) + self.assertEqual(OFPXMT_OFB_IP_ECN, 9) + self.assertEqual(OFPXMT_OFB_IP_PROTO, 10) + self.assertEqual(OFPXMT_OFB_IPV4_SRC, 11) + self.assertEqual(OFPXMT_OFB_IPV4_DST, 12) + self.assertEqual(OFPXMT_OFB_TCP_SRC, 13) + self.assertEqual(OFPXMT_OFB_TCP_DST, 14) + self.assertEqual(OFPXMT_OFB_UDP_SRC, 15) + self.assertEqual(OFPXMT_OFB_UDP_DST, 16) + self.assertEqual(OFPXMT_OFB_SCTP_SRC, 17) + self.assertEqual(OFPXMT_OFB_SCTP_DST, 18) + self.assertEqual(OFPXMT_OFB_ICMPV4_TYPE, 19) + self.assertEqual(OFPXMT_OFB_ICMPV4_CODE, 20) + self.assertEqual(OFPXMT_OFB_ARP_OP, 21) + self.assertEqual(OFPXMT_OFB_ARP_SPA, 22) + self.assertEqual(OFPXMT_OFB_ARP_TPA, 23) + self.assertEqual(OFPXMT_OFB_ARP_SHA, 24) + self.assertEqual(OFPXMT_OFB_ARP_THA, 25) + self.assertEqual(OFPXMT_OFB_IPV6_SRC, 26) + self.assertEqual(OFPXMT_OFB_IPV6_DST, 27) + self.assertEqual(OFPXMT_OFB_IPV6_FLABEL, 28) + self.assertEqual(OFPXMT_OFB_ICMPV6_TYPE, 29) + self.assertEqual(OFPXMT_OFB_ICMPV6_CODE, 30) + self.assertEqual(OFPXMT_OFB_IPV6_ND_TARGET, 31) + self.assertEqual(OFPXMT_OFB_IPV6_ND_SLL, 32) + self.assertEqual(OFPXMT_OFB_IPV6_ND_TLL, 33) + self.assertEqual(OFPXMT_OFB_MPLS_LABEL, 34) + self.assertEqual(OFPXMT_OFB_MPLS_TC, 35) def test_enum_ofp_vlan_id(self): - eq_(OFPVID_PRESENT, 0x1000) - eq_(OFPVID_NONE, 0x0000) + self.assertEqual(OFPVID_PRESENT, 0x1000) + self.assertEqual(OFPVID_NONE, 0x0000) def test_struct_ofp_oxm_experimenter_header(self): - eq_(OFP_OXM_EXPERIMENTER_HEADER_PACK_STR, '!II') - eq_(OFP_OXM_EXPERIMENTER_HEADER_SIZE, 8) + self.assertEqual(OFP_OXM_EXPERIMENTER_HEADER_PACK_STR, '!II') + self.assertEqual(OFP_OXM_EXPERIMENTER_HEADER_SIZE, 8) def test_enum_ofp_instruction_type(self): - eq_(OFPIT_GOTO_TABLE, 1) - eq_(OFPIT_WRITE_METADATA, 2) - eq_(OFPIT_WRITE_ACTIONS, 3) - eq_(OFPIT_APPLY_ACTIONS, 4) - eq_(OFPIT_CLEAR_ACTIONS, 5) - eq_(OFPIT_EXPERIMENTER, 0xFFFF) + self.assertEqual(OFPIT_GOTO_TABLE, 1) + self.assertEqual(OFPIT_WRITE_METADATA, 2) + self.assertEqual(OFPIT_WRITE_ACTIONS, 3) + self.assertEqual(OFPIT_APPLY_ACTIONS, 4) + self.assertEqual(OFPIT_CLEAR_ACTIONS, 5) + self.assertEqual(OFPIT_EXPERIMENTER, 0xFFFF) def test_struct_ofp_instruction_goto_table(self): - eq_(OFP_INSTRUCTION_GOTO_TABLE_PACK_STR, '!HHB3x') - eq_(OFP_INSTRUCTION_GOTO_TABLE_SIZE, 8) + self.assertEqual(OFP_INSTRUCTION_GOTO_TABLE_PACK_STR, '!HHB3x') + self.assertEqual(OFP_INSTRUCTION_GOTO_TABLE_SIZE, 8) def test_struct_ofp_instruction_write_metadata(self): - eq_(OFP_INSTRUCTION_WRITE_METADATA_PACK_STR, '!HH4xQQ') - eq_(OFP_INSTRUCTION_WRITE_METADATA_SIZE, 24) + self.assertEqual(OFP_INSTRUCTION_WRITE_METADATA_PACK_STR, '!HH4xQQ') + self.assertEqual(OFP_INSTRUCTION_WRITE_METADATA_SIZE, 24) def test_struct_ofp_instaruction_actions(self): - eq_(OFP_INSTRUCTION_ACTIONS_PACK_STR, '!HH4x') - eq_(OFP_INSTRUCTION_ACTIONS_SIZE, 8) + self.assertEqual(OFP_INSTRUCTION_ACTIONS_PACK_STR, '!HH4x') + self.assertEqual(OFP_INSTRUCTION_ACTIONS_SIZE, 8) def test_enum_ofp_action_type(self): - eq_(OFPAT_OUTPUT, 0) - eq_(OFPAT_COPY_TTL_OUT, 11) - eq_(OFPAT_COPY_TTL_IN, 12) - eq_(OFPAT_SET_MPLS_TTL, 15) - eq_(OFPAT_DEC_MPLS_TTL, 16) - eq_(OFPAT_PUSH_VLAN, 17) - eq_(OFPAT_POP_VLAN, 18) - eq_(OFPAT_PUSH_MPLS, 19) - eq_(OFPAT_POP_MPLS, 20) - eq_(OFPAT_SET_QUEUE, 21) - eq_(OFPAT_GROUP, 22) - eq_(OFPAT_SET_NW_TTL, 23) - eq_(OFPAT_DEC_NW_TTL, 24) - eq_(OFPAT_SET_FIELD, 25) - eq_(OFPAT_EXPERIMENTER, 0xffff) + self.assertEqual(OFPAT_OUTPUT, 0) + self.assertEqual(OFPAT_COPY_TTL_OUT, 11) + self.assertEqual(OFPAT_COPY_TTL_IN, 12) + self.assertEqual(OFPAT_SET_MPLS_TTL, 15) + self.assertEqual(OFPAT_DEC_MPLS_TTL, 16) + self.assertEqual(OFPAT_PUSH_VLAN, 17) + self.assertEqual(OFPAT_POP_VLAN, 18) + self.assertEqual(OFPAT_PUSH_MPLS, 19) + self.assertEqual(OFPAT_POP_MPLS, 20) + self.assertEqual(OFPAT_SET_QUEUE, 21) + self.assertEqual(OFPAT_GROUP, 22) + self.assertEqual(OFPAT_SET_NW_TTL, 23) + self.assertEqual(OFPAT_DEC_NW_TTL, 24) + self.assertEqual(OFPAT_SET_FIELD, 25) + self.assertEqual(OFPAT_EXPERIMENTER, 0xffff) def test_struct_ofp_action_header(self): - eq_(OFP_ACTION_HEADER_PACK_STR, '!HH4x') - eq_(OFP_ACTION_HEADER_SIZE, 8) + self.assertEqual(OFP_ACTION_HEADER_PACK_STR, '!HH4x') + self.assertEqual(OFP_ACTION_HEADER_SIZE, 8) def test_struct_ofp_action_output(self): - eq_(OFP_ACTION_OUTPUT_PACK_STR, '!HHIH6x') - eq_(OFP_ACTION_OUTPUT_SIZE, 16) + self.assertEqual(OFP_ACTION_OUTPUT_PACK_STR, '!HHIH6x') + self.assertEqual(OFP_ACTION_OUTPUT_SIZE, 16) def test_enum_ofp_controller_max_len(self): - eq_(OFPCML_MAX, 0xffe5) - eq_(OFPCML_NO_BUFFER, 0xffff) + self.assertEqual(OFPCML_MAX, 0xffe5) + self.assertEqual(OFPCML_NO_BUFFER, 0xffff) def test_struct_ofp_action_group(self): - eq_(OFP_ACTION_GROUP_PACK_STR, '!HHI') - eq_(OFP_ACTION_GROUP_SIZE, 8) + self.assertEqual(OFP_ACTION_GROUP_PACK_STR, '!HHI') + self.assertEqual(OFP_ACTION_GROUP_SIZE, 8) def test_struct_ofp_action_set_queue(self): - eq_(OFP_ACTION_SET_QUEUE_PACK_STR, '!HHI') - eq_(OFP_ACTION_SET_QUEUE_SIZE, 8) + self.assertEqual(OFP_ACTION_SET_QUEUE_PACK_STR, '!HHI') + self.assertEqual(OFP_ACTION_SET_QUEUE_SIZE, 8) def test_struct_ofp_aciton_mpls_ttl(self): - eq_(OFP_ACTION_MPLS_TTL_PACK_STR, '!HHB3x') - eq_(OFP_ACTION_MPLS_TTL_SIZE, 8) + self.assertEqual(OFP_ACTION_MPLS_TTL_PACK_STR, '!HHB3x') + self.assertEqual(OFP_ACTION_MPLS_TTL_SIZE, 8) def test_struct_ofp_action_nw_ttl(self): - eq_(OFP_ACTION_NW_TTL_PACK_STR, '!HHB3x') - eq_(OFP_ACTION_NW_TTL_SIZE, 8) + self.assertEqual(OFP_ACTION_NW_TTL_PACK_STR, '!HHB3x') + self.assertEqual(OFP_ACTION_NW_TTL_SIZE, 8) def test_struct_ofp_action_push(self): - eq_(OFP_ACTION_PUSH_PACK_STR, '!HHH2x') - eq_(OFP_ACTION_PUSH_SIZE, 8) + self.assertEqual(OFP_ACTION_PUSH_PACK_STR, '!HHH2x') + self.assertEqual(OFP_ACTION_PUSH_SIZE, 8) def test_struct_ofp_action_pop_mpls(self): - eq_(OFP_ACTION_POP_MPLS_PACK_STR, '!HHH2x') - eq_(OFP_ACTION_POP_MPLS_SIZE, 8) + self.assertEqual(OFP_ACTION_POP_MPLS_PACK_STR, '!HHH2x') + self.assertEqual(OFP_ACTION_POP_MPLS_SIZE, 8) def test_struct_ofp_action_set_field(self): - eq_(OFP_ACTION_SET_FIELD_PACK_STR, '!HH4B') - eq_(OFP_ACTION_SET_FIELD_SIZE, 8) + self.assertEqual(OFP_ACTION_SET_FIELD_PACK_STR, '!HH4B') + self.assertEqual(OFP_ACTION_SET_FIELD_SIZE, 8) def test_struct_ofp_action_experimenter_header(self): - eq_(OFP_ACTION_EXPERIMENTER_HEADER_PACK_STR, '!HHI') - eq_(OFP_ACTION_EXPERIMENTER_HEADER_SIZE, 8) + self.assertEqual(OFP_ACTION_EXPERIMENTER_HEADER_PACK_STR, '!HHI') + self.assertEqual(OFP_ACTION_EXPERIMENTER_HEADER_SIZE, 8) def test_struct_ofp_switch_feature(self): - eq_(OFP_SWITCH_FEATURES_PACK_STR, '!QIB3xII') - eq_(OFP_SWITCH_FEATURES_SIZE, 32) + self.assertEqual(OFP_SWITCH_FEATURES_PACK_STR, '!QIB3xII') + self.assertEqual(OFP_SWITCH_FEATURES_SIZE, 32) def test_enum_ofp_capabilities(self): - eq_(OFPC_FLOW_STATS, 1 << 0) - eq_(OFPC_TABLE_STATS, 1 << 1) - eq_(OFPC_PORT_STATS, 1 << 2) - eq_(OFPC_GROUP_STATS, 1 << 3) - eq_(OFPC_IP_REASM, 1 << 5) - eq_(OFPC_QUEUE_STATS, 1 << 6) - eq_(OFPC_PORT_BLOCKED, 1 << 8) + self.assertEqual(OFPC_FLOW_STATS, 1 << 0) + self.assertEqual(OFPC_TABLE_STATS, 1 << 1) + self.assertEqual(OFPC_PORT_STATS, 1 << 2) + self.assertEqual(OFPC_GROUP_STATS, 1 << 3) + self.assertEqual(OFPC_IP_REASM, 1 << 5) + self.assertEqual(OFPC_QUEUE_STATS, 1 << 6) + self.assertEqual(OFPC_PORT_BLOCKED, 1 << 8) def test_struct_ofp_switch_config(self): - eq_(OFP_SWITCH_CONFIG_PACK_STR, '!HH') - eq_(OFP_SWITCH_CONFIG_SIZE, 12) + self.assertEqual(OFP_SWITCH_CONFIG_PACK_STR, '!HH') + self.assertEqual(OFP_SWITCH_CONFIG_SIZE, 12) def test_enum_ofp_config_flags(self): - eq_(OFPC_FRAG_NORMAL, 0) - eq_(OFPC_FRAG_DROP, 1 << 0) - eq_(OFPC_FRAG_REASM, 1 << 1) - eq_(OFPC_FRAG_MASK, 3) - eq_(OFPC_INVALID_TTL_TO_CONTROLLER, 1 << 2) + self.assertEqual(OFPC_FRAG_NORMAL, 0) + self.assertEqual(OFPC_FRAG_DROP, 1 << 0) + self.assertEqual(OFPC_FRAG_REASM, 1 << 1) + self.assertEqual(OFPC_FRAG_MASK, 3) + self.assertEqual(OFPC_INVALID_TTL_TO_CONTROLLER, 1 << 2) def test_enum_ofp_table(self): - eq_(OFPTT_MAX, 0xfe) - eq_(OFPTT_ALL, 0xff) + self.assertEqual(OFPTT_MAX, 0xfe) + self.assertEqual(OFPTT_ALL, 0xff) def test_struct_ofp_table_mod(self): - eq_(OFP_TABLE_MOD_PACK_STR, '!B3xI') - eq_(OFP_TABLE_MOD_SIZE, 16) + self.assertEqual(OFP_TABLE_MOD_PACK_STR, '!B3xI') + self.assertEqual(OFP_TABLE_MOD_SIZE, 16) def test_enum_ofp_table_config(self): - eq_(OFPTC_TABLE_MISS_CONTROLLER, 0) - eq_(OFPTC_TABLE_MISS_CONTINUE, 1 << 0) - eq_(OFPTC_TABLE_MISS_DROP, 1 << 1) - eq_(OFPTC_TABLE_MISS_MASK, 3) + self.assertEqual(OFPTC_TABLE_MISS_CONTROLLER, 0) + self.assertEqual(OFPTC_TABLE_MISS_CONTINUE, 1 << 0) + self.assertEqual(OFPTC_TABLE_MISS_DROP, 1 << 1) + self.assertEqual(OFPTC_TABLE_MISS_MASK, 3) def test_struct_ofp_flow_mod(self): - eq_(OFP_FLOW_MOD_PACK_STR, '!QQBBHHHIIIH2xHHBBBB') - eq_(OFP_FLOW_MOD_SIZE, 56) + self.assertEqual(OFP_FLOW_MOD_PACK_STR, '!QQBBHHHIIIH2xHHBBBB') + self.assertEqual(OFP_FLOW_MOD_SIZE, 56) def test_enum_ofp_flow_mod_command(self): - eq_(OFPFC_ADD, 0) - eq_(OFPFC_MODIFY, 1) - eq_(OFPFC_MODIFY_STRICT, 2) - eq_(OFPFC_DELETE, 3) - eq_(OFPFC_DELETE_STRICT, 4) + self.assertEqual(OFPFC_ADD, 0) + self.assertEqual(OFPFC_MODIFY, 1) + self.assertEqual(OFPFC_MODIFY_STRICT, 2) + self.assertEqual(OFPFC_DELETE, 3) + self.assertEqual(OFPFC_DELETE_STRICT, 4) def test_enum_ofp_flow_mod_flags(self): - eq_(OFPFF_SEND_FLOW_REM, 1 << 0) - eq_(OFPFF_CHECK_OVERLAP, 1 << 1) - eq_(OFPFF_RESET_COUNTS, 1 << 2) + self.assertEqual(OFPFF_SEND_FLOW_REM, 1 << 0) + self.assertEqual(OFPFF_CHECK_OVERLAP, 1 << 1) + self.assertEqual(OFPFF_RESET_COUNTS, 1 << 2) def test_struct_ofp_group_mod(self): - eq_(OFP_GROUP_MOD_PACK_STR, '!HBxI') - eq_(OFP_GROUP_MOD_SIZE, 16) + self.assertEqual(OFP_GROUP_MOD_PACK_STR, '!HBxI') + self.assertEqual(OFP_GROUP_MOD_SIZE, 16) # same to OFPP_* def test_enum_ofp_group(self): - eq_(OFPG_MAX, 0xffffff00) - eq_(OFPG_ALL, 0xfffffffc) - eq_(OFPG_ANY, 0xffffffff) + self.assertEqual(OFPG_MAX, 0xffffff00) + self.assertEqual(OFPG_ALL, 0xfffffffc) + self.assertEqual(OFPG_ANY, 0xffffffff) def test_enum_ofp_group_mod_command(self): - eq_(OFPGC_ADD, 0) - eq_(OFPGC_MODIFY, 1) - eq_(OFPGC_DELETE, 2) + self.assertEqual(OFPGC_ADD, 0) + self.assertEqual(OFPGC_MODIFY, 1) + self.assertEqual(OFPGC_DELETE, 2) def test_enum_ofp_group_type(self): - eq_(OFPGT_ALL, 0) - eq_(OFPGT_SELECT, 1) - eq_(OFPGT_INDIRECT, 2) - eq_(OFPGT_FF, 3) + self.assertEqual(OFPGT_ALL, 0) + self.assertEqual(OFPGT_SELECT, 1) + self.assertEqual(OFPGT_INDIRECT, 2) + self.assertEqual(OFPGT_FF, 3) def test_struct_ofp_bucket(self): - eq_(OFP_BUCKET_PACK_STR, '!HHII4x') - eq_(OFP_BUCKET_SIZE, 16) + self.assertEqual(OFP_BUCKET_PACK_STR, '!HHII4x') + self.assertEqual(OFP_BUCKET_SIZE, 16) def test_struct_ofp_port_mod(self): - eq_(OFP_PORT_MOD_PACK_STR, '!I4x6s2xIII4x') - eq_(OFP_PORT_MOD_SIZE, 40) + self.assertEqual(OFP_PORT_MOD_PACK_STR, '!I4x6s2xIII4x') + self.assertEqual(OFP_PORT_MOD_SIZE, 40) def test_sturct_ofp_stats_request(self): - eq_(OFP_STATS_REQUEST_PACK_STR, '!HH4x') - eq_(OFP_STATS_REQUEST_SIZE, 16) + self.assertEqual(OFP_STATS_REQUEST_PACK_STR, '!HH4x') + self.assertEqual(OFP_STATS_REQUEST_SIZE, 16) - # OFPSF_REQ_* flags (none yet defined). + # OFPSF_Rself.assertEqual* flags (none yet defined). # The only value defined for flags in a reply is whether more # replies will follow this one - this has the value 0x0001. def test_enum_ofp_stats_reply_flags(self): - eq_(OFPSF_REPLY_MORE, 0x0001) + self.assertEqual(OFPSF_REPLY_MORE, 0x0001) def test_struct_ofp_stats_reply(self): - eq_(OFP_STATS_REPLY_PACK_STR, '!HH4x') - eq_(OFP_STATS_REPLY_SIZE, 16) + self.assertEqual(OFP_STATS_REPLY_PACK_STR, '!HH4x') + self.assertEqual(OFP_STATS_REPLY_SIZE, 16) def test_enum_ofp_stats_types(self): - eq_(OFPST_DESC, 0) - eq_(OFPST_FLOW, 1) - eq_(OFPST_AGGREGATE, 2) - eq_(OFPST_TABLE, 3) - eq_(OFPST_PORT, 4) - eq_(OFPST_QUEUE, 5) - eq_(OFPST_GROUP, 6) - eq_(OFPST_GROUP_DESC, 7) - eq_(OFPST_GROUP_FEATURES, 8) - eq_(OFPST_EXPERIMENTER, 0xffff) + self.assertEqual(OFPST_DESC, 0) + self.assertEqual(OFPST_FLOW, 1) + self.assertEqual(OFPST_AGGREGATE, 2) + self.assertEqual(OFPST_TABLE, 3) + self.assertEqual(OFPST_PORT, 4) + self.assertEqual(OFPST_QUEUE, 5) + self.assertEqual(OFPST_GROUP, 6) + self.assertEqual(OFPST_GROUP_DESC, 7) + self.assertEqual(OFPST_GROUP_FEATURES, 8) + self.assertEqual(OFPST_EXPERIMENTER, 0xffff) def test_struct_ofp_desc_stats(self): - eq_(OFP_DESC_STATS_PACK_STR, '!256s256s256s32s256s') - eq_(OFP_DESC_STATS_SIZE, 1056) + self.assertEqual(OFP_DESC_STATS_PACK_STR, '!256s256s256s32s256s') + self.assertEqual(OFP_DESC_STATS_SIZE, 1056) def test_struct_ofp_flow_stats_request(self): - eq_(OFP_FLOW_STATS_REQUEST_PACK_STR, '!B3xII4xQQ') - eq_(OFP_FLOW_STATS_REQUEST_SIZE, 40) + self.assertEqual(OFP_FLOW_STATS_REQUEST_PACK_STR, '!B3xII4xQQ') + self.assertEqual(OFP_FLOW_STATS_REQUEST_SIZE, 40) def test_struct_ofp_flow_stats(self): - eq_(OFP_FLOW_STATS_PACK_STR, '!HBxIIHHH6xQQQ') - eq_(OFP_FLOW_STATS_SIZE, 56) + self.assertEqual(OFP_FLOW_STATS_PACK_STR, '!HBxIIHHH6xQQQ') + self.assertEqual(OFP_FLOW_STATS_SIZE, 56) def test_struct_ofp_aggregate_stats_request(self): - eq_(OFP_AGGREGATE_STATS_REQUEST_PACK_STR, '!B3xII4xQQ') - eq_(OFP_AGGREGATE_STATS_REQUEST_SIZE, 40) + self.assertEqual(OFP_AGGREGATE_STATS_REQUEST_PACK_STR, '!B3xII4xQQ') + self.assertEqual(OFP_AGGREGATE_STATS_REQUEST_SIZE, 40) def test_struct_ofp_aggregate_stats_reply(self): - eq_(OFP_AGGREGATE_STATS_REPLY_PACK_STR, '!QQI4x') - eq_(OFP_AGGREGATE_STATS_REPLY_SIZE, 24) + self.assertEqual(OFP_AGGREGATE_STATS_REPLY_PACK_STR, '!QQI4x') + self.assertEqual(OFP_AGGREGATE_STATS_REPLY_SIZE, 24) def test_sturct_ofp_table_stats(self): - eq_(OFP_TABLE_STATS_PACK_STR, '!B7x32sQQIIQQQQIIIIQQ') - eq_(OFP_TABLE_STATS_SIZE, 128) + self.assertEqual(OFP_TABLE_STATS_PACK_STR, '!B7x32sQQIIQQQQIIIIQQ') + self.assertEqual(OFP_TABLE_STATS_SIZE, 128) def test_struct_ofp_port_stats_request(self): - eq_(OFP_PORT_STATS_REQUEST_PACK_STR, '!I4x') - eq_(OFP_PORT_STATS_REQUEST_SIZE, 8) + self.assertEqual(OFP_PORT_STATS_REQUEST_PACK_STR, '!I4x') + self.assertEqual(OFP_PORT_STATS_REQUEST_SIZE, 8) def test_struct_ofp_port_stats(self): - eq_(OFP_PORT_STATS_PACK_STR, '!I4xQQQQQQQQQQQQ') - eq_(OFP_PORT_STATS_SIZE, 104) + self.assertEqual(OFP_PORT_STATS_PACK_STR, '!I4xQQQQQQQQQQQQ') + self.assertEqual(OFP_PORT_STATS_SIZE, 104) def test_struct_ofp_queue_stats_request(self): - eq_(OFP_QUEUE_STATS_REQUEST_PACK_STR, '!II') - eq_(OFP_QUEUE_STATS_REQUEST_SIZE, 8) + self.assertEqual(OFP_QUEUE_STATS_REQUEST_PACK_STR, '!II') + self.assertEqual(OFP_QUEUE_STATS_REQUEST_SIZE, 8) def test_struct_ofp_queue_stats(self): - eq_(OFP_QUEUE_STATS_PACK_STR, '!IIQQQ') - eq_(OFP_QUEUE_STATS_SIZE, 32) + self.assertEqual(OFP_QUEUE_STATS_PACK_STR, '!IIQQQ') + self.assertEqual(OFP_QUEUE_STATS_SIZE, 32) def test_struct_ofp_group_stats_request(self): - eq_(OFP_GROUP_STATS_REQUEST_PACK_STR, '!I4x') - eq_(OFP_GROUP_STATS_REQUEST_SIZE, 8) + self.assertEqual(OFP_GROUP_STATS_REQUEST_PACK_STR, '!I4x') + self.assertEqual(OFP_GROUP_STATS_REQUEST_SIZE, 8) def test_struct_ofp_group_stats(self): - eq_(OFP_GROUP_STATS_PACK_STR, '!H2xII4xQQ') - eq_(OFP_GROUP_STATS_SIZE, 32) + self.assertEqual(OFP_GROUP_STATS_PACK_STR, '!H2xII4xQQ') + self.assertEqual(OFP_GROUP_STATS_SIZE, 32) def test_struct_ofp_bucket_counter(self): - eq_(OFP_BUCKET_COUNTER_PACK_STR, '!QQ') - eq_(OFP_BUCKET_COUNTER_SIZE, 16) + self.assertEqual(OFP_BUCKET_COUNTER_PACK_STR, '!QQ') + self.assertEqual(OFP_BUCKET_COUNTER_SIZE, 16) def test_struct_ofp_group_desc_stats(self): - eq_(OFP_GROUP_DESC_STATS_PACK_STR, '!HBxI') - eq_(OFP_GROUP_DESC_STATS_SIZE, 8) + self.assertEqual(OFP_GROUP_DESC_STATS_PACK_STR, '!HBxI') + self.assertEqual(OFP_GROUP_DESC_STATS_SIZE, 8) def test_struct_ofp_group_features_stats(self): - eq_(OFP_GROUP_FEATURES_STATS_PACK_STR, '!II4I4I') - eq_(OFP_GROUP_FEATURES_STATS_SIZE, 40) + self.assertEqual(OFP_GROUP_FEATURES_STATS_PACK_STR, '!II4I4I') + self.assertEqual(OFP_GROUP_FEATURES_STATS_SIZE, 40) def test_enmu_ofp_group_capabilities(self): - eq_(OFPGFC_SELECT_WEIGHT, 1 << 0) - eq_(OFPGFC_SELECT_LIVENESS, 1 << 1) - eq_(OFPGFC_CHAINING, 1 << 2) - eq_(OFPGFC_CHAINING_CHECKS, 1 << 3) + self.assertEqual(OFPGFC_SELECT_WEIGHT, 1 << 0) + self.assertEqual(OFPGFC_SELECT_LIVENESS, 1 << 1) + self.assertEqual(OFPGFC_CHAINING, 1 << 2) + self.assertEqual(OFPGFC_CHAINING_CHECKS, 1 << 3) def test_struct_ofp_experimenter_stats_header(self): - eq_(OFP_EXPERIMENTER_STATS_HEADER_PACK_STR, '!II') - eq_(OFP_EXPERIMENTER_STATS_HEADER_SIZE, 8) + self.assertEqual(OFP_EXPERIMENTER_STATS_HEADER_PACK_STR, '!II') + self.assertEqual(OFP_EXPERIMENTER_STATS_HEADER_SIZE, 8) def test_struct_opf_queue_get_config_request(self): - eq_(OFP_QUEUE_GET_CONFIG_REQUEST_PACK_STR, '!I4x') - eq_(OFP_QUEUE_GET_CONFIG_REQUEST_SIZE, 16) + self.assertEqual(OFP_QUEUE_GET_CONFIG_REQUEST_PACK_STR, '!I4x') + self.assertEqual(OFP_QUEUE_GET_CONFIG_REQUEST_SIZE, 16) def test_struct_ofp_queue_get_config_reply(self): - eq_(OFP_QUEUE_GET_CONFIG_REPLY_PACK_STR, '!I4x') - eq_(OFP_QUEUE_GET_CONFIG_REPLY_SIZE, 16) + self.assertEqual(OFP_QUEUE_GET_CONFIG_REPLY_PACK_STR, '!I4x') + self.assertEqual(OFP_QUEUE_GET_CONFIG_REPLY_SIZE, 16) def test_struct_ofp_packet_out(self): - eq_(OFP_PACKET_OUT_PACK_STR, '!IIH6x') - eq_(OFP_PACKET_OUT_SIZE, 24) + self.assertEqual(OFP_PACKET_OUT_PACK_STR, '!IIH6x') + self.assertEqual(OFP_PACKET_OUT_SIZE, 24) def test_struct_ofp_role_request(self): - eq_(OFP_ROLE_REQUEST_PACK_STR, '!I4xQ') - eq_(OFP_ROLE_REQUEST_SIZE, 24) + self.assertEqual(OFP_ROLE_REQUEST_PACK_STR, '!I4xQ') + self.assertEqual(OFP_ROLE_REQUEST_SIZE, 24) def test_enum_ofp_controller_role(self): - eq_(OFPCR_ROLE_NOCHANGE, 0) - eq_(OFPCR_ROLE_EQUAL, 1) - eq_(OFPCR_ROLE_MASTER, 2) - eq_(OFPCR_ROLE_SLAVE, 3) + self.assertEqual(OFPCR_ROLE_NOCHANGE, 0) + self.assertEqual(OFPCR_ROLE_EQUAL, 1) + self.assertEqual(OFPCR_ROLE_MASTER, 2) + self.assertEqual(OFPCR_ROLE_SLAVE, 3) def test_struct_ofp_packet_in(self): - eq_(OFP_PACKET_IN_PACK_STR, '!IHBB') - eq_(OFP_PACKET_IN_SIZE, 24) + self.assertEqual(OFP_PACKET_IN_PACK_STR, '!IHBB') + self.assertEqual(OFP_PACKET_IN_SIZE, 24) def test_enum_ofp_packet_in_reason(self): - eq_(OFPR_NO_MATCH, 0) - eq_(OFPR_ACTION, 1) - eq_(OFPR_INVALID_TTL, 2) + self.assertEqual(OFPR_NO_MATCH, 0) + self.assertEqual(OFPR_ACTION, 1) + self.assertEqual(OFPR_INVALID_TTL, 2) def test_struct_ofp_flow_removed(self): - eq_(OFP_FLOW_REMOVED_PACK_STR, '!QHBBIIHHQQHHBBBB') - eq_(OFP_FLOW_REMOVED_PACK_STR0, '!QHBBIIHHQQ') - eq_(OFP_FLOW_REMOVED_SIZE, 56) + self.assertEqual(OFP_FLOW_REMOVED_PACK_STR, '!QHBBIIHHQQHHBBBB') + self.assertEqual(OFP_FLOW_REMOVED_PACK_STR0, '!QHBBIIHHQQ') + self.assertEqual(OFP_FLOW_REMOVED_SIZE, 56) def test_enum_ofp_flow_removed_reason(self): - eq_(OFPRR_IDLE_TIMEOUT, 0) - eq_(OFPRR_HARD_TIMEOUT, 1) - eq_(OFPRR_DELETE, 2) - eq_(OFPRR_GROUP_DELETE, 3) + self.assertEqual(OFPRR_IDLE_TIMEOUT, 0) + self.assertEqual(OFPRR_HARD_TIMEOUT, 1) + self.assertEqual(OFPRR_DELETE, 2) + self.assertEqual(OFPRR_GROUP_DELETE, 3) def test_struct_ofp_port_status(self): - eq_(OFP_PORT_STATUS_PACK_STR, '!B7xI4x6s2x16sIIIIIIII') - eq_(OFP_PORT_STATUS_DESC_OFFSET, 16) - eq_(OFP_PORT_STATUS_SIZE, 80) + self.assertEqual(OFP_PORT_STATUS_PACK_STR, '!B7xI4x6s2x16sIIIIIIII') + self.assertEqual(OFP_PORT_STATUS_DESC_OFFSET, 16) + self.assertEqual(OFP_PORT_STATUS_SIZE, 80) def test_enum_ofp_port_reason(self): - eq_(OFPPR_ADD, 0) - eq_(OFPPR_DELETE, 1) - eq_(OFPPR_MODIFY, 2) + self.assertEqual(OFPPR_ADD, 0) + self.assertEqual(OFPPR_DELETE, 1) + self.assertEqual(OFPPR_MODIFY, 2) def test_struct_ofp_error_msg(self): - eq_(OFP_ERROR_MSG_PACK_STR, '!HH') - eq_(OFP_ERROR_MSG_SIZE, 12) + self.assertEqual(OFP_ERROR_MSG_PACK_STR, '!HH') + self.assertEqual(OFP_ERROR_MSG_SIZE, 12) def test_enum_ofp_error_type(self): - eq_(OFPET_HELLO_FAILED, 0) - eq_(OFPET_BAD_REQUEST, 1) - eq_(OFPET_BAD_ACTION, 2) - eq_(OFPET_BAD_INSTRUCTION, 3) - eq_(OFPET_BAD_MATCH, 4) - eq_(OFPET_FLOW_MOD_FAILED, 5) - eq_(OFPET_GROUP_MOD_FAILED, 6) - eq_(OFPET_PORT_MOD_FAILED, 7) - eq_(OFPET_TABLE_MOD_FAILED, 8) - eq_(OFPET_QUEUE_OP_FAILED, 9) - eq_(OFPET_SWITCH_CONFIG_FAILED, 10) - eq_(OFPET_ROLE_REQUEST_FAILED, 11) - eq_(OFPET_EXPERIMENTER, 0xffff) + self.assertEqual(OFPET_HELLO_FAILED, 0) + self.assertEqual(OFPET_BAD_REQUEST, 1) + self.assertEqual(OFPET_BAD_ACTION, 2) + self.assertEqual(OFPET_BAD_INSTRUCTION, 3) + self.assertEqual(OFPET_BAD_MATCH, 4) + self.assertEqual(OFPET_FLOW_MOD_FAILED, 5) + self.assertEqual(OFPET_GROUP_MOD_FAILED, 6) + self.assertEqual(OFPET_PORT_MOD_FAILED, 7) + self.assertEqual(OFPET_TABLE_MOD_FAILED, 8) + self.assertEqual(OFPET_QUEUE_OP_FAILED, 9) + self.assertEqual(OFPET_SWITCH_CONFIG_FAILED, 10) + self.assertEqual(OFPET_ROLE_REQUEST_FAILED, 11) + self.assertEqual(OFPET_EXPERIMENTER, 0xffff) def test_enum_ofp_hello_failed_code(self): - eq_(OFPHFC_INCOMPATIBLE, 0) - eq_(OFPHFC_EPERM, 1) + self.assertEqual(OFPHFC_INCOMPATIBLE, 0) + self.assertEqual(OFPHFC_EPERM, 1) def test_enum_ofp_bad_request_code(self): - eq_(OFPBRC_BAD_VERSION, 0) - eq_(OFPBRC_BAD_TYPE, 1) - eq_(OFPBRC_BAD_STAT, 2) - eq_(OFPBRC_BAD_EXPERIMENTER, 3) - eq_(OFPBRC_BAD_EXP_TYPE, 4) - eq_(OFPBRC_EPERM, 5) - eq_(OFPBRC_BAD_LEN, 6) - eq_(OFPBRC_BUFFER_EMPTY, 7) - eq_(OFPBRC_BUFFER_UNKNOWN, 8) - eq_(OFPBRC_BAD_TABLE_ID, 9) - eq_(OFPBRC_IS_SLAVE, 10) - eq_(OFPBRC_BAD_PORT, 11) - eq_(OFPBRC_BAD_PACKET, 12) + self.assertEqual(OFPBRC_BAD_VERSION, 0) + self.assertEqual(OFPBRC_BAD_TYPE, 1) + self.assertEqual(OFPBRC_BAD_STAT, 2) + self.assertEqual(OFPBRC_BAD_EXPERIMENTER, 3) + self.assertEqual(OFPBRC_BAD_EXP_TYPE, 4) + self.assertEqual(OFPBRC_EPERM, 5) + self.assertEqual(OFPBRC_BAD_LEN, 6) + self.assertEqual(OFPBRC_BUFFER_EMPTY, 7) + self.assertEqual(OFPBRC_BUFFER_UNKNOWN, 8) + self.assertEqual(OFPBRC_BAD_TABLE_ID, 9) + self.assertEqual(OFPBRC_IS_SLAVE, 10) + self.assertEqual(OFPBRC_BAD_PORT, 11) + self.assertEqual(OFPBRC_BAD_PACKET, 12) def test_enum_ofp_bad_action_code(self): - eq_(OFPBAC_BAD_TYPE, 0) - eq_(OFPBAC_BAD_LEN, 1) - eq_(OFPBAC_BAD_EXPERIMENTER, 2) - eq_(OFPBAC_BAD_EXP_TYPE, 3) - eq_(OFPBAC_BAD_OUT_PORT, 4) - eq_(OFPBAC_BAD_ARGUMENT, 5) - eq_(OFPBAC_EPERM, 6) - eq_(OFPBAC_TOO_MANY, 7) - eq_(OFPBAC_BAD_QUEUE, 8) - eq_(OFPBAC_BAD_OUT_GROUP, 9) - eq_(OFPBAC_MATCH_INCONSISTENT, 10) - eq_(OFPBAC_UNSUPPORTED_ORDER, 11) - eq_(OFPBAC_BAD_TAG, 12) - eq_(OFPBAC_BAD_SET_TYPE, 13) - eq_(OFPBAC_BAD_SET_LEN, 14) - eq_(OFPBAC_BAD_SET_ARGUMENT, 15) + self.assertEqual(OFPBAC_BAD_TYPE, 0) + self.assertEqual(OFPBAC_BAD_LEN, 1) + self.assertEqual(OFPBAC_BAD_EXPERIMENTER, 2) + self.assertEqual(OFPBAC_BAD_EXP_TYPE, 3) + self.assertEqual(OFPBAC_BAD_OUT_PORT, 4) + self.assertEqual(OFPBAC_BAD_ARGUMENT, 5) + self.assertEqual(OFPBAC_EPERM, 6) + self.assertEqual(OFPBAC_TOO_MANY, 7) + self.assertEqual(OFPBAC_BAD_QUEUE, 8) + self.assertEqual(OFPBAC_BAD_OUT_GROUP, 9) + self.assertEqual(OFPBAC_MATCH_INCONSISTENT, 10) + self.assertEqual(OFPBAC_UNSUPPORTED_ORDER, 11) + self.assertEqual(OFPBAC_BAD_TAG, 12) + self.assertEqual(OFPBAC_BAD_SET_TYPE, 13) + self.assertEqual(OFPBAC_BAD_SET_LEN, 14) + self.assertEqual(OFPBAC_BAD_SET_ARGUMENT, 15) def test_enum_ofp_bad_instruction_code(self): - eq_(OFPBIC_UNKNOWN_INST, 0) - eq_(OFPBIC_UNSUP_INST, 1) - eq_(OFPBIC_BAD_TABLE_ID, 2) - eq_(OFPBIC_UNSUP_METADATA, 3) - eq_(OFPBIC_UNSUP_METADATA_MASK, 4) - eq_(OFPBIC_BAD_EXPERIMENTER, 5) - eq_(OFPBIC_BAD_EXP_TYPE, 6) - eq_(OFPBIC_BAD_LEN, 7) - eq_(OFPBIC_EPERM, 8) + self.assertEqual(OFPBIC_UNKNOWN_INST, 0) + self.assertEqual(OFPBIC_UNSUP_INST, 1) + self.assertEqual(OFPBIC_BAD_TABLE_ID, 2) + self.assertEqual(OFPBIC_UNSUP_METADATA, 3) + self.assertEqual(OFPBIC_UNSUP_METADATA_MASK, 4) + self.assertEqual(OFPBIC_BAD_EXPERIMENTER, 5) + self.assertEqual(OFPBIC_BAD_EXP_TYPE, 6) + self.assertEqual(OFPBIC_BAD_LEN, 7) + self.assertEqual(OFPBIC_EPERM, 8) def test_enum_ofp_bad_match_code(self): - eq_(OFPBMC_BAD_TYPE, 0) - eq_(OFPBMC_BAD_LEN, 1) - eq_(OFPBMC_BAD_TAG, 2) - eq_(OFPBMC_BAD_DL_ADDR_MASK, 3) - eq_(OFPBMC_BAD_NW_ADDR_MASK, 4) - eq_(OFPBMC_BAD_WILDCARDS, 5) - eq_(OFPBMC_BAD_FIELD, 6) - eq_(OFPBMC_BAD_VALUE, 7) - eq_(OFPBMC_BAD_MASK, 8) - eq_(OFPBMC_BAD_PREREQ, 9) - eq_(OFPBMC_DUP_FIELD, 10) - eq_(OFPBMC_EPERM, 11) + self.assertEqual(OFPBMC_BAD_TYPE, 0) + self.assertEqual(OFPBMC_BAD_LEN, 1) + self.assertEqual(OFPBMC_BAD_TAG, 2) + self.assertEqual(OFPBMC_BAD_DL_ADDR_MASK, 3) + self.assertEqual(OFPBMC_BAD_NW_ADDR_MASK, 4) + self.assertEqual(OFPBMC_BAD_WILDCARDS, 5) + self.assertEqual(OFPBMC_BAD_FIELD, 6) + self.assertEqual(OFPBMC_BAD_VALUE, 7) + self.assertEqual(OFPBMC_BAD_MASK, 8) + self.assertEqual(OFPBMC_BAD_PREREQ, 9) + self.assertEqual(OFPBMC_DUP_FIELD, 10) + self.assertEqual(OFPBMC_EPERM, 11) def test_enum_ofp_flow_mod_failed_code(self): - eq_(OFPFMFC_UNKNOWN, 0) - eq_(OFPFMFC_TABLE_FULL, 1) - eq_(OFPFMFC_BAD_TABLE_ID, 2) - eq_(OFPFMFC_OVERLAP, 3) - eq_(OFPFMFC_EPERM, 4) - eq_(OFPFMFC_BAD_TIMEOUT, 5) - eq_(OFPFMFC_BAD_COMMAND, 6) - eq_(OFPFMFC_BAD_FLAGS, 7) + self.assertEqual(OFPFMFC_UNKNOWN, 0) + self.assertEqual(OFPFMFC_TABLE_FULL, 1) + self.assertEqual(OFPFMFC_BAD_TABLE_ID, 2) + self.assertEqual(OFPFMFC_OVERLAP, 3) + self.assertEqual(OFPFMFC_EPERM, 4) + self.assertEqual(OFPFMFC_BAD_TIMEOUT, 5) + self.assertEqual(OFPFMFC_BAD_COMMAND, 6) + self.assertEqual(OFPFMFC_BAD_FLAGS, 7) def test_enum_ofp_group_mod_failed_code(self): - eq_(OFPGMFC_GROUP_EXISTS, 0) - eq_(OFPGMFC_INVALID_GROUP, 1) - eq_(OFPGMFC_WEIGHT_UNSUPPORTED, 2) - eq_(OFPGMFC_OUT_OF_GROUPS, 3) - eq_(OFPGMFC_OUT_OF_BUCKETS, 4) - eq_(OFPGMFC_CHAINING_UNSUPPORTED, 5) - eq_(OFPGMFC_WATCH_UNSUPPORTED, 6) - eq_(OFPGMFC_LOOP, 7) - eq_(OFPGMFC_UNKNOWN_GROUP, 8) - eq_(OFPGMFC_CHAINED_GROUP, 9) - eq_(OFPGMFC_BAD_TYPE, 10) - eq_(OFPGMFC_BAD_COMMAND, 11) - eq_(OFPGMFC_BAD_BUCKET, 12) - eq_(OFPGMFC_BAD_WATCH, 13) - eq_(OFPGMFC_EPERM, 14) + self.assertEqual(OFPGMFC_GROUP_EXISTS, 0) + self.assertEqual(OFPGMFC_INVALID_GROUP, 1) + self.assertEqual(OFPGMFC_WEIGHT_UNSUPPORTED, 2) + self.assertEqual(OFPGMFC_OUT_OF_GROUPS, 3) + self.assertEqual(OFPGMFC_OUT_OF_BUCKETS, 4) + self.assertEqual(OFPGMFC_CHAINING_UNSUPPORTED, 5) + self.assertEqual(OFPGMFC_WATCH_UNSUPPORTED, 6) + self.assertEqual(OFPGMFC_LOOP, 7) + self.assertEqual(OFPGMFC_UNKNOWN_GROUP, 8) + self.assertEqual(OFPGMFC_CHAINED_GROUP, 9) + self.assertEqual(OFPGMFC_BAD_TYPE, 10) + self.assertEqual(OFPGMFC_BAD_COMMAND, 11) + self.assertEqual(OFPGMFC_BAD_BUCKET, 12) + self.assertEqual(OFPGMFC_BAD_WATCH, 13) + self.assertEqual(OFPGMFC_EPERM, 14) def test_enum_ofp_port_mod_failed_code(self): - eq_(OFPPMFC_BAD_PORT, 0) - eq_(OFPPMFC_BAD_HW_ADDR, 1) - eq_(OFPPMFC_BAD_CONFIG, 2) - eq_(OFPPMFC_BAD_ADVERTISE, 3) - eq_(OFPPMFC_EPERM, 4) + self.assertEqual(OFPPMFC_BAD_PORT, 0) + self.assertEqual(OFPPMFC_BAD_HW_ADDR, 1) + self.assertEqual(OFPPMFC_BAD_CONFIG, 2) + self.assertEqual(OFPPMFC_BAD_ADVERTISE, 3) + self.assertEqual(OFPPMFC_EPERM, 4) def test_enum_ofp_table_mod_failed_code(self): - eq_(OFPTMFC_BAD_TABLE, 0) - eq_(OFPTMFC_BAD_CONFIG, 1) - eq_(OFPTMFC_EPERM, 2) + self.assertEqual(OFPTMFC_BAD_TABLE, 0) + self.assertEqual(OFPTMFC_BAD_CONFIG, 1) + self.assertEqual(OFPTMFC_EPERM, 2) def test_enum_ofp_queue_op_failed_code(self): - eq_(OFPQOFC_BAD_PORT, 0) - eq_(OFPQOFC_BAD_QUEUE, 1) - eq_(OFPQOFC_EPERM, 2) + self.assertEqual(OFPQOFC_BAD_PORT, 0) + self.assertEqual(OFPQOFC_BAD_QUEUE, 1) + self.assertEqual(OFPQOFC_EPERM, 2) def test_enum_ofp_switch_config_failed_code(self): - eq_(OFPSCFC_BAD_FLAGS, 0) - eq_(OFPSCFC_BAD_LEN, 1) - eq_(OFPSCFC_EPERM, 2) + self.assertEqual(OFPSCFC_BAD_FLAGS, 0) + self.assertEqual(OFPSCFC_BAD_LEN, 1) + self.assertEqual(OFPSCFC_EPERM, 2) def test_enum_ofp_role_request_failed_code(self): - eq_(OFPRRFC_STALE, 0) - eq_(OFPRRFC_UNSUP, 1) - eq_(OFPRRFC_BAD_ROLE, 2) + self.assertEqual(OFPRRFC_STALE, 0) + self.assertEqual(OFPRRFC_UNSUP, 1) + self.assertEqual(OFPRRFC_BAD_ROLE, 2) def test_struct_ofp_error_experimenter_msg(self): - eq_(OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, '!HHI') - eq_(OFP_ERROR_EXPERIMENTER_MSG_SIZE, 16) + self.assertEqual(OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, '!HHI') + self.assertEqual(OFP_ERROR_EXPERIMENTER_MSG_SIZE, 16) def test_struct_ofp_experimenter_header(self): - eq_(OFP_EXPERIMENTER_HEADER_PACK_STR, '!II') - eq_(OFP_EXPERIMENTER_HEADER_SIZE, 16) + self.assertEqual(OFP_EXPERIMENTER_HEADER_PACK_STR, '!II') + self.assertEqual(OFP_EXPERIMENTER_HEADER_SIZE, 16) # OXM is interpreted as a 32-bit word in network byte order. # - oxm_class 17-bit to 32-bit (OFPXMC_*). @@ -652,8 +651,8 @@ class TestOfprot12(unittest.TestCase): # - oxm_length 1-bit to 8-bit (Lenght of OXM payload). def _test_OXM(self, value, class_, field, hasmask, length): virfy = (class_ << 16) | (field << 9) | (hasmask << 8) | length - eq_(value >> 32, 0) - eq_(value, virfy) + self.assertEqual(value >> 32, 0) + self.assertEqual(value, virfy) def _test_OXM_basic(self, value, field, hasmask, length): self._test_OXM(value, OFPXMC_OPENFLOW_BASIC, field, hasmask, length) @@ -712,6 +711,6 @@ class TestOfprot12(unittest.TestCase): self._test_OXM_basic(OXM_OF_MPLS_TC, OFPXMT_OFB_MPLS_TC, 0, 1) def test_define_constants(self): - eq_(OFP_VERSION, 0x03) - eq_(OFP_TCP_PORT, 6633) - eq_(MAX_XID, 0xffffffff) + self.assertEqual(OFP_VERSION, 0x03) + self.assertEqual(OFP_TCP_PORT, 6633) + self.assertEqual(MAX_XID, 0xffffffff) diff --git a/os_ken/tests/unit/ofproto/test_parser.py b/os_ken/tests/unit/ofproto/test_parser.py index aab5c7bd..560a1357 100644 --- a/os_ken/tests/unit/ofproto/test_parser.py +++ b/os_ken/tests/unit/ofproto/test_parser.py @@ -14,10 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os.path import six import sys import unittest -from nose.tools import eq_ +import testscenarios from os_ken.ofproto import ofproto_parser from os_ken.ofproto import ofproto_protocol @@ -26,7 +27,6 @@ from os_ken.ofproto import ofproto_v1_2 from os_ken.ofproto import ofproto_v1_3 from os_ken.ofproto import ofproto_v1_4 from os_ken.ofproto import ofproto_v1_5 -from os_ken.tests import test_lib from os_ken import exception import json @@ -153,13 +153,53 @@ implemented = { } -class Test_Parser(unittest.TestCase): - """ Test case for os_ken.ofproto, especially json representation - """ +def _list_test_cases(): + this_dir = os.path.dirname(sys.modules[__name__].__file__) + packet_data_dir = os.path.join(this_dir, '../../packet_data') + json_dir = os.path.join(this_dir, 'json') + ofvers = [ + 'of10', + 'of12', + 'of13', + 'of14', + 'of15', + ] + cases = [] + for ver in ofvers: + pdir = packet_data_dir + '/' + ver + jdir = json_dir + '/' + ver + for file in os.listdir(pdir): + if file.endswith('.packet'): + truncated = None + elif '.truncated' in file: + # contents of .truncated files aren't relevant + s1, s2 = file.split('.truncated') + try: + truncated = int(s2) + except ValueError: + continue + file = s1 + '.packet' + else: + continue + wire_msg = open(pdir + '/' + file, 'rb').read() + if not truncated: + json_str = open(jdir + '/' + file + '.json', 'r').read() + else: + json_str = open(jdir + '/' + file + + '.truncated%d.json' % truncated, 'r').read() + wire_msg = wire_msg[:truncated] + method_name = ('test_' + file).replace('-', '_').replace('.', '_') + if truncated: + method_name += '_truncated%d' % truncated + cases.append({'name': method_name, 'wire_msg': wire_msg, + 'json_str': json_str}) + return cases - def __init__(self, methodName): - print('init %s' % methodName) - super(Test_Parser, self).__init__(methodName) + +class Test_Parser(testscenarios.WithScenarios, unittest.TestCase): + """Test case for os_ken.ofproto, especially json representation""" + + scenarios = [(case['name'], case) for case in _list_test_cases()] def setUp(self): pass @@ -175,6 +215,10 @@ class Test_Parser(unittest.TestCase): def _jsondict_to_msg(dp, jsondict): return ofproto_parser.ofp_msg_from_jsondict(dp, jsondict) + def test_parser(self): + self._test_msg(name=self.name, wire_msg=self.wire_msg, + json_str=self.json_str) + def _test_msg(self, name, wire_msg, json_str): def bytes_eq(buf1, buf2): if buf1 != buf2: @@ -206,8 +250,9 @@ class Test_Parser(unittest.TestCase): json_dict2 = {'OFPTruncatedMessage': self._msg_to_jsondict(e.ofpmsg)} # XXXdebug code - open(('/tmp/%s.json' % name), 'w').write(json.dumps(json_dict2)) - eq_(json_dict, json_dict2) + with open(('/tmp/%s.json' % name), 'w') as _file: + _file.write(json.dumps(json_dict2)) + self.assertEqual(json_dict, json_dict2) if 'OFPTruncatedMessage' in json_dict2: return @@ -217,7 +262,7 @@ class Test_Parser(unittest.TestCase): msg2.set_xid(xid) if has_serializer: msg2.serialize() - eq_(self._msg_to_jsondict(msg2), json_dict) + self.assertEqual(self._msg_to_jsondict(msg2), json_dict) bytes_eq(wire_msg, msg2.buf) # check if "len" "length" fields can be omitted @@ -243,67 +288,3 @@ class Test_Parser(unittest.TestCase): msg2.serialize() bytes_eq(wire_msg, msg2.buf) - - -def _add_tests(): - import os - import os.path - import functools - - this_dir = os.path.dirname(sys.modules[__name__].__file__) - packet_data_dir = os.path.join(this_dir, '../../packet_data') - json_dir = os.path.join(this_dir, 'json') - ofvers = [ - 'of10', - 'of12', - 'of13', - 'of14', - 'of15', - ] - cases = set() - for ver in ofvers: - pdir = packet_data_dir + '/' + ver - jdir = json_dir + '/' + ver - n_added = 0 - for file in os.listdir(pdir): - if file.endswith('.packet'): - truncated = None - elif '.truncated' in file: - # contents of .truncated files aren't relevant - s1, s2 = file.split('.truncated') - try: - truncated = int(s2) - except ValueError: - continue - file = s1 + '.packet' - else: - continue - wire_msg = open(pdir + '/' + file, 'rb').read() - if not truncated: - json_str = open(jdir + '/' + file + '.json', 'r').read() - else: - json_str = open(jdir + '/' + file + - '.truncated%d.json' % truncated, 'r').read() - wire_msg = wire_msg[:truncated] - method_name = ('test_' + file).replace('-', '_').replace('.', '_') - if truncated: - method_name += '_truncated%d' % truncated - - def _run(self, name, wire_msg, json_str): - print('processing %s ...' % name) - if six.PY3: - self._test_msg(self, name, wire_msg, json_str) - else: - self._test_msg(name, wire_msg, json_str) - print('adding %s ...' % method_name) - f = functools.partial(_run, name=method_name, wire_msg=wire_msg, - json_str=json_str) - test_lib.add_method(Test_Parser, method_name, f) - cases.add(method_name) - n_added += 1 - assert n_added > 0 - assert (cases == - set(unittest.defaultTestLoader.getTestCaseNames(Test_Parser))) - - -_add_tests() diff --git a/os_ken/tests/unit/ofproto/test_parser_compat.py b/os_ken/tests/unit/ofproto/test_parser_compat.py index b9f19024..825b59a9 100644 --- a/os_ken/tests/unit/ofproto/test_parser_compat.py +++ b/os_ken/tests/unit/ofproto/test_parser_compat.py @@ -15,10 +15,8 @@ # limitations under the License. import six -import sys import unittest -from nose.tools import eq_ -from nose.tools import ok_ +import testscenarios from os_ken.ofproto import ofproto_v1_2 from os_ken.ofproto import ofproto_v1_3 @@ -26,14 +24,22 @@ from os_ken.ofproto import ofproto_v1_2_parser from os_ken.ofproto import ofproto_v1_3_parser from os_ken.lib import addrconv -from os_ken.tests import test_lib from struct import unpack -class Test_Parser_Compat(unittest.TestCase): - def __init__(self, methodName): - print('init %s' % methodName) - super(Test_Parser_Compat, self).__init__(methodName) +def _list_test_cases(): + ofpps = [ofproto_v1_2_parser, ofproto_v1_3_parser] + cases = [] + for ofpp in ofpps: + mod = ofpp.__name__.split('.')[-1] + method_name = 'test_' + mod + '_ofpmatch_compat' + cases.append({'name': method_name, 'ofpp': ofpp}) + return cases + + +class Test_Parser_Compat(testscenarios.WithScenarios, unittest.TestCase): + + scenarios = [(case['name'], case) for case in _list_test_cases()] def setUp(self): pass @@ -41,6 +47,9 @@ class Test_Parser_Compat(unittest.TestCase): def tearDown(self): pass + def test_parser(self): + self._test(name=self.name, ofpp=self.ofpp) + def _test(self, name, ofpp): ofp = { ofproto_v1_2_parser: ofproto_v1_2, @@ -70,17 +79,17 @@ class Test_Parser_Compat(unittest.TestCase): return f get_value = lambda m, t: get_field(m, t).value - eq_(get_value(o, ofpp.MTInPort), old_in_port) - eq_(get_value(o, ofpp.MTEthSrc), old_eth_src) - eq_(get_value(o, ofpp.MTIPV4Src), old_ipv4_src) - eq_(get_value(o, ofpp.MTIPv6Src), old_ipv6_src) + self.assertEqual(get_value(o, ofpp.MTInPort), old_in_port) + self.assertEqual(get_value(o, ofpp.MTEthSrc), old_eth_src) + self.assertEqual(get_value(o, ofpp.MTIPV4Src), old_ipv4_src) + self.assertEqual(get_value(o, ofpp.MTIPv6Src), old_ipv6_src) def check_new(o): # new api - eq_(o['in_port'], in_port) - eq_(o['eth_src'], eth_src) - eq_(o['ipv4_src'], ipv4_src) - eq_(o['ipv6_src'], ipv6_src) + self.assertEqual(o['in_port'], in_port) + self.assertEqual(o['eth_src'], eth_src) + self.assertEqual(o['ipv4_src'], ipv4_src) + self.assertEqual(o['ipv6_src'], ipv6_src) # ensure that old and new api produces the same thing @@ -117,43 +126,19 @@ class Test_Parser_Compat(unittest.TestCase): new_buf = bytearray() new.serialize(new_buf, 0) - eq_(new_buf, old_buf) - eq_(new_buf, old2_buf) + self.assertEqual(new_buf, old_buf) + self.assertEqual(new_buf, old2_buf) old_jsondict = old.to_jsondict() old2_jsondict = old2.to_jsondict() new_jsondict = new.to_jsondict() - eq_(new_jsondict, old_jsondict) - eq_(new_jsondict, old2_jsondict) + self.assertEqual(new_jsondict, old_jsondict) + self.assertEqual(new_jsondict, old2_jsondict) - eq_(str(new), str(old)) - eq_(str(new), str(old2)) + self.assertEqual(str(new), str(old)) + self.assertEqual(str(new), str(old2)) # a parsed object can be inspected by old and new api check(ofpp.OFPMatch.parser(six.binary_type(new_buf), 0)) check(ofpp.OFPMatch.from_jsondict(list(new_jsondict.values())[0])) - - -def _add_tests(): - import functools - import itertools - - ofpps = [ofproto_v1_2_parser, ofproto_v1_3_parser] - for ofpp in ofpps: - mod = ofpp.__name__.split('.')[-1] - method_name = 'test_' + mod + '_ofpmatch_compat' - - def _run(self, name, ofpp): - print('processing %s ...' % name) - if six.PY3: - self._test(self, name, ofpp) - else: - self._test(name, ofpp) - print('adding %s ...' % method_name) - f = functools.partial(_run, name=method_name, - ofpp=ofpp) - test_lib.add_method(Test_Parser_Compat, method_name, f) - - -_add_tests() diff --git a/os_ken/tests/unit/ofproto/test_parser_ofpmatch.py b/os_ken/tests/unit/ofproto/test_parser_ofpmatch.py index d3c3ad7e..20a3dd88 100644 --- a/os_ken/tests/unit/ofproto/test_parser_ofpmatch.py +++ b/os_ken/tests/unit/ofproto/test_parser_ofpmatch.py @@ -14,17 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -try: - # Python 3 - from functools import reduce -except ImportError: - # Python 2 - pass - +import functools +import itertools import six import unittest -from nose.tools import eq_ -from nose.tools import ok_ +import testscenarios from os_ken.ofproto import ofproto_v1_2 from os_ken.ofproto import ofproto_v1_3 @@ -34,50 +28,9 @@ from os_ken.ofproto import ofproto_v1_2_parser from os_ken.ofproto import ofproto_v1_3_parser from os_ken.ofproto import ofproto_v1_4_parser from os_ken.ofproto import ofproto_v1_5_parser -from os_ken.tests import test_lib -class Test_Parser_OFPMatch(unittest.TestCase): - _ofp = {ofproto_v1_2_parser: ofproto_v1_2, - ofproto_v1_3_parser: ofproto_v1_3, - ofproto_v1_4_parser: ofproto_v1_4, - ofproto_v1_5_parser: ofproto_v1_5} - - def __init__(self, methodName): - print('init %s' % methodName) - super(Test_Parser_OFPMatch, self).__init__(methodName) - - def setUp(self): - pass - - def tearDown(self): - pass - - def _test(self, name, ofpp, d, domask): - if domask: - d = dict(self._ofp[ofpp].oxm_normalize_user(k, uv) - for (k, uv) - in d.items()) - match = ofpp.OFPMatch(**d) - b = bytearray() - match.serialize(b, 0) - match2 = match.parser(six.binary_type(b), 0) - for k, v in d.items(): - ok_(k in match) - ok_(k in match2) - eq_(match[k], v) - eq_(match2[k], v) - for k, v in match.iteritems(): - ok_(k in d) - eq_(d[k], v) - for k, v in match2.iteritems(): - ok_(k in d) - eq_(d[k], v) - - -def _add_tests(): - import functools - import itertools +def _list_test_cases(): class Field(object): @classmethod @@ -238,8 +191,9 @@ def _add_tests(): return l + flatten(i) else: return l + [i] - flatten = lambda l: reduce(flatten_one, l, []) + flatten = lambda l: functools.reduce(flatten_one, l, []) + cases = [] for ofpp in ofpps: for n in range(1, 3): for C in itertools.combinations(L[ofpp], n): @@ -272,18 +226,47 @@ def _add_tests(): method_name = method_name.replace(',', '_') method_name = method_name.replace("'", '_') method_name = method_name.replace(' ', '_') - - def _run(self, name, ofpp, d, domask): - print('processing %s ...' % name) - if six.PY3: - self._test(self, name, ofpp, d, domask) - else: - self._test(name, ofpp, d, domask) - print('adding %s ...' % method_name) - f = functools.partial(_run, name=method_name, - ofpp=ofpp, d=d, domask=domask) - test_lib.add_method(Test_Parser_OFPMatch, - method_name, f) + cases.append({'name': method_name, 'ofpp': ofpp, + 'd': d, 'domask': domask}) + return cases -_add_tests() +class Test_Parser_OFPMatch(testscenarios.WithScenarios, unittest.TestCase): + + scenarios = [(case['name'], case) for case in _list_test_cases()] + + _ofp = {ofproto_v1_2_parser: ofproto_v1_2, + ofproto_v1_3_parser: ofproto_v1_3, + ofproto_v1_4_parser: ofproto_v1_4, + ofproto_v1_5_parser: ofproto_v1_5} + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_parser(self): + self._test(name=self.name, ofpp=self.ofpp, d=self.d, + domask=self.domask) + + def _test(self, name, ofpp, d, domask): + if domask: + d = dict(self._ofp[ofpp].oxm_normalize_user(k, uv) + for (k, uv) + in d.items()) + match = ofpp.OFPMatch(**d) + b = bytearray() + match.serialize(b, 0) + match2 = match.parser(six.binary_type(b), 0) + for k, v in d.items(): + self.assertTrue(k in match) + self.assertTrue(k in match2) + self.assertEqual(match[k], v) + self.assertEqual(match2[k], v) + for k, v in match.iteritems(): + self.assertTrue(k in d) + self.assertEqual(d[k], v) + for k, v in match2.iteritems(): + self.assertTrue(k in d) + self.assertEqual(d[k], v) diff --git a/os_ken/tests/unit/ofproto/test_parser_ofpstats.py b/os_ken/tests/unit/ofproto/test_parser_ofpstats.py index 93518cbd..586e3505 100644 --- a/os_ken/tests/unit/ofproto/test_parser_ofpstats.py +++ b/os_ken/tests/unit/ofproto/test_parser_ofpstats.py @@ -13,56 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -try: - # Python 3 - from functools import reduce -except ImportError: - # Python 2 - pass +from functools import reduce import six -import sys import unittest -from nose.tools import eq_ -from nose.tools import ok_ +import testscenarios from os_ken.ofproto import ofproto_v1_5 from os_ken.ofproto import ofproto_v1_5_parser -from os_ken.tests import test_lib -class Test_Parser_OFPStats(unittest.TestCase): - _ofp = {ofproto_v1_5_parser: ofproto_v1_5} - - def __init__(self, methodName): - print('init %s' % methodName) - super(Test_Parser_OFPStats, self).__init__(methodName) - - def setUp(self): - pass - - def tearDown(self): - pass - - def _test(self, name, ofpp, d): - stats = ofpp.OFPStats(**d) - b = bytearray() - stats.serialize(b, 0) - stats2 = stats.parser(six.binary_type(b), 0) - for k, v in d.items(): - ok_(k in stats) - ok_(k in stats2) - eq_(stats[k], v) - eq_(stats2[k], v) - for k, v in stats.iteritems(): - ok_(k in d) - eq_(d[k], v) - for k, v in stats2.iteritems(): - ok_(k in d) - eq_(d[k], v) - - -def _add_tests(): +def _list_test_cases(): import functools import itertools @@ -159,6 +120,7 @@ def _add_tests(): return l + [i] flatten = lambda l: reduce(flatten_one, l, []) + cases = [] for ofpp in ofpps: for n in range(1, 3): for C in itertools.combinations(L[ofpp], n): @@ -191,18 +153,37 @@ def _add_tests(): method_name = method_name.replace(',', '_') method_name = method_name.replace("'", '_') method_name = method_name.replace(' ', '_') - - def _run(self, name, ofpp, d): - print('processing %s ...' % name) - if six.PY3: - self._test(self, name, ofpp, d) - else: - self._test(name, ofpp, d) - print('adding %s ...' % method_name) - f = functools.partial(_run, name=method_name, - ofpp=ofpp, d=d) - test_lib.add_method(Test_Parser_OFPStats, - method_name, f) + cases.append({'name': method_name, 'ofpp': ofpp, 'd': d}) + return cases -_add_tests() +class Test_Parser_OFPStats(testscenarios.WithScenarios, unittest.TestCase): + + scenarios = [(case['name'], case) for case in _list_test_cases()] + _ofp = {ofproto_v1_5_parser: ofproto_v1_5} + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_parser(self): + self._test(name=self.name, ofpp=self.ofpp, d=self.d) + + def _test(self, name, ofpp, d): + stats = ofpp.OFPStats(**d) + b = bytearray() + stats.serialize(b, 0) + stats2 = stats.parser(six.binary_type(b), 0) + for k, v in d.items(): + self.assertTrue(k in stats) + self.assertTrue(k in stats2) + self.assertEqual(stats[k], v) + self.assertEqual(stats2[k], v) + for k, v in stats.iteritems(): + self.assertTrue(k in d) + self.assertEqual(d[k], v) + for k, v in stats2.iteritems(): + self.assertTrue(k in d) + self.assertEqual(d[k], v) diff --git a/os_ken/tests/unit/ofproto/test_parser_v10.py b/os_ken/tests/unit/ofproto/test_parser_v10.py index ed956984..7740fe96 100644 --- a/os_ken/tests/unit/ofproto/test_parser_v10.py +++ b/os_ken/tests/unit/ofproto/test_parser_v10.py @@ -18,7 +18,6 @@ import unittest import logging import six -from nose.tools import * from os_ken.ofproto.ofproto_v1_0_parser import * from os_ken.ofproto.nx_actions import * from os_ken.ofproto import ofproto_v1_0_parser @@ -72,28 +71,28 @@ class TestOFPPhyPort(unittest.TestCase): pass def test_init(self): - eq_(self.port_no['val'], self.c.port_no) - eq_(self.hw_addr, self.c.hw_addr) - eq_(self.name, self.c.name) - eq_(self.config['val'], self.c.config) - eq_(self.state['val'], self.c.state) - eq_(self.curr['val'], self.c.curr) - eq_(self.advertised['val'], self.c.advertised) - eq_(self.supported['val'], self.c.supported) - eq_(self.peer['val'], self.c.peer) + self.assertEqual(self.port_no['val'], self.c.port_no) + self.assertEqual(self.hw_addr, self.c.hw_addr) + self.assertEqual(self.name, self.c.name) + self.assertEqual(self.config['val'], self.c.config) + self.assertEqual(self.state['val'], self.c.state) + self.assertEqual(self.curr['val'], self.c.curr) + self.assertEqual(self.advertised['val'], self.c.advertised) + self.assertEqual(self.supported['val'], self.c.supported) + self.assertEqual(self.peer['val'], self.c.peer) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.port_no['val'], res.port_no) - eq_(self.hw_addr, res.hw_addr) - eq_(self.name, res.name) - eq_(self.config['val'], res.config) - eq_(self.state['val'], res.state) - eq_(self.curr['val'], res.curr) - eq_(self.advertised['val'], res.advertised) - eq_(self.supported['val'], res.supported) - eq_(self.peer['val'], res.peer) + self.assertEqual(self.port_no['val'], res.port_no) + self.assertEqual(self.hw_addr, res.hw_addr) + self.assertEqual(self.name, res.name) + self.assertEqual(self.config['val'], res.config) + self.assertEqual(self.state['val'], res.state) + self.assertEqual(self.curr['val'], res.curr) + self.assertEqual(self.advertised['val'], res.advertised) + self.assertEqual(self.supported['val'], res.supported) + self.assertEqual(self.peer['val'], res.peer) class TestOFPMatch(unittest.TestCase): @@ -165,42 +164,42 @@ class TestOFPMatch(unittest.TestCase): def test_init(self): c = self._get_obj(self.dl_src['buf'], self.dl_dst['buf']) - eq_(self.wildcards['val'], c.wildcards) - eq_(self.in_port['val'], c.in_port) - eq_(self.dl_src['buf'], c.dl_src) - eq_(self.dl_dst['buf'], c.dl_dst) - eq_(self.dl_vlan['val'], c.dl_vlan) - eq_(self.dl_vlan_pcp['val'], c.dl_vlan_pcp) - eq_(self.dl_type['val'], c.dl_type) - eq_(self.nw_tos['val'], c.nw_tos) - eq_(self.nw_proto['val'], c.nw_proto) - eq_(self.nw_src['val'], c.nw_src) - eq_(self.nw_dst['val'], c.nw_dst) - eq_(self.tp_src['val'], c.tp_src) - eq_(self.tp_dst['val'], c.tp_dst) + self.assertEqual(self.wildcards['val'], c.wildcards) + self.assertEqual(self.in_port['val'], c.in_port) + self.assertEqual(self.dl_src['buf'], c.dl_src) + self.assertEqual(self.dl_dst['buf'], c.dl_dst) + self.assertEqual(self.dl_vlan['val'], c.dl_vlan) + self.assertEqual(self.dl_vlan_pcp['val'], c.dl_vlan_pcp) + self.assertEqual(self.dl_type['val'], c.dl_type) + self.assertEqual(self.nw_tos['val'], c.nw_tos) + self.assertEqual(self.nw_proto['val'], c.nw_proto) + self.assertEqual(self.nw_src['val'], c.nw_src) + self.assertEqual(self.nw_dst['val'], c.nw_dst) + self.assertEqual(self.tp_src['val'], c.tp_src) + self.assertEqual(self.tp_dst['val'], c.tp_dst) def test_init_zero(self): c = self._get_obj(0, 0) - eq_(mac.DONTCARE, c.dl_src) - eq_(mac.DONTCARE, c.dl_dst) + self.assertEqual(mac.DONTCARE, c.dl_src) + self.assertEqual(mac.DONTCARE, c.dl_dst) def test_parse(self): c = self._get_obj(self.dl_src['buf'], self.dl_dst['buf']) res = c.parse(self.buf, 0) - eq_(self.wildcards['val'], res.wildcards) - eq_(self.in_port['val'], res.in_port) - eq_(self.dl_src['buf'], res.dl_src) - eq_(self.dl_dst['buf'], res.dl_dst) - eq_(self.dl_vlan['val'], res.dl_vlan) - eq_(self.dl_vlan_pcp['val'], res.dl_vlan_pcp) - eq_(self.dl_type['val'], res.dl_type) - eq_(self.nw_tos['val'], res.nw_tos) - eq_(self.nw_proto['val'], res.nw_proto) - eq_(self.nw_src['val'], res.nw_src) - eq_(self.nw_dst['val'], res.nw_dst) - eq_(self.tp_src['val'], res.tp_src) - eq_(self.tp_dst['val'], res.tp_dst) + self.assertEqual(self.wildcards['val'], res.wildcards) + self.assertEqual(self.in_port['val'], res.in_port) + self.assertEqual(self.dl_src['buf'], res.dl_src) + self.assertEqual(self.dl_dst['buf'], res.dl_dst) + self.assertEqual(self.dl_vlan['val'], res.dl_vlan) + self.assertEqual(self.dl_vlan_pcp['val'], res.dl_vlan_pcp) + self.assertEqual(self.dl_type['val'], res.dl_type) + self.assertEqual(self.nw_tos['val'], res.nw_tos) + self.assertEqual(self.nw_proto['val'], res.nw_proto) + self.assertEqual(self.nw_src['val'], res.nw_src) + self.assertEqual(self.nw_dst['val'], res.nw_dst) + self.assertEqual(self.tp_src['val'], res.tp_src) + self.assertEqual(self.tp_dst['val'], res.tp_dst) def test_serialize(self): buf = bytearray() @@ -211,36 +210,36 @@ class TestOFPMatch(unittest.TestCase): fmt = ofproto.OFP_MATCH_PACK_STR res = struct.unpack_from(fmt, six.binary_type(buf)) - eq_(self.wildcards['val'], res[0]) - eq_(self.in_port['val'], res[1]) - eq_(self.dl_src['buf'], res[2]) - eq_(self.dl_dst['buf'], res[3]) - eq_(self.dl_vlan['val'], res[4]) - eq_(self.dl_vlan_pcp['val'], res[5]) - eq_(self.dl_type['val'], res[6]) - eq_(self.nw_tos['val'], res[7]) - eq_(self.nw_proto['val'], res[8]) - eq_(self.nw_src['val'], res[9]) - eq_(self.nw_dst['val'], res[10]) - eq_(self.tp_src['val'], res[11]) - eq_(self.tp_dst['val'], res[12]) + self.assertEqual(self.wildcards['val'], res[0]) + self.assertEqual(self.in_port['val'], res[1]) + self.assertEqual(self.dl_src['buf'], res[2]) + self.assertEqual(self.dl_dst['buf'], res[3]) + self.assertEqual(self.dl_vlan['val'], res[4]) + self.assertEqual(self.dl_vlan_pcp['val'], res[5]) + self.assertEqual(self.dl_type['val'], res[6]) + self.assertEqual(self.nw_tos['val'], res[7]) + self.assertEqual(self.nw_proto['val'], res[8]) + self.assertEqual(self.nw_src['val'], res[9]) + self.assertEqual(self.nw_dst['val'], res[10]) + self.assertEqual(self.tp_src['val'], res[11]) + self.assertEqual(self.tp_dst['val'], res[12]) def test_getitem(self): c = self._get_obj(self.dl_src['buf'], self.dl_dst['buf']) - eq_(self.wildcards['val'], c["wildcards"]) - eq_(self.in_port['val'], c["in_port"]) - eq_(self.dl_src['human'], c["dl_src"]) - eq_(self.dl_dst['human'], c["dl_dst"]) - eq_(self.dl_vlan['val'], c["dl_vlan"]) - eq_(self.dl_vlan_pcp['val'], c["dl_vlan_pcp"]) - eq_(self.dl_type['val'], c["dl_type"]) - eq_(self.nw_tos['val'], c["nw_tos"]) - eq_(self.nw_proto['val'], c["nw_proto"]) - eq_(self.nw_src['human'], c["nw_src"]) - eq_(self.nw_dst['human'], c["nw_dst"]) - eq_(self.tp_src['val'], c["tp_src"]) - eq_(self.tp_dst['val'], c["tp_dst"]) + self.assertEqual(self.wildcards['val'], c["wildcards"]) + self.assertEqual(self.in_port['val'], c["in_port"]) + self.assertEqual(self.dl_src['human'], c["dl_src"]) + self.assertEqual(self.dl_dst['human'], c["dl_dst"]) + self.assertEqual(self.dl_vlan['val'], c["dl_vlan"]) + self.assertEqual(self.dl_vlan_pcp['val'], c["dl_vlan_pcp"]) + self.assertEqual(self.dl_type['val'], c["dl_type"]) + self.assertEqual(self.nw_tos['val'], c["nw_tos"]) + self.assertEqual(self.nw_proto['val'], c["nw_proto"]) + self.assertEqual(self.nw_src['human'], c["nw_src"]) + self.assertEqual(self.nw_dst['human'], c["nw_dst"]) + self.assertEqual(self.tp_src['val'], c["tp_src"]) + self.assertEqual(self.tp_dst['val'], c["tp_dst"]) class TestOFPActionHeader(unittest.TestCase): @@ -266,8 +265,8 @@ class TestOFPActionHeader(unittest.TestCase): pass def test_init(self): - eq_(self.type['val'], self.c.type) - eq_(self.len['val'], self.c.len) + self.assertEqual(self.type['val'], self.c.type) + self.assertEqual(self.len['val'], self.c.len) def test_serialize(self): buf = bytearray() @@ -276,8 +275,8 @@ class TestOFPActionHeader(unittest.TestCase): fmt = ofproto.OFP_ACTION_HEADER_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type['val'], res[0]) - eq_(self.len['val'], res[1]) + self.assertEqual(self.type['val'], res[0]) + self.assertEqual(self.len['val'], res[1]) class TestOFPActionOutput(unittest.TestCase): @@ -305,16 +304,15 @@ class TestOFPActionOutput(unittest.TestCase): pass def test_init(self): - eq_(self.port['val'], self.c.port) - eq_(self.max_len['val'], self.c.max_len) + self.assertEqual(self.port['val'], self.c.port) + self.assertEqual(self.max_len['val'], self.c.max_len) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.port['val'], res.port) - eq_(self.max_len['val'], res.max_len) + self.assertEqual(self.port['val'], res.port) + self.assertEqual(self.max_len['val'], res.max_len) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x01', 'val': 1} @@ -323,9 +321,8 @@ class TestOFPActionOutput(unittest.TestCase): + self.port['buf'] \ + self.max_len['buf'] - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x07', 'val': 7} @@ -334,7 +331,7 @@ class TestOFPActionOutput(unittest.TestCase): + self.port['buf'] \ + self.max_len['buf'] - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -343,10 +340,10 @@ class TestOFPActionOutput(unittest.TestCase): fmt = ofproto.OFP_ACTION_OUTPUT_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.port['val'], res[2]) - eq_(self.max_len['val'], res[3]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.port['val'], res[2]) + self.assertEqual(self.max_len['val'], res[3]) class TestOFPActionVlanVid(unittest.TestCase): @@ -374,14 +371,13 @@ class TestOFPActionVlanVid(unittest.TestCase): pass def test_init(self): - eq_(self.vlan_vid['val'], self.c.vlan_vid) + self.assertEqual(self.vlan_vid['val'], self.c.vlan_vid) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.vlan_vid['val'], res.vlan_vid) + self.assertEqual(self.vlan_vid['val'], res.vlan_vid) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x02', 'val': 2} @@ -390,9 +386,8 @@ class TestOFPActionVlanVid(unittest.TestCase): + self.vlan_vid['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x07', 'val': 7} @@ -401,7 +396,7 @@ class TestOFPActionVlanVid(unittest.TestCase): + self.vlan_vid['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -410,9 +405,9 @@ class TestOFPActionVlanVid(unittest.TestCase): fmt = ofproto.OFP_ACTION_VLAN_VID_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vlan_vid['val'], res[2]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vlan_vid['val'], res[2]) class TestOFPActionVlanPcp(unittest.TestCase): @@ -440,13 +435,12 @@ class TestOFPActionVlanPcp(unittest.TestCase): pass def test_init(self): - eq_(self.vlan_pcp['val'], self.c.vlan_pcp) + self.assertEqual(self.vlan_pcp['val'], self.c.vlan_pcp) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.vlan_pcp['val'], res.vlan_pcp) + self.assertEqual(self.vlan_pcp['val'], res.vlan_pcp) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x01', 'val': 1} @@ -455,9 +449,8 @@ class TestOFPActionVlanPcp(unittest.TestCase): + self.vlan_pcp['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x07', 'val': 7} @@ -466,7 +459,7 @@ class TestOFPActionVlanPcp(unittest.TestCase): + self.vlan_pcp['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -475,9 +468,9 @@ class TestOFPActionVlanPcp(unittest.TestCase): fmt = ofproto.OFP_ACTION_VLAN_PCP_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vlan_pcp['val'], res[2]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vlan_pcp['val'], res[2]) class TestOFPActionStripVlan(unittest.TestCase): @@ -506,9 +499,8 @@ class TestOFPActionStripVlan(unittest.TestCase): pass def test_parser(self): - ok_(self.c.parser(self.buf, 0)) + self.assertTrue(self.c.parser(self.buf, 0)) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x01', 'val': 1} @@ -516,9 +508,8 @@ class TestOFPActionStripVlan(unittest.TestCase): + self.len_['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x07', 'val': 7} @@ -526,7 +517,7 @@ class TestOFPActionStripVlan(unittest.TestCase): + len_['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) class TestOFPActionSetDlSrc(unittest.TestCase): @@ -554,11 +545,11 @@ class TestOFPActionSetDlSrc(unittest.TestCase): pass def test_init(self): - eq_(self.dl_addr, self.c.dl_addr) + self.assertEqual(self.dl_addr, self.c.dl_addr) def test_parser_type_src(self): res = self.c.parser(self.buf, 0) - eq_(self.dl_addr, res.dl_addr) + self.assertEqual(self.dl_addr, res.dl_addr) def test_parser_type_dst(self): type_ = {'buf': b'\x00\x05', 'val': ofproto.OFPAT_SET_DL_DST} @@ -569,9 +560,8 @@ class TestOFPActionSetDlSrc(unittest.TestCase): res = self.c.parser(buf, 0) - eq_(self.dl_addr, res.dl_addr) + self.assertEqual(self.dl_addr, res.dl_addr) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x06', 'val': 6} buf = type_['buf'] \ @@ -579,9 +569,8 @@ class TestOFPActionSetDlSrc(unittest.TestCase): + self.dl_addr \ + self.zfill - res = self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x07', 'val': 7} buf = self.type_['buf'] \ @@ -589,7 +578,7 @@ class TestOFPActionSetDlSrc(unittest.TestCase): + self.dl_addr \ + self.zfill - res = self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -598,9 +587,9 @@ class TestOFPActionSetDlSrc(unittest.TestCase): fmt = ofproto.OFP_ACTION_DL_ADDR_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.dl_addr, res[2]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.dl_addr, res[2]) class TestOFPActionSetDlDst(unittest.TestCase): @@ -628,11 +617,11 @@ class TestOFPActionSetDlDst(unittest.TestCase): pass def test_init(self): - eq_(self.dl_addr, self.c.dl_addr) + self.assertEqual(self.dl_addr, self.c.dl_addr) def test_parser_type_dst(self): res = self.c.parser(self.buf, 0) - eq_(self.dl_addr, res.dl_addr) + self.assertEqual(self.dl_addr, res.dl_addr) def test_parser_type_src(self): type_ = {'buf': b'\x00\x04', 'val': ofproto.OFPAT_SET_DL_SRC} @@ -643,9 +632,8 @@ class TestOFPActionSetDlDst(unittest.TestCase): res = self.c.parser(buf, 0) - eq_(self.dl_addr, res.dl_addr) + self.assertEqual(self.dl_addr, res.dl_addr) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x06', 'val': 6} buf = type_['buf'] \ @@ -653,9 +641,8 @@ class TestOFPActionSetDlDst(unittest.TestCase): + self.dl_addr \ + self.zfill - res = self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x07', 'val': 7} buf = self.type_['buf'] \ @@ -663,7 +650,7 @@ class TestOFPActionSetDlDst(unittest.TestCase): + self.dl_addr \ + self.zfill - res = self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -672,9 +659,9 @@ class TestOFPActionSetDlDst(unittest.TestCase): fmt = ofproto.OFP_ACTION_DL_ADDR_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.dl_addr, res[2]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.dl_addr, res[2]) class TestOFPActionSetNwSrc(unittest.TestCase): @@ -700,11 +687,11 @@ class TestOFPActionSetNwSrc(unittest.TestCase): pass def test_init(self): - eq_(self.nw_addr['val'], self.c.nw_addr) + self.assertEqual(self.nw_addr['val'], self.c.nw_addr) def test_parser_src(self): res = self.c.parser(self.buf, 0) - eq_(self.nw_addr['val'], res.nw_addr) + self.assertEqual(self.nw_addr['val'], res.nw_addr) def test_parser_dst(self): type_ = {'buf': b'\x00\x07', 'val': ofproto.OFPAT_SET_NW_DST} @@ -714,9 +701,8 @@ class TestOFPActionSetNwSrc(unittest.TestCase): + self.nw_addr['buf'] res = self.c.parser(buf, 0) - eq_(self.nw_addr['val'], res.nw_addr) + self.assertEqual(self.nw_addr['val'], res.nw_addr) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x05', 'val': 5} @@ -724,9 +710,8 @@ class TestOFPActionSetNwSrc(unittest.TestCase): + self.len_['buf'] \ + self.nw_addr['buf'] - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x10', 'val': 16} @@ -734,7 +719,7 @@ class TestOFPActionSetNwSrc(unittest.TestCase): + len_['buf'] \ + self.nw_addr['buf'] - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -743,9 +728,9 @@ class TestOFPActionSetNwSrc(unittest.TestCase): fmt = ofproto.OFP_ACTION_NW_ADDR_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.nw_addr['val'], res[2]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.nw_addr['val'], res[2]) class TestOFPActionSetNwDst(unittest.TestCase): @@ -771,11 +756,11 @@ class TestOFPActionSetNwDst(unittest.TestCase): pass def test_init(self): - eq_(self.nw_addr['val'], self.c.nw_addr) + self.assertEqual(self.nw_addr['val'], self.c.nw_addr) def test_parser_dst(self): res = self.c.parser(self.buf, 0) - eq_(self.nw_addr['val'], res.nw_addr) + self.assertEqual(self.nw_addr['val'], res.nw_addr) def test_parser_src(self): type_ = {'buf': b'\x00\x06', 'val': ofproto.OFPAT_SET_NW_SRC} @@ -785,9 +770,8 @@ class TestOFPActionSetNwDst(unittest.TestCase): + self.nw_addr['buf'] res = self.c.parser(buf, 0) - eq_(self.nw_addr['val'], res.nw_addr) + self.assertEqual(self.nw_addr['val'], res.nw_addr) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x05', 'val': 5} @@ -795,9 +779,8 @@ class TestOFPActionSetNwDst(unittest.TestCase): + self.len_['buf'] \ + self.nw_addr['buf'] - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x10', 'val': 16} @@ -805,7 +788,7 @@ class TestOFPActionSetNwDst(unittest.TestCase): + len_['buf'] \ + self.nw_addr['buf'] - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -814,9 +797,9 @@ class TestOFPActionSetNwDst(unittest.TestCase): fmt = ofproto.OFP_ACTION_NW_ADDR_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.nw_addr['val'], res[2]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.nw_addr['val'], res[2]) class TestOFPActionSetNwTos(unittest.TestCase): @@ -844,13 +827,12 @@ class TestOFPActionSetNwTos(unittest.TestCase): pass def test_init(self): - eq_(self.tos['val'], self.c.tos) + self.assertEqual(self.tos['val'], self.c.tos) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.tos['val'], res.tos) + self.assertEqual(self.tos['val'], res.tos) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x05', 'val': 5} @@ -859,9 +841,8 @@ class TestOFPActionSetNwTos(unittest.TestCase): + self.tos['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x07', 'val': 7} @@ -870,7 +851,7 @@ class TestOFPActionSetNwTos(unittest.TestCase): + self.tos['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -879,9 +860,9 @@ class TestOFPActionSetNwTos(unittest.TestCase): fmt = ofproto.OFP_ACTION_NW_TOS_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.tos['val'], res[2]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.tos['val'], res[2]) class TestOFPActionSetTpSrc(unittest.TestCase): @@ -909,11 +890,11 @@ class TestOFPActionSetTpSrc(unittest.TestCase): pass def test_init(self): - eq_(self.tp['val'], self.c.tp) + self.assertEqual(self.tp['val'], self.c.tp) def test_parser_src(self): res = self.c.parser(self.buf, 0) - eq_(self.tp['val'], res.tp) + self.assertEqual(self.tp['val'], res.tp) def test_parser_dst(self): type_ = {'buf': b'\x00\x0a', 'val': ofproto.OFPAT_SET_TP_DST} @@ -924,9 +905,8 @@ class TestOFPActionSetTpSrc(unittest.TestCase): + self.zfill res = self.c.parser(self.buf, 0) - eq_(self.tp['val'], res.tp) + self.assertEqual(self.tp['val'], res.tp) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x07', 'val': 7} @@ -935,9 +915,8 @@ class TestOFPActionSetTpSrc(unittest.TestCase): + self.tp['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x07', 'val': 7} @@ -946,7 +925,7 @@ class TestOFPActionSetTpSrc(unittest.TestCase): + self.tp['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -955,9 +934,9 @@ class TestOFPActionSetTpSrc(unittest.TestCase): fmt = ofproto.OFP_ACTION_TP_PORT_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.tp['val'], res[2]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.tp['val'], res[2]) class TestOFPActionSetTpDst(unittest.TestCase): @@ -985,11 +964,11 @@ class TestOFPActionSetTpDst(unittest.TestCase): pass def test_init(self): - eq_(self.tp['val'], self.c.tp) + self.assertEqual(self.tp['val'], self.c.tp) def test_parser_dst(self): res = self.c.parser(self.buf, 0) - eq_(self.tp['val'], res.tp) + self.assertEqual(self.tp['val'], res.tp) def test_parser_src(self): type_ = {'buf': b'\x00\x09', 'val': ofproto.OFPAT_SET_TP_SRC} @@ -1000,9 +979,8 @@ class TestOFPActionSetTpDst(unittest.TestCase): + self.zfill res = self.c.parser(buf, 0) - eq_(self.tp['val'], res.tp) + self.assertEqual(self.tp['val'], res.tp) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x10', 'val': 16} @@ -1011,9 +989,8 @@ class TestOFPActionSetTpDst(unittest.TestCase): + self.tp['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x07', 'val': 7} @@ -1022,7 +999,7 @@ class TestOFPActionSetTpDst(unittest.TestCase): + self.tp['buf'] \ + self.zfill - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -1031,9 +1008,9 @@ class TestOFPActionSetTpDst(unittest.TestCase): fmt = ofproto.OFP_ACTION_TP_PORT_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.tp['val'], res[2]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.tp['val'], res[2]) class TestOFPActionEnqueue(unittest.TestCase): @@ -1063,16 +1040,15 @@ class TestOFPActionEnqueue(unittest.TestCase): pass def test_init(self): - eq_(self.port['val'], self.c.port) - eq_(self.queue_id['val'], self.c.queue_id) + self.assertEqual(self.port['val'], self.c.port) + self.assertEqual(self.queue_id['val'], self.c.queue_id) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.port['val'], res.port) - eq_(self.queue_id['val'], res.queue_id) + self.assertEqual(self.port['val'], res.port) + self.assertEqual(self.queue_id['val'], res.queue_id) - @raises(AssertionError) def test_parser_check_type(self): type_ = {'buf': b'\x00\x0a', 'val': 10} @@ -1082,9 +1058,8 @@ class TestOFPActionEnqueue(unittest.TestCase): + self.zfill \ + self.queue_id['buf'] - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) - @raises(AssertionError) def test_parser_check_len(self): len_ = {'buf': b'\x00\x05', 'val': 5} @@ -1094,7 +1069,7 @@ class TestOFPActionEnqueue(unittest.TestCase): + self.zfill \ + self.queue_id['buf'] - self.c.parser(buf, 0) + self.assertRaises(AssertionError, self.c.parser, buf, 0) def test_serialize(self): buf = bytearray() @@ -1103,10 +1078,10 @@ class TestOFPActionEnqueue(unittest.TestCase): fmt = ofproto.OFP_ACTION_ENQUEUE_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.port['val'], res[2]) - eq_(self.queue_id['val'], res[3]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.port['val'], res[2]) + self.assertEqual(self.queue_id['val'], res[3]) class TestNXActionResubmit(unittest.TestCase): @@ -1140,14 +1115,14 @@ class TestNXActionResubmit(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.in_port['val'], self.c.in_port) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.in_port['val'], self.c.in_port) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.in_port['val'], res.in_port) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.in_port['val'], res.in_port) def test_serialize(self): buf = bytearray() @@ -1156,11 +1131,11 @@ class TestNXActionResubmit(unittest.TestCase): fmt = ofproto.NX_ACTION_RESUBMIT_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.in_port['val'], res[4]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.in_port['val'], res[4]) class TestNXActionResubmitTable(unittest.TestCase): @@ -1194,16 +1169,16 @@ class TestNXActionResubmitTable(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.in_port['val'], self.c.in_port) - eq_(self.table_id['val'], self.c.table_id) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.in_port['val'], self.c.in_port) + self.assertEqual(self.table_id['val'], self.c.table_id) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.in_port['val'], res.in_port) - eq_(self.table_id['val'], res.table_id) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.in_port['val'], res.in_port) + self.assertEqual(self.table_id['val'], res.table_id) def test_serialize(self): buf = bytearray() @@ -1212,12 +1187,12 @@ class TestNXActionResubmitTable(unittest.TestCase): fmt = ofproto.NX_ACTION_RESUBMIT_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.in_port['val'], res[4]) - eq_(self.table_id['val'], res[5]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.in_port['val'], res[4]) + self.assertEqual(self.table_id['val'], res[5]) class TestNXActionSetTunnel(unittest.TestCase): @@ -1249,14 +1224,14 @@ class TestNXActionSetTunnel(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.tun_id['val'], self.c.tun_id) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.tun_id['val'], self.c.tun_id) def test_parse(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.tun_id['val'], res.tun_id) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.tun_id['val'], res.tun_id) def test_serialize(self): buf = bytearray() @@ -1265,11 +1240,11 @@ class TestNXActionSetTunnel(unittest.TestCase): fmt = ofproto.NX_ACTION_SET_TUNNEL_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.tun_id['val'], res[4]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.tun_id['val'], res[4]) class TestNXActionSetQueue(unittest.TestCase): @@ -1302,14 +1277,14 @@ class TestNXActionSetQueue(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.queue_id['val'], self.c.queue_id) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.queue_id['val'], self.c.queue_id) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.queue_id['val'], res.queue_id) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.queue_id['val'], res.queue_id) def test_serialize(self): buf = bytearray() @@ -1318,11 +1293,11 @@ class TestNXActionSetQueue(unittest.TestCase): fmt = ofproto.NX_ACTION_SET_QUEUE_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.queue_id['val'], res[4]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.queue_id['val'], res[4]) class TestNXActionPopQueue(unittest.TestCase): @@ -1353,13 +1328,13 @@ class TestNXActionPopQueue(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) + self.assertEqual(self.subtype['val'], self.c.subtype) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.subtype['val'], res.subtype) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.subtype['val'], res.subtype) def test_serialize(self): buf = bytearray() @@ -1368,10 +1343,10 @@ class TestNXActionPopQueue(unittest.TestCase): fmt = ofproto.NX_ACTION_POP_QUEUE_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) class TestNXActionRegMove(unittest.TestCase): @@ -1415,23 +1390,23 @@ class TestNXActionRegMove(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.src_field['val'], self.c.src_field) - eq_(self.dst_field['val'], self.c.dst_field) - eq_(self.n_bits['val'], self.c.n_bits) - eq_(self.src_field['val'], self.c.src_field) - eq_(self.dst_field['val'], self.c.dst_field) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.src_field['val'], self.c.src_field) + self.assertEqual(self.dst_field['val'], self.c.dst_field) + self.assertEqual(self.n_bits['val'], self.c.n_bits) + self.assertEqual(self.src_field['val'], self.c.src_field) + self.assertEqual(self.dst_field['val'], self.c.dst_field) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.subtype['val'], res.subtype) - eq_(self.src_ofs['val'], res.src_ofs) - eq_(self.dst_ofs['val'], res.dst_ofs) - eq_(self.n_bits['val'], res.n_bits) - eq_(self.src_field['val'], res.src_field) - eq_(self.dst_field['val'], res.dst_field) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.subtype['val'], res.subtype) + self.assertEqual(self.src_ofs['val'], res.src_ofs) + self.assertEqual(self.dst_ofs['val'], res.dst_ofs) + self.assertEqual(self.n_bits['val'], res.n_bits) + self.assertEqual(self.src_field['val'], res.src_field) + self.assertEqual(self.dst_field['val'], res.dst_field) def test_serialize(self): buf = bytearray() @@ -1440,15 +1415,15 @@ class TestNXActionRegMove(unittest.TestCase): fmt = ofproto.NX_ACTION_REG_MOVE_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.n_bits['val'], res[4]) - eq_(self.src_ofs['val'], res[5]) - eq_(self.dst_ofs['val'], res[6]) - eq_(self.src_field['val2'], res[7]) - eq_(self.dst_field['val2'], res[8]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.n_bits['val'], res[4]) + self.assertEqual(self.src_ofs['val'], res[5]) + self.assertEqual(self.dst_ofs['val'], res[6]) + self.assertEqual(self.src_field['val2'], res[7]) + self.assertEqual(self.dst_field['val2'], res[8]) class TestNXActionRegLoad(unittest.TestCase): @@ -1489,18 +1464,18 @@ class TestNXActionRegLoad(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.ofs_nbits['val'], self.c.ofs_nbits) - eq_(self.dst['val'], self.c.dst) - eq_(self.value['val'], self.c.value) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.ofs_nbits['val'], self.c.ofs_nbits) + self.assertEqual(self.dst['val'], self.c.dst) + self.assertEqual(self.value['val'], self.c.value) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.ofs_nbits['val'], self.c.ofs_nbits) - eq_(self.dst['val'], res.dst) - eq_(self.value['val'], res.value) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.ofs_nbits['val'], self.c.ofs_nbits) + self.assertEqual(self.dst['val'], res.dst) + self.assertEqual(self.value['val'], res.value) def test_serialize(self): buf = bytearray() @@ -1509,13 +1484,13 @@ class TestNXActionRegLoad(unittest.TestCase): fmt = ofproto.NX_ACTION_REG_LOAD_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.ofs_nbits['val'], res[4]) - eq_(self.dst['val2'], res[5]) - eq_(self.value['val'], res[6]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.ofs_nbits['val'], res[4]) + self.assertEqual(self.dst['val2'], res[5]) + self.assertEqual(self.value['val'], res[6]) class TestNXActionSetTunnel64(unittest.TestCase): @@ -1549,15 +1524,15 @@ class TestNXActionSetTunnel64(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.tun_id['val'], self.c.tun_id) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.tun_id['val'], self.c.tun_id) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.subtype['val'], res.subtype) - eq_(self.tun_id['val'], res.tun_id) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.subtype['val'], res.subtype) + self.assertEqual(self.tun_id['val'], res.tun_id) def test_serialize(self): buf = bytearray() @@ -1566,11 +1541,11 @@ class TestNXActionSetTunnel64(unittest.TestCase): fmt = ofproto.NX_ACTION_SET_TUNNEL64_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.tun_id['val'], res[4]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.tun_id['val'], res[4]) class TestNXActionMultipath(unittest.TestCase): @@ -1626,27 +1601,27 @@ class TestNXActionMultipath(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.fields['val'], self.c.fields) - eq_(self.basis['val'], self.c.basis) - eq_(self.algorithm['val'], self.c.algorithm) - eq_(self.max_link['val'], self.c.max_link) - eq_(self.arg['val'], self.c.arg) - eq_(self.ofs_nbits['val'], self.c.ofs_nbits) - eq_(self.dst['val'], self.c.dst) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.fields['val'], self.c.fields) + self.assertEqual(self.basis['val'], self.c.basis) + self.assertEqual(self.algorithm['val'], self.c.algorithm) + self.assertEqual(self.max_link['val'], self.c.max_link) + self.assertEqual(self.arg['val'], self.c.arg) + self.assertEqual(self.ofs_nbits['val'], self.c.ofs_nbits) + self.assertEqual(self.dst['val'], self.c.dst) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.subtype['val'], res.subtype) - eq_(self.fields['val'], res.fields) - eq_(self.basis['val'], res.basis) - eq_(self.algorithm['val'], res.algorithm) - eq_(self.max_link['val'], res.max_link) - eq_(self.arg['val'], res.arg) - eq_(self.ofs_nbits['val'], res.ofs_nbits) - eq_(self.dst['val'], res.dst) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.subtype['val'], res.subtype) + self.assertEqual(self.fields['val'], res.fields) + self.assertEqual(self.basis['val'], res.basis) + self.assertEqual(self.algorithm['val'], res.algorithm) + self.assertEqual(self.max_link['val'], res.max_link) + self.assertEqual(self.arg['val'], res.arg) + self.assertEqual(self.ofs_nbits['val'], res.ofs_nbits) + self.assertEqual(self.dst['val'], res.dst) def test_serialize(self): buf = bytearray() @@ -1655,17 +1630,17 @@ class TestNXActionMultipath(unittest.TestCase): fmt = ofproto.NX_ACTION_MULTIPATH_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.fields['val'], res[4]) - eq_(self.basis['val'], res[5]) - eq_(self.algorithm['val'], res[6]) - eq_(self.max_link['val'], res[7]) - eq_(self.arg['val'], res[8]) - eq_(self.ofs_nbits['val'], res[9]) - eq_(self.dst['val2'], res[10]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.fields['val'], res[4]) + self.assertEqual(self.basis['val'], res[5]) + self.assertEqual(self.algorithm['val'], res[6]) + self.assertEqual(self.max_link['val'], res[7]) + self.assertEqual(self.arg['val'], res[8]) + self.assertEqual(self.ofs_nbits['val'], res[9]) + self.assertEqual(self.dst['val2'], res[10]) class TestNXActionBundle(unittest.TestCase): @@ -1727,37 +1702,37 @@ class TestNXActionBundle(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.algorithm['val'], self.c.algorithm) - eq_(self.fields['val'], self.c.fields) - eq_(self.basis['val'], self.c.basis) - eq_(self.slave_type['val'], self.c.slave_type) - eq_(self.n_slaves['val'], self.c.n_slaves) - eq_(self.ofs_nbits['val'], self.c.ofs_nbits) - eq_(self.dst['val'], self.c.dst) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.algorithm['val'], self.c.algorithm) + self.assertEqual(self.fields['val'], self.c.fields) + self.assertEqual(self.basis['val'], self.c.basis) + self.assertEqual(self.slave_type['val'], self.c.slave_type) + self.assertEqual(self.n_slaves['val'], self.c.n_slaves) + self.assertEqual(self.ofs_nbits['val'], self.c.ofs_nbits) + self.assertEqual(self.dst['val'], self.c.dst) # slaves slaves = self.c.slaves - eq_(self.slaves_val[0], slaves[0]) - eq_(self.slaves_val[1], slaves[1]) + self.assertEqual(self.slaves_val[0], slaves[0]) + self.assertEqual(self.slaves_val[1], slaves[1]) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.subtype['val'], res.subtype) - eq_(self.algorithm['val'], res.algorithm) - eq_(self.fields['val'], res.fields) - eq_(self.basis['val'], res.basis) - eq_(self.slave_type['val'], res.slave_type) - eq_(self.n_slaves['val'], res.n_slaves) - eq_(self.ofs_nbits['val'], res.ofs_nbits) - eq_(self.dst['val'], res.dst) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.subtype['val'], res.subtype) + self.assertEqual(self.algorithm['val'], res.algorithm) + self.assertEqual(self.fields['val'], res.fields) + self.assertEqual(self.basis['val'], res.basis) + self.assertEqual(self.slave_type['val'], res.slave_type) + self.assertEqual(self.n_slaves['val'], res.n_slaves) + self.assertEqual(self.ofs_nbits['val'], res.ofs_nbits) + self.assertEqual(self.dst['val'], res.dst) # slaves slaves = res.slaves - eq_(self.slaves_val[0], slaves[0]) - eq_(self.slaves_val[1], slaves[1]) + self.assertEqual(self.slaves_val[0], slaves[0]) + self.assertEqual(self.slaves_val[1], slaves[1]) def test_serialize(self): buf = bytearray() @@ -1769,17 +1744,17 @@ class TestNXActionBundle(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.algorithm['val'], res[4]) - eq_(self.fields['val'], res[5]) - eq_(self.basis['val'], res[6]) - eq_(self.slave_type['val'], res[7]) - eq_(self.n_slaves['val'], res[8]) - eq_(self.ofs_nbits['val'], res[9]) - eq_(self.dst['val'], res[10]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.algorithm['val'], res[4]) + self.assertEqual(self.fields['val'], res[5]) + self.assertEqual(self.basis['val'], res[6]) + self.assertEqual(self.slave_type['val'], res[7]) + self.assertEqual(self.n_slaves['val'], res[8]) + self.assertEqual(self.ofs_nbits['val'], res[9]) + self.assertEqual(self.dst['val'], res[10]) class TestNXActionBundleLoad(unittest.TestCase): @@ -1841,37 +1816,37 @@ class TestNXActionBundleLoad(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.algorithm['val'], self.c.algorithm) - eq_(self.fields['val'], self.c.fields) - eq_(self.basis['val'], self.c.basis) - eq_(self.slave_type['val'], self.c.slave_type) - eq_(self.n_slaves['val'], self.c.n_slaves) - eq_(self.ofs_nbits['val'], self.c.ofs_nbits) - eq_(self.dst['val'], self.c.dst) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.algorithm['val'], self.c.algorithm) + self.assertEqual(self.fields['val'], self.c.fields) + self.assertEqual(self.basis['val'], self.c.basis) + self.assertEqual(self.slave_type['val'], self.c.slave_type) + self.assertEqual(self.n_slaves['val'], self.c.n_slaves) + self.assertEqual(self.ofs_nbits['val'], self.c.ofs_nbits) + self.assertEqual(self.dst['val'], self.c.dst) # slaves slaves = self.c.slaves - eq_(self.slaves_val[0], slaves[0]) - eq_(self.slaves_val[1], slaves[1]) + self.assertEqual(self.slaves_val[0], slaves[0]) + self.assertEqual(self.slaves_val[1], slaves[1]) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.subtype['val'], res.subtype) - eq_(self.algorithm['val'], res.algorithm) - eq_(self.fields['val'], res.fields) - eq_(self.basis['val'], res.basis) - eq_(self.slave_type['val'], res.slave_type) - eq_(self.n_slaves['val'], res.n_slaves) - eq_(self.ofs_nbits['val'], res.ofs_nbits) - eq_(self.dst['val'], res.dst) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.subtype['val'], res.subtype) + self.assertEqual(self.algorithm['val'], res.algorithm) + self.assertEqual(self.fields['val'], res.fields) + self.assertEqual(self.basis['val'], res.basis) + self.assertEqual(self.slave_type['val'], res.slave_type) + self.assertEqual(self.n_slaves['val'], res.n_slaves) + self.assertEqual(self.ofs_nbits['val'], res.ofs_nbits) + self.assertEqual(self.dst['val'], res.dst) # slaves slaves = res.slaves - eq_(self.slaves_val[0], slaves[0]) - eq_(self.slaves_val[1], slaves[1]) + self.assertEqual(self.slaves_val[0], slaves[0]) + self.assertEqual(self.slaves_val[1], slaves[1]) def test_serialize(self): buf = bytearray() @@ -1883,17 +1858,17 @@ class TestNXActionBundleLoad(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.algorithm['val'], res[4]) - eq_(self.fields['val'], res[5]) - eq_(self.basis['val'], res[6]) - eq_(self.slave_type['val'], res[7]) - eq_(self.n_slaves['val'], res[8]) - eq_(self.ofs_nbits['val'], res[9]) - eq_(self.dst['val2'], res[10]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.algorithm['val'], res[4]) + self.assertEqual(self.fields['val'], res[5]) + self.assertEqual(self.basis['val'], res[6]) + self.assertEqual(self.slave_type['val'], res[7]) + self.assertEqual(self.n_slaves['val'], res[8]) + self.assertEqual(self.ofs_nbits['val'], res[9]) + self.assertEqual(self.dst['val2'], res[10]) class TestNXActionOutputReg(unittest.TestCase): @@ -1933,19 +1908,19 @@ class TestNXActionOutputReg(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) - eq_(self.ofs_nbits['val'], self.c.ofs_nbits) - eq_(self.src['val'], self.c.src) - eq_(self.max_len['val'], self.c.max_len) + self.assertEqual(self.subtype['val'], self.c.subtype) + self.assertEqual(self.ofs_nbits['val'], self.c.ofs_nbits) + self.assertEqual(self.src['val'], self.c.src) + self.assertEqual(self.max_len['val'], self.c.max_len) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.subtype['val'], res.subtype) - eq_(self.ofs_nbits['val'], self.c.ofs_nbits) - eq_(self.src['val'], res.src) - eq_(self.max_len['val'], res.max_len) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.subtype['val'], res.subtype) + self.assertEqual(self.ofs_nbits['val'], self.c.ofs_nbits) + self.assertEqual(self.src['val'], res.src) + self.assertEqual(self.max_len['val'], res.max_len) def test_serialize(self): buf = bytearray() @@ -1954,13 +1929,13 @@ class TestNXActionOutputReg(unittest.TestCase): fmt = ofproto.NX_ACTION_OUTPUT_REG_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) - eq_(self.ofs_nbits['val'], res[4]) - eq_(self.src['val2'], res[5]) - eq_(self.max_len['val'], res[6]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) + self.assertEqual(self.ofs_nbits['val'], res[4]) + self.assertEqual(self.src['val2'], res[5]) + self.assertEqual(self.max_len['val'], res[6]) class TestNXActionExit(unittest.TestCase): @@ -1991,13 +1966,13 @@ class TestNXActionExit(unittest.TestCase): pass def test_init(self): - eq_(self.subtype['val'], self.c.subtype) + self.assertEqual(self.subtype['val'], self.c.subtype) def test_parser(self): res = OFPActionVendor.parser(self.buf, 0) - eq_(self.type_['val'], res.type) - eq_(self.len_['val'], res.len) - eq_(self.subtype['val'], res.subtype) + self.assertEqual(self.type_['val'], res.type) + self.assertEqual(self.len_['val'], res.len) + self.assertEqual(self.subtype['val'], res.subtype) def test_serialize(self): buf = bytearray() @@ -2006,10 +1981,10 @@ class TestNXActionExit(unittest.TestCase): fmt = ofproto.NX_ACTION_HEADER_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(self.type_['val'], res[0]) - eq_(self.len_['val'], res[1]) - eq_(self.vendor['val'], res[2]) - eq_(self.subtype['val'], res[3]) + self.assertEqual(self.type_['val'], res[0]) + self.assertEqual(self.len_['val'], res[1]) + self.assertEqual(self.vendor['val'], res[2]) + self.assertEqual(self.subtype['val'], res[3]) class TestOFPDescStats(unittest.TestCase): @@ -2039,20 +2014,20 @@ class TestOFPDescStats(unittest.TestCase): pass def test_init(self): - eq_(self.mfr_desc, self.c.mfr_desc) - eq_(self.hw_desc, self.c.hw_desc) - eq_(self.sw_desc, self.c.sw_desc) - eq_(self.serial_num, self.c.serial_num) - eq_(self.dp_desc, self.c.dp_desc) + self.assertEqual(self.mfr_desc, self.c.mfr_desc) + self.assertEqual(self.hw_desc, self.c.hw_desc) + self.assertEqual(self.sw_desc, self.c.sw_desc) + self.assertEqual(self.serial_num, self.c.serial_num) + self.assertEqual(self.dp_desc, self.c.dp_desc) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.mfr_desc, self.mfr_desc) - eq_(self.hw_desc, self.hw_desc) - eq_(self.sw_desc, self.sw_desc) - eq_(self.serial_num, self.serial_num) - eq_(self.dp_desc, self.dp_desc) + self.assertEqual(self.mfr_desc, self.mfr_desc) + self.assertEqual(self.hw_desc, self.hw_desc) + self.assertEqual(self.sw_desc, self.sw_desc) + self.assertEqual(self.serial_num, self.serial_num) + self.assertEqual(self.dp_desc, self.dp_desc) class TestOFPFlowStats(unittest.TestCase): @@ -2151,24 +2126,24 @@ class TestOFPFlowStats(unittest.TestCase): def test_parser(self): res = self._parser() - eq_(self.length['val'], res.length) - eq_(self.table_id['val'], res.table_id) - eq_(self.duration_sec['val'], res.duration_sec) - eq_(self.duration_nsec['val'], res.duration_nsec) - eq_(self.priority['val'], res.priority) - eq_(self.idle_timeout['val'], res.idle_timeout) - eq_(self.hard_timeout['val'], res.hard_timeout) - eq_(self.cookie['val'], res.cookie) - eq_(self.packet_count['val'], res.packet_count) - eq_(self.byte_count['val'], res.byte_count) + self.assertEqual(self.length['val'], res.length) + self.assertEqual(self.table_id['val'], res.table_id) + self.assertEqual(self.duration_sec['val'], res.duration_sec) + self.assertEqual(self.duration_nsec['val'], res.duration_nsec) + self.assertEqual(self.priority['val'], res.priority) + self.assertEqual(self.idle_timeout['val'], res.idle_timeout) + self.assertEqual(self.hard_timeout['val'], res.hard_timeout) + self.assertEqual(self.cookie['val'], res.cookie) + self.assertEqual(self.packet_count['val'], res.packet_count) + self.assertEqual(self.byte_count['val'], res.byte_count) def test_parser_append_actions(self): res = self._parser(True).actions[0] - eq_(self.action[self.ACTION_TYPE]['val'], res.type) - eq_(self.action[self.ACTION_LEN]['val'], res.len) - eq_(self.action[self.ACTION_PORT]['val'], res.port) - eq_(self.action[self.ACTION_MAX_LEN]['val'], res.max_len) + self.assertEqual(self.action[self.ACTION_TYPE]['val'], res.type) + self.assertEqual(self.action[self.ACTION_LEN]['val'], res.len) + self.assertEqual(self.action[self.ACTION_PORT]['val'], res.port) + self.assertEqual(self.action[self.ACTION_MAX_LEN]['val'], res.max_len) class TestOFPAggregateStats(unittest.TestCase): @@ -2200,17 +2175,17 @@ class TestOFPAggregateStats(unittest.TestCase): pass def test_init(self): - eq_(self.packet_count['val'], self.c.packet_count) - eq_(self.byte_count['val'], self.c.byte_count) - eq_(self.flow_count['val'], self.c.flow_count) + self.assertEqual(self.packet_count['val'], self.c.packet_count) + self.assertEqual(self.byte_count['val'], self.c.byte_count) + self.assertEqual(self.flow_count['val'], self.c.flow_count) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.packet_count['val'], res.packet_count) - eq_(self.byte_count['val'], res.byte_count) - eq_(self.flow_count['val'], res.flow_count) + self.assertEqual(self.packet_count['val'], res.packet_count) + self.assertEqual(self.byte_count['val'], res.byte_count) + self.assertEqual(self.flow_count['val'], res.flow_count) class TestOFPTableStats(unittest.TestCase): @@ -2255,24 +2230,24 @@ class TestOFPTableStats(unittest.TestCase): pass def test_init(self): - eq_(self.table_id['val'], self.c.table_id) - eq_(self.name, self.c.name) - eq_(self.wildcards['val'], self.c.wildcards) - eq_(self.max_entries['val'], self.c.max_entries) - eq_(self.active_count['val'], self.c.active_count) - eq_(self.lookup_count['val'], self.c.lookup_count) - eq_(self.matched_count['val'], self.c.matched_count) + self.assertEqual(self.table_id['val'], self.c.table_id) + self.assertEqual(self.name, self.c.name) + self.assertEqual(self.wildcards['val'], self.c.wildcards) + self.assertEqual(self.max_entries['val'], self.c.max_entries) + self.assertEqual(self.active_count['val'], self.c.active_count) + self.assertEqual(self.lookup_count['val'], self.c.lookup_count) + self.assertEqual(self.matched_count['val'], self.c.matched_count) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.table_id['val'], res.table_id) - eq_(self.name, res.name) - eq_(self.wildcards['val'], res.wildcards) - eq_(self.max_entries['val'], res.max_entries) - eq_(self.active_count['val'], res.active_count) - eq_(self.lookup_count['val'], res.lookup_count) - eq_(self.matched_count['val'], res.matched_count) + self.assertEqual(self.table_id['val'], res.table_id) + self.assertEqual(self.name, res.name) + self.assertEqual(self.wildcards['val'], res.wildcards) + self.assertEqual(self.max_entries['val'], res.max_entries) + self.assertEqual(self.active_count['val'], res.active_count) + self.assertEqual(self.lookup_count['val'], res.lookup_count) + self.assertEqual(self.matched_count['val'], res.matched_count) class TestOFPPortStats(unittest.TestCase): @@ -2347,36 +2322,36 @@ class TestOFPPortStats(unittest.TestCase): pass def test_init(self): - eq_(self.port_no['val'], self.c.port_no) - eq_(self.rx_packets['val'], self.c.rx_packets) - eq_(self.tx_packets['val'], self.c.tx_packets) - eq_(self.rx_bytes['val'], self.c.rx_bytes) - eq_(self.tx_bytes['val'], self.c.tx_bytes) - eq_(self.rx_dropped['val'], self.c.rx_dropped) - eq_(self.tx_dropped['val'], self.c.tx_dropped) - eq_(self.rx_errors['val'], self.c.rx_errors) - eq_(self.tx_errors['val'], self.c.tx_errors) - eq_(self.rx_frame_err['val'], self.c.rx_frame_err) - eq_(self.rx_over_err['val'], self.c.rx_over_err) - eq_(self.rx_crc_err['val'], self.c.rx_crc_err) - eq_(self.collisions['val'], self.c.collisions) + self.assertEqual(self.port_no['val'], self.c.port_no) + self.assertEqual(self.rx_packets['val'], self.c.rx_packets) + self.assertEqual(self.tx_packets['val'], self.c.tx_packets) + self.assertEqual(self.rx_bytes['val'], self.c.rx_bytes) + self.assertEqual(self.tx_bytes['val'], self.c.tx_bytes) + self.assertEqual(self.rx_dropped['val'], self.c.rx_dropped) + self.assertEqual(self.tx_dropped['val'], self.c.tx_dropped) + self.assertEqual(self.rx_errors['val'], self.c.rx_errors) + self.assertEqual(self.tx_errors['val'], self.c.tx_errors) + self.assertEqual(self.rx_frame_err['val'], self.c.rx_frame_err) + self.assertEqual(self.rx_over_err['val'], self.c.rx_over_err) + self.assertEqual(self.rx_crc_err['val'], self.c.rx_crc_err) + self.assertEqual(self.collisions['val'], self.c.collisions) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.port_no['val'], res.port_no) - eq_(self.rx_packets['val'], res.rx_packets) - eq_(self.tx_packets['val'], res.tx_packets) - eq_(self.rx_bytes['val'], res.rx_bytes) - eq_(self.tx_bytes['val'], res.tx_bytes) - eq_(self.rx_dropped['val'], res.rx_dropped) - eq_(self.tx_dropped['val'], res.tx_dropped) - eq_(self.rx_errors['val'], res.rx_errors) - eq_(self.tx_errors['val'], res.tx_errors) - eq_(self.rx_frame_err['val'], res.rx_frame_err) - eq_(self.rx_over_err['val'], res.rx_over_err) - eq_(self.rx_crc_err['val'], res.rx_crc_err) - eq_(self.collisions['val'], res.collisions) + self.assertEqual(self.port_no['val'], res.port_no) + self.assertEqual(self.rx_packets['val'], res.rx_packets) + self.assertEqual(self.tx_packets['val'], res.tx_packets) + self.assertEqual(self.rx_bytes['val'], res.rx_bytes) + self.assertEqual(self.tx_bytes['val'], res.tx_bytes) + self.assertEqual(self.rx_dropped['val'], res.rx_dropped) + self.assertEqual(self.tx_dropped['val'], res.tx_dropped) + self.assertEqual(self.rx_errors['val'], res.rx_errors) + self.assertEqual(self.tx_errors['val'], res.tx_errors) + self.assertEqual(self.rx_frame_err['val'], res.rx_frame_err) + self.assertEqual(self.rx_over_err['val'], res.rx_over_err) + self.assertEqual(self.rx_crc_err['val'], res.rx_crc_err) + self.assertEqual(self.collisions['val'], res.collisions) class TestOFPQueueStats(unittest.TestCase): @@ -2415,20 +2390,20 @@ class TestOFPQueueStats(unittest.TestCase): pass def test_init(self): - eq_(self.port_no['val'], self.c.port_no) - eq_(self.queue_id['val'], self.c.queue_id) - eq_(self.tx_bytes['val'], self.c.tx_bytes) - eq_(self.tx_packets['val'], self.c.tx_packets) - eq_(self.tx_errors['val'], self.c.tx_errors) + self.assertEqual(self.port_no['val'], self.c.port_no) + self.assertEqual(self.queue_id['val'], self.c.queue_id) + self.assertEqual(self.tx_bytes['val'], self.c.tx_bytes) + self.assertEqual(self.tx_packets['val'], self.c.tx_packets) + self.assertEqual(self.tx_errors['val'], self.c.tx_errors) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.port_no['val'], res.port_no) - eq_(self.queue_id['val'], res.queue_id) - eq_(self.tx_bytes['val'], res.tx_bytes) - eq_(self.tx_packets['val'], res.tx_packets) - eq_(self.tx_errors['val'], res.tx_errors) + self.assertEqual(self.port_no['val'], res.port_no) + self.assertEqual(self.queue_id['val'], res.queue_id) + self.assertEqual(self.tx_bytes['val'], res.tx_bytes) + self.assertEqual(self.tx_packets['val'], res.tx_packets) + self.assertEqual(self.tx_errors['val'], res.tx_errors) class TestOFPVendorStats(unittest.TestCase): @@ -2448,11 +2423,11 @@ class TestOFPVendorStats(unittest.TestCase): pass def test_init(self): - eq_(self.specific_data, self.c.specific_data) + self.assertEqual(self.specific_data, self.c.specific_data) def test_parser(self): res = self.c.parser(self.specific_data, self.offset) - eq_(self.specific_data_after, res.specific_data) + self.assertEqual(self.specific_data_after, res.specific_data) class TestOFPQueuePropNone(unittest.TestCase): @@ -2476,20 +2451,20 @@ class TestOFPQueuePropNone(unittest.TestCase): def test_init(self): cls = OFPQueuePropHeader._QUEUE_PROPERTIES[self.c.cls_prop_type] - eq_(self.property['val'], self.c.cls_prop_type) - eq_(self.property['val'], self.c.property) - eq_(self.property['val'], cls.cls_prop_type) + self.assertEqual(self.property['val'], self.c.cls_prop_type) + self.assertEqual(self.property['val'], self.c.property) + self.assertEqual(self.property['val'], cls.cls_prop_type) - eq_(self.len['val'], self.c.cls_prop_len) - eq_(self.len['val'], self.c.len) - eq_(self.len['val'], cls.cls_prop_len) + self.assertEqual(self.len['val'], self.c.cls_prop_len) + self.assertEqual(self.len['val'], self.c.len) + self.assertEqual(self.len['val'], cls.cls_prop_len) def test_parser(self): buf = self.property['buf'] \ + self.len['buf'] \ + self.zfill - ok_(self.c.parser(buf, 0)) + self.assertTrue(self.c.parser(buf, 0)) class TestOFPQueuePropMinRate(unittest.TestCase): @@ -2516,16 +2491,16 @@ class TestOFPQueuePropMinRate(unittest.TestCase): def test_init(self): cls = OFPQueuePropHeader._QUEUE_PROPERTIES[self.c.cls_prop_type] - eq_(self.rate['val'], self.c.cls_prop_type) - eq_(self.rate['val'], self.c.rate) - eq_(self.rate['val'], cls.cls_prop_type) + self.assertEqual(self.rate['val'], self.c.cls_prop_type) + self.assertEqual(self.rate['val'], self.c.rate) + self.assertEqual(self.rate['val'], cls.cls_prop_type) - eq_(self.len['val'], self.c.cls_prop_len) - eq_(self.len['val'], cls.cls_prop_len) + self.assertEqual(self.len['val'], self.c.cls_prop_len) + self.assertEqual(self.len['val'], cls.cls_prop_len) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.rate['val'], res.rate) + self.assertEqual(self.rate['val'], res.rate) class TestOFPPacketQueue(unittest.TestCase): @@ -2553,13 +2528,13 @@ class TestOFPPacketQueue(unittest.TestCase): pass def test_init(self): - eq_(self.queue_id['val'], self.c.queue_id) - eq_(self.len_['val'], self.c.len) + self.assertEqual(self.queue_id['val'], self.c.queue_id) + self.assertEqual(self.len_['val'], self.c.len) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.queue_id['val'], res.queue_id) - eq_(self.len_['val'], res.len) + self.assertEqual(self.queue_id['val'], res.queue_id) + self.assertEqual(self.len_['val'], res.len) def test_parser_append_prop(self): # OFP_QUEUE_PROP_HEADER_PACK_STR + OFP_QUEUE_PROP_MIN_RATE_PACK_STR @@ -2584,14 +2559,14 @@ class TestOFPPacketQueue(unittest.TestCase): res = self.c.parser(buf, 0) - eq_(self.queue_id['val'], res.queue_id) - eq_(len_['val'], res.len) + self.assertEqual(self.queue_id['val'], res.queue_id) + self.assertEqual(len_['val'], res.len) append_cls = res.properties[0] - eq_(a_type['val'], append_cls.property) - eq_(a_len['val'], append_cls.len) - eq_(a_rate['val'], append_cls.rate) + self.assertEqual(a_type['val'], append_cls.property) + self.assertEqual(a_len['val'], append_cls.len) + self.assertEqual(a_rate['val'], append_cls.rate) class TestOFPHello(unittest.TestCase): @@ -2621,11 +2596,11 @@ class TestOFPHello(unittest.TestCase): res = OFPHello.parser(object, version, msg_type, msg_len, xid, bytearray(buf)) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(six.binary_type(buf), six.binary_type(res.buf)) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(six.binary_type(buf), six.binary_type(res.buf)) def test_serialize(self): @@ -2635,9 +2610,9 @@ class TestOFPHello(unittest.TestCase): c = OFPHello(Datapath) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_HELLO, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_HELLO, c.msg_type) + self.assertEqual(0, c.xid) class TestOFPErrorMsg(unittest.TestCase): @@ -2678,13 +2653,13 @@ class TestOFPErrorMsg(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(type['val'], res.type) - eq_(code['val'], res.code) - eq_(data, res.data) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(type['val'], res.type) + self.assertEqual(code['val'], res.code) + self.assertEqual(data, res.data) def test_serialize(self): class Datapath(object): @@ -2702,9 +2677,9 @@ class TestOFPErrorMsg(unittest.TestCase): c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_ERROR, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_ERROR, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -2712,13 +2687,13 @@ class TestOFPErrorMsg(unittest.TestCase): + str(len(data)) + 's' res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_ERROR, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) - eq_(type, res[4]) - eq_(code, res[5]) - eq_(data, res[6]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_ERROR, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(type, res[4]) + self.assertEqual(code, res[5]) + self.assertEqual(data, res[6]) class TestOFPEchoRequest(unittest.TestCase): @@ -2755,11 +2730,11 @@ class TestOFPEchoRequest(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(data, res.data) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(data, res.data) def test_serialize(self): class Datapath(object): @@ -2773,20 +2748,20 @@ class TestOFPEchoRequest(unittest.TestCase): c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_ECHO_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_ECHO_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ + str(len(data)) + 's' res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_ECHO_REQUEST, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) - eq_(data, res[4]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_ECHO_REQUEST, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(data, res[4]) class TestOFPEchoReply(unittest.TestCase): @@ -2823,11 +2798,11 @@ class TestOFPEchoReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(data, res.data) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(data, res.data) def test_serialize(self): class Datapath(object): @@ -2841,20 +2816,20 @@ class TestOFPEchoReply(unittest.TestCase): c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_ECHO_REPLY, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_ECHO_REPLY, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ + str(len(data)) + 's' res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_ECHO_REPLY, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) - eq_(data, res[4]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_ECHO_REPLY, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(data, res[4]) class TestOFPVendor(unittest.TestCase): @@ -2893,12 +2868,12 @@ class TestOFPVendor(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(vendor['val'], res.vendor) - eq_(data, res.data) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(vendor['val'], res.vendor) + self.assertEqual(data, res.data) def test_serialize(self): class Datapath(object): @@ -2914,10 +2889,10 @@ class TestOFPVendor(unittest.TestCase): c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_VENDOR, c.msg_type) - eq_(0, c.xid) - eq_(vendor['val'], c.vendor) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_VENDOR, c.msg_type) + self.assertEqual(0, c.xid) + self.assertEqual(vendor['val'], c.vendor) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -2925,12 +2900,12 @@ class TestOFPVendor(unittest.TestCase): + str(len(data)) + 's' res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_VENDOR, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) - eq_(vendor['val'], res[4]) - eq_(data, res[5]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_VENDOR, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(vendor['val'], res[4]) + self.assertEqual(data, res[5]) # class TestNXTRequest(unittest.TestCase): @@ -2948,7 +2923,7 @@ class TestNiciraHeader(unittest.TestCase): subtype = ofproto.NXT_FLOW_MOD_TABLE_ID c = NiciraHeader(object, subtype) - eq_(subtype, c.subtype) + self.assertEqual(subtype, c.subtype) def test_parser(self): # Not used. @@ -2967,10 +2942,10 @@ class TestNiciraHeader(unittest.TestCase): c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_VENDOR, c.msg_type) - eq_(0, c.xid) - eq_(ofproto_common.NX_EXPERIMENTER_ID, c.vendor) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_VENDOR, c.msg_type) + self.assertEqual(0, c.xid) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, c.vendor) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -2978,13 +2953,13 @@ class TestNiciraHeader(unittest.TestCase): + str(len(data)) + 's' res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_VENDOR, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) - eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4]) - eq_(subtype, res[5]) - eq_(data, res[6]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_VENDOR, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, res[4]) + self.assertEqual(subtype, res[5]) + self.assertEqual(data, res[6]) class TestNXTSetFlowFormat(unittest.TestCase): @@ -3001,7 +2976,7 @@ class TestNXTSetFlowFormat(unittest.TestCase): flow_format = {'buf': b'\xdc\x6b\xf5\x24', 'val': 3698062628} c = NXTSetFlowFormat(object, flow_format['val']) - eq_(flow_format['val'], c.format) + self.assertEqual(flow_format['val'], c.format) def test_parser(self): # Not used. @@ -3017,10 +2992,10 @@ class TestNXTSetFlowFormat(unittest.TestCase): c = NXTSetFlowFormat(Datapath, flow_format['val']) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_VENDOR, c.msg_type) - eq_(0, c.xid) - eq_(ofproto_common.NX_EXPERIMENTER_ID, c.vendor) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_VENDOR, c.msg_type) + self.assertEqual(0, c.xid) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, c.vendor) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -3028,13 +3003,13 @@ class TestNXTSetFlowFormat(unittest.TestCase): + ofproto.NX_SET_FLOW_FORMAT_PACK_STR.replace('!', '') res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_VENDOR, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) - eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4]) - eq_(ofproto.NXT_SET_FLOW_FORMAT, res[5]) - eq_(flow_format['val'], res[6]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_VENDOR, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, res[4]) + self.assertEqual(ofproto.NXT_SET_FLOW_FORMAT, res[5]) + self.assertEqual(flow_format['val'], res[6]) class TestNXTFlowMod(unittest.TestCase): @@ -3091,23 +3066,23 @@ class TestNXTFlowMod(unittest.TestCase): def test_init(self): c = self._get_obj() - eq_(self.cookie['val'], c.cookie) - eq_(self.command['val'], c.command) - eq_(self.idle_timeout['val'], c.idle_timeout) - eq_(self.hard_timeout['val'], c.hard_timeout) - eq_(self.priority['val'], c.priority) - eq_(self.buffer_id['val'], c.buffer_id) - eq_(self.out_port['val'], c.out_port) - eq_(self.flags['val'], c.flags) - eq_(self.rule.__hash__(), c.rule.__hash__()) + self.assertEqual(self.cookie['val'], c.cookie) + self.assertEqual(self.command['val'], c.command) + self.assertEqual(self.idle_timeout['val'], c.idle_timeout) + self.assertEqual(self.hard_timeout['val'], c.hard_timeout) + self.assertEqual(self.priority['val'], c.priority) + self.assertEqual(self.buffer_id['val'], c.buffer_id) + self.assertEqual(self.out_port['val'], c.out_port) + self.assertEqual(self.flags['val'], c.flags) + self.assertEqual(self.rule.__hash__(), c.rule.__hash__()) def test_init_append_actions(self): c = self._get_obj(True) action = c.actions[0] - eq_(ofproto.OFPAT_OUTPUT, action.type) - eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, action.len) - eq_(self.port['val'], action.port) + self.assertEqual(ofproto.OFPAT_OUTPUT, action.type) + self.assertEqual(ofproto.OFP_ACTION_OUTPUT_SIZE, action.len) + self.assertEqual(self.port['val'], action.port) def test_parser(self): # Not used. @@ -3117,10 +3092,10 @@ class TestNXTFlowMod(unittest.TestCase): c = self._get_obj() c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_VENDOR, c.msg_type) - eq_(0, c.xid) - eq_(ofproto_common.NX_EXPERIMENTER_ID, c.vendor) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_VENDOR, c.msg_type) + self.assertEqual(0, c.xid) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, c.vendor) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -3128,29 +3103,29 @@ class TestNXTFlowMod(unittest.TestCase): + ofproto.NX_FLOW_MOD_PACK_STR.replace('!', '') res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_VENDOR, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) - eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4]) - eq_(ofproto.NXT_FLOW_MOD, res[5]) - eq_(self.cookie['val'], res[6]) - eq_(self.command['val'], res[7]) - eq_(self.idle_timeout['val'], res[8]) - eq_(self.hard_timeout['val'], res[9]) - eq_(self.priority['val'], res[10]) - eq_(self.buffer_id['val'], res[11]) - eq_(self.out_port['val'], res[12]) - eq_(self.flags['val'], res[13]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_VENDOR, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, res[4]) + self.assertEqual(ofproto.NXT_FLOW_MOD, res[5]) + self.assertEqual(self.cookie['val'], res[6]) + self.assertEqual(self.command['val'], res[7]) + self.assertEqual(self.idle_timeout['val'], res[8]) + self.assertEqual(self.hard_timeout['val'], res[9]) + self.assertEqual(self.priority['val'], res[10]) + self.assertEqual(self.buffer_id['val'], res[11]) + self.assertEqual(self.out_port['val'], res[12]) + self.assertEqual(self.flags['val'], res[13]) def test_serialize_append_actions(self): c = self._get_obj(True) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_VENDOR, c.msg_type) - eq_(0, c.xid) - eq_(ofproto_common.NX_EXPERIMENTER_ID, c.vendor) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_VENDOR, c.msg_type) + self.assertEqual(0, c.xid) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, c.vendor) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -3159,27 +3134,27 @@ class TestNXTFlowMod(unittest.TestCase): + ofproto.OFP_ACTION_OUTPUT_PACK_STR.replace('!', '') res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_VENDOR, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) - eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4]) - eq_(ofproto.NXT_FLOW_MOD, res[5]) - eq_(self.cookie['val'], res[6]) - eq_(self.command['val'], res[7]) - eq_(self.idle_timeout['val'], res[8]) - eq_(self.hard_timeout['val'], res[9]) - eq_(self.priority['val'], res[10]) - eq_(self.buffer_id['val'], res[11]) - eq_(self.out_port['val'], res[12]) - eq_(self.flags['val'], res[13]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_VENDOR, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, res[4]) + self.assertEqual(ofproto.NXT_FLOW_MOD, res[5]) + self.assertEqual(self.cookie['val'], res[6]) + self.assertEqual(self.command['val'], res[7]) + self.assertEqual(self.idle_timeout['val'], res[8]) + self.assertEqual(self.hard_timeout['val'], res[9]) + self.assertEqual(self.priority['val'], res[10]) + self.assertEqual(self.buffer_id['val'], res[11]) + self.assertEqual(self.out_port['val'], res[12]) + self.assertEqual(self.flags['val'], res[13]) # action - eq_(0, res[14]) - eq_(ofproto.OFPAT_OUTPUT, res[15]) - eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, res[16]) - eq_(self.port['val'], res[17]) - eq_(0xffe5, res[18]) + self.assertEqual(0, res[14]) + self.assertEqual(ofproto.OFPAT_OUTPUT, res[15]) + self.assertEqual(ofproto.OFP_ACTION_OUTPUT_SIZE, res[16]) + self.assertEqual(self.port['val'], res[17]) + self.assertEqual(0xffe5, res[18]) class TestNXTRoleRequest(unittest.TestCase): @@ -3203,7 +3178,7 @@ class TestNXTRoleRequest(unittest.TestCase): pass def test_init(self): - eq_(self.role['val'], self.c.role) + self.assertEqual(self.role['val'], self.c.role) def test_parser(self): # Not used. @@ -3212,10 +3187,10 @@ class TestNXTRoleRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_VENDOR, self.c.msg_type) - eq_(0, self.c.xid) - eq_(ofproto_common.NX_EXPERIMENTER_ID, self.c.vendor) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_VENDOR, self.c.msg_type) + self.assertEqual(0, self.c.xid) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, self.c.vendor) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -3224,13 +3199,13 @@ class TestNXTRoleRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(self.c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_VENDOR, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) - eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4]) - eq_(ofproto.NXT_ROLE_REQUEST, res[5]) - eq_(self.role['val'], res[6]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_VENDOR, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, res[4]) + self.assertEqual(ofproto.NXT_ROLE_REQUEST, res[5]) + self.assertEqual(self.role['val'], res[6]) class TestNXTFlowModTableId(unittest.TestCase): @@ -3255,7 +3230,7 @@ class TestNXTFlowModTableId(unittest.TestCase): pass def test_init(self): - eq_(self.set_['val'], self.c.set) + self.assertEqual(self.set_['val'], self.c.set) def test_parser(self): # Not used. @@ -3264,10 +3239,10 @@ class TestNXTFlowModTableId(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_VENDOR, self.c.msg_type) - eq_(0, self.c.xid) - eq_(ofproto_common.NX_EXPERIMENTER_ID, self.c.vendor) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_VENDOR, self.c.msg_type) + self.assertEqual(0, self.c.xid) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, self.c.vendor) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -3275,13 +3250,13 @@ class TestNXTFlowModTableId(unittest.TestCase): + ofproto.NX_FLOW_MOD_TABLE_ID_PACK_STR.replace('!', '') res = struct.unpack(fmt, six.binary_type(self.c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_VENDOR, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) - eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4]) - eq_(ofproto.NXT_FLOW_MOD_TABLE_ID, res[5]) - eq_(self.set_['val'], res[6]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_VENDOR, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(ofproto_common.NX_EXPERIMENTER_ID, res[4]) + self.assertEqual(ofproto.NXT_FLOW_MOD_TABLE_ID, res[5]) + self.assertEqual(self.set_['val'], res[6]) class TestOFPSwitchFeatures(unittest.TestCase): @@ -3362,27 +3337,27 @@ class TestOFPSwitchFeatures(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(datapath_id['val'], res.datapath_id) - eq_(n_buffers['val'], res.n_buffers) - eq_(n_tables['val'], res.n_tables) - eq_(capabilities['val'], res.capabilities) - eq_(actions['val'], res.actions) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(datapath_id['val'], res.datapath_id) + self.assertEqual(n_buffers['val'], res.n_buffers) + self.assertEqual(n_tables['val'], res.n_tables) + self.assertEqual(capabilities['val'], res.capabilities) + self.assertEqual(actions['val'], res.actions) # port port = res.ports[port_no['val']] - eq_(port_no['val'], port.port_no) - eq_(hw_addr, hw_addr) - eq_(name, port.name) - eq_(config['val'], port.config) - eq_(state['val'], port.state) - eq_(curr['val'], port.curr) - eq_(advertised['val'], port.advertised) - eq_(supported['val'], port.supported) - eq_(peer['val'], port.peer) + self.assertEqual(port_no['val'], port.port_no) + self.assertEqual(hw_addr, hw_addr) + self.assertEqual(name, port.name) + self.assertEqual(config['val'], port.config) + self.assertEqual(state['val'], port.state) + self.assertEqual(curr['val'], port.curr) + self.assertEqual(advertised['val'], port.advertised) + self.assertEqual(supported['val'], port.supported) + self.assertEqual(peer['val'], port.peer) def test_serialize(self): # Not used. @@ -3454,23 +3429,23 @@ class TestOFPPortStatus(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(reason['val'], res.reason) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(reason['val'], res.reason) # desc desc = res.desc - eq_(port_no['val'], desc.port_no) - eq_(hw_addr, desc.hw_addr) - eq_(name, desc.name) - eq_(config['val'], desc.config) - eq_(state['val'], desc.state) - eq_(curr['val'], desc.curr) - eq_(advertised['val'], desc.advertised) - eq_(supported['val'], desc.supported) - eq_(peer['val'], desc.peer) + self.assertEqual(port_no['val'], desc.port_no) + self.assertEqual(hw_addr, desc.hw_addr) + self.assertEqual(name, desc.name) + self.assertEqual(config['val'], desc.config) + self.assertEqual(state['val'], desc.state) + self.assertEqual(curr['val'], desc.curr) + self.assertEqual(advertised['val'], desc.advertised) + self.assertEqual(supported['val'], desc.supported) + self.assertEqual(peer['val'], desc.peer) def test_serialize(self): # Not used. @@ -3534,23 +3509,23 @@ class TestOFPPacketIn(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(buffer_id['val'], res.buffer_id) - eq_(total_len['val'], res.total_len) - eq_(in_port['val'], res.in_port) - eq_(reason['val'], res.reason) - eq_(data[0:16], res.data) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(buffer_id['val'], res.buffer_id) + self.assertEqual(total_len['val'], res.total_len) + self.assertEqual(in_port['val'], res.in_port) + self.assertEqual(reason['val'], res.reason) + self.assertEqual(data[0:16], res.data) return True def test_parser(self): - ok_(self._test_parser()) + self.assertTrue(self._test_parser()) def test_parser_padding(self): - ok_(self._test_parser(True)) + self.assertTrue(self._test_parser(True)) def test_serialize(self): # Not used. @@ -3602,12 +3577,12 @@ class TestOFPGetConfigReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(flags['val'], res.flags) - eq_(miss_send_len['val'], res.miss_send_len) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(flags['val'], res.flags) + self.assertEqual(miss_send_len['val'], res.miss_send_len) def test_serialize(self): # Not used. @@ -3652,10 +3627,10 @@ class TestOFPBarrierReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) def test_serialize(self): # Not used. @@ -3765,34 +3740,34 @@ class TestOFPFlowRemoved(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(cookie['val'], res.cookie) - eq_(priority['val'], res.priority) - eq_(reason['val'], res.reason) - eq_(duration_sec['val'], res.duration_sec) - eq_(duration_nsec['val'], res.duration_nsec) - eq_(idle_timeout['val'], res.idle_timeout) - eq_(packet_count['val'], res.packet_count) - eq_(byte_count['val'], res.byte_count) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(cookie['val'], res.cookie) + self.assertEqual(priority['val'], res.priority) + self.assertEqual(reason['val'], res.reason) + self.assertEqual(duration_sec['val'], res.duration_sec) + self.assertEqual(duration_nsec['val'], res.duration_nsec) + self.assertEqual(idle_timeout['val'], res.idle_timeout) + self.assertEqual(packet_count['val'], res.packet_count) + self.assertEqual(byte_count['val'], res.byte_count) # match match = res.match - eq_(wildcards['val'], match.wildcards) - eq_(in_port['val'], match.in_port) - eq_(dl_src, match.dl_src) - eq_(dl_dst, match.dl_dst) - eq_(dl_vlan['val'], match.dl_vlan) - eq_(dl_vlan_pcp['val'], match.dl_vlan_pcp) - eq_(dl_type['val'], match.dl_type) - eq_(nw_tos['val'], match.nw_tos) - eq_(nw_proto['val'], match.nw_proto) - eq_(nw_src['val'], match.nw_src) - eq_(nw_dst['val'], match.nw_dst) - eq_(tp_src['val'], match.tp_src) - eq_(tp_dst['val'], match.tp_dst) + self.assertEqual(wildcards['val'], match.wildcards) + self.assertEqual(in_port['val'], match.in_port) + self.assertEqual(dl_src, match.dl_src) + self.assertEqual(dl_dst, match.dl_dst) + self.assertEqual(dl_vlan['val'], match.dl_vlan) + self.assertEqual(dl_vlan_pcp['val'], match.dl_vlan_pcp) + self.assertEqual(dl_type['val'], match.dl_type) + self.assertEqual(nw_tos['val'], match.nw_tos) + self.assertEqual(nw_proto['val'], match.nw_proto) + self.assertEqual(nw_src['val'], match.nw_src) + self.assertEqual(nw_dst['val'], match.nw_dst) + self.assertEqual(tp_src['val'], match.tp_src) + self.assertEqual(tp_dst['val'], match.tp_dst) def test_serialize(self): # Not used. @@ -3858,16 +3833,16 @@ class TestOFPQueueGetConfigReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(port['val'], res.port) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(port['val'], res.port) # queue queue = res.queues[0] - eq_(queue_id['val'], queue.queue_id) - eq_(len_['val'], queue.len) + self.assertEqual(queue_id['val'], queue.queue_id) + self.assertEqual(len_['val'], queue.len) def test_serialize(self): # Not used. @@ -3937,20 +3912,20 @@ class TestOFPDescStatsReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(type_['val'], res.type) - eq_(flags['val'], res.flags) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(type_['val'], res.type) + self.assertEqual(flags['val'], res.flags) # body body = res.body - eq_(mfr_desc, body.mfr_desc) - eq_(hw_desc, body.hw_desc) - eq_(sw_desc, body.sw_desc) - eq_(serial_num, body.serial_num) - eq_(dp_desc, body.dp_desc) + self.assertEqual(mfr_desc, body.mfr_desc) + self.assertEqual(hw_desc, body.hw_desc) + self.assertEqual(sw_desc, body.sw_desc) + self.assertEqual(serial_num, body.serial_num) + self.assertEqual(dp_desc, body.dp_desc) def test_serialize(self): # Not used. @@ -4075,32 +4050,32 @@ class TestOFPFlowStatsReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(type_['val'], res.type) - eq_(flags['val'], res.flags) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(type_['val'], res.type) + self.assertEqual(flags['val'], res.flags) # body body = res.body[0] - eq_(length['val'], body.length) - eq_(table_id['val'], body.table_id) - eq_(duration_sec['val'], body.duration_sec) - eq_(duration_nsec['val'], body.duration_nsec) - eq_(priority['val'], body.priority) - eq_(idle_timeout['val'], body.idle_timeout) - eq_(hard_timeout['val'], body.hard_timeout) - eq_(cookie['val'], body.cookie) - eq_(packet_count['val'], body.packet_count) - eq_(byte_count['val'], body.byte_count) + self.assertEqual(length['val'], body.length) + self.assertEqual(table_id['val'], body.table_id) + self.assertEqual(duration_sec['val'], body.duration_sec) + self.assertEqual(duration_nsec['val'], body.duration_nsec) + self.assertEqual(priority['val'], body.priority) + self.assertEqual(idle_timeout['val'], body.idle_timeout) + self.assertEqual(hard_timeout['val'], body.hard_timeout) + self.assertEqual(cookie['val'], body.cookie) + self.assertEqual(packet_count['val'], body.packet_count) + self.assertEqual(byte_count['val'], body.byte_count) # action action = body.actions[0] - eq_(type['val'], action.type) - eq_(len['val'], action.len) - eq_(port['val'], action.port) - eq_(max_len['val'], action.max_len) + self.assertEqual(type['val'], action.type) + self.assertEqual(len['val'], action.len) + self.assertEqual(port['val'], action.port) + self.assertEqual(max_len['val'], action.max_len) def test_serialize(self): # Not used. @@ -4169,18 +4144,18 @@ class TestOFPAggregateStatsReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(type_['val'], res.type) - eq_(flags['val'], res.flags) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(type_['val'], res.type) + self.assertEqual(flags['val'], res.flags) # body body = res.body[0] - eq_(packet_count['val'], body.packet_count) - eq_(byte_count['val'], body.byte_count) - eq_(flow_count['val'], body.flow_count) + self.assertEqual(packet_count['val'], body.packet_count) + self.assertEqual(byte_count['val'], body.byte_count) + self.assertEqual(flow_count['val'], body.flow_count) def test_serialize(self): # Not used. @@ -4258,22 +4233,22 @@ class TestOFPTableStatsReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(type_['val'], res.type) - eq_(flags['val'], res.flags) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(type_['val'], res.type) + self.assertEqual(flags['val'], res.flags) # body body = res.body[0] - eq_(table_id['val'], body.table_id) - eq_(name, body.name) - eq_(wildcards['val'], body.wildcards) - eq_(max_entries['val'], body.max_entries) - eq_(active_count['val'], body.active_count) - eq_(lookup_count['val'], body.lookup_count) - eq_(matched_count['val'], body.matched_count) + self.assertEqual(table_id['val'], body.table_id) + self.assertEqual(name, body.name) + self.assertEqual(wildcards['val'], body.wildcards) + self.assertEqual(max_entries['val'], body.max_entries) + self.assertEqual(active_count['val'], body.active_count) + self.assertEqual(lookup_count['val'], body.lookup_count) + self.assertEqual(matched_count['val'], body.matched_count) def test_serialize(self): # Not used. @@ -4375,28 +4350,28 @@ class TestOFPPortStatsReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(type_['val'], res.type) - eq_(flags['val'], res.flags) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(type_['val'], res.type) + self.assertEqual(flags['val'], res.flags) # body body = res.body[0] - eq_(port_no['val'], body.port_no) - eq_(rx_packets['val'], body.rx_packets) - eq_(tx_packets['val'], body.tx_packets) - eq_(rx_bytes['val'], body.rx_bytes) - eq_(tx_bytes['val'], body.tx_bytes) - eq_(rx_dropped['val'], body.rx_dropped) - eq_(tx_dropped['val'], body.tx_dropped) - eq_(rx_errors['val'], body.rx_errors) - eq_(tx_errors['val'], body.tx_errors) - eq_(rx_frame_err['val'], body.rx_frame_err) - eq_(rx_over_err['val'], body.rx_over_err) - eq_(rx_crc_err['val'], body.rx_crc_err) - eq_(collisions['val'], body.collisions) + self.assertEqual(port_no['val'], body.port_no) + self.assertEqual(rx_packets['val'], body.rx_packets) + self.assertEqual(tx_packets['val'], body.tx_packets) + self.assertEqual(rx_bytes['val'], body.rx_bytes) + self.assertEqual(tx_bytes['val'], body.tx_bytes) + self.assertEqual(rx_dropped['val'], body.rx_dropped) + self.assertEqual(tx_dropped['val'], body.tx_dropped) + self.assertEqual(rx_errors['val'], body.rx_errors) + self.assertEqual(tx_errors['val'], body.tx_errors) + self.assertEqual(rx_frame_err['val'], body.rx_frame_err) + self.assertEqual(rx_over_err['val'], body.rx_over_err) + self.assertEqual(rx_crc_err['val'], body.rx_crc_err) + self.assertEqual(collisions['val'], body.collisions) def test_serialize(self): # Not used. @@ -4470,20 +4445,20 @@ class TestOFPQueueStatsReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(type_['val'], res.type) - eq_(flags['val'], res.flags) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(type_['val'], res.type) + self.assertEqual(flags['val'], res.flags) # body body = res.body[0] - eq_(port_no['val'], body.port_no) - eq_(queue_id['val'], body.queue_id) - eq_(tx_bytes['val'], body.tx_bytes) - eq_(tx_packets['val'], body.tx_packets) - eq_(tx_errors['val'], body.tx_errors) + self.assertEqual(port_no['val'], body.port_no) + self.assertEqual(queue_id['val'], body.queue_id) + self.assertEqual(tx_bytes['val'], body.tx_bytes) + self.assertEqual(tx_packets['val'], body.tx_packets) + self.assertEqual(tx_errors['val'], body.tx_errors) def test_serialize(self): # Not used. @@ -4542,16 +4517,16 @@ class TestOFPVendorStatsReply(unittest.TestCase): xid['val'], buf) - eq_(version['val'], res.version) - eq_(msg_type['val'], res.msg_type) - eq_(msg_len['val'], res.msg_len) - eq_(xid['val'], res.xid) - eq_(type_['val'], res.type) - eq_(flags['val'], res.flags) + self.assertEqual(version['val'], res.version) + self.assertEqual(msg_type['val'], res.msg_type) + self.assertEqual(msg_len['val'], res.msg_len) + self.assertEqual(xid['val'], res.xid) + self.assertEqual(type_['val'], res.type) + self.assertEqual(flags['val'], res.flags) # body body = res.body[0] - eq_(specific_data, body) + self.assertEqual(specific_data, body) def test_serialize(self): # Not used. @@ -4584,17 +4559,17 @@ class TestOFPFeaturesRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_FEATURES_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_FEATURES_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = ofproto.OFP_HEADER_PACK_STR res = struct.unpack(fmt, six.binary_type(self.c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_FEATURES_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_FEATURES_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) class TestOFPGetConfigRequest(unittest.TestCase): @@ -4623,17 +4598,17 @@ class TestOFPGetConfigRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_GET_CONFIG_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_GET_CONFIG_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = ofproto.OFP_HEADER_PACK_STR res = struct.unpack(fmt, six.binary_type(self.c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_GET_CONFIG_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_GET_CONFIG_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) class TestOFPSetConfig(unittest.TestCase): @@ -4660,8 +4635,8 @@ class TestOFPSetConfig(unittest.TestCase): pass def test_init(self): - eq_(self.flags['val'], self.c.flags) - eq_(self.miss_send_len['val'], self.c.miss_send_len) + self.assertEqual(self.flags['val'], self.c.flags) + self.assertEqual(self.miss_send_len['val'], self.c.miss_send_len) def test_parser(self): # Not used. @@ -4670,21 +4645,21 @@ class TestOFPSetConfig(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_SET_CONFIG, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_SET_CONFIG, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ + ofproto.OFP_SWITCH_CONFIG_PACK_STR.replace('!', '') res = struct.unpack(fmt, six.binary_type(self.c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_SET_CONFIG, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) - eq_(self.flags['val'], res[4]) - eq_(self.miss_send_len['val'], res[5]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_SET_CONFIG, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(self.flags['val'], res[4]) + self.assertEqual(self.miss_send_len['val'], res[5]) class TestOFPPacketOut(unittest.TestCase): @@ -4719,9 +4694,9 @@ class TestOFPPacketOut(unittest.TestCase): c = self._get_obj(buffer_id, in_port, data) - eq_(buffer_id, c.buffer_id) - eq_(in_port, c.in_port) - eq_(data, c.data) + self.assertEqual(buffer_id, c.buffer_id) + self.assertEqual(in_port, c.in_port) + self.assertEqual(data, c.data) def test_parser(self): # Not used. @@ -4735,9 +4710,9 @@ class TestOFPPacketOut(unittest.TestCase): c = self._get_obj(buffer_id, in_port, data) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_PACKET_OUT, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_PACKET_OUT, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -4748,33 +4723,32 @@ class TestOFPPacketOut(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) # OFP_HEADER_PACK_STR - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_PACKET_OUT, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_PACKET_OUT, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) # OFP_PACKET_OUT_PACK_STR - eq_(buffer_id, res[4]) - eq_(in_port, res[5]) - eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, res[6]) + self.assertEqual(buffer_id, res[4]) + self.assertEqual(in_port, res[5]) + self.assertEqual(ofproto.OFP_ACTION_OUTPUT_SIZE, res[6]) # OFP_ACTION_OUTPUT_PACK_STR - eq_(ofproto.OFPAT_OUTPUT, res[7]) - eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, res[8]) - eq_(self.port, res[9]) - eq_(0, res[10]) + self.assertEqual(ofproto.OFPAT_OUTPUT, res[7]) + self.assertEqual(ofproto.OFP_ACTION_OUTPUT_SIZE, res[8]) + self.assertEqual(self.port, res[9]) + self.assertEqual(0, res[10]) # data - eq_(data, res[11]) + self.assertEqual(data, res[11]) - @raises(AssertionError) def test_serialize_check_buffer_id(self): buffer_id = 0xffffff00 in_port = 0xaa92 data = 'Message' c = self._get_obj(buffer_id, in_port, data) - c.serialize() + self.assertRaises(AssertionError, c.serialize) class TestOFPFlowMod(unittest.TestCase): @@ -4859,20 +4833,20 @@ class TestOFPFlowMod(unittest.TestCase): def test_init(self): c = self._get_obj() - eq_(self.cookie['val'], c.cookie) - eq_(self.command['val'], c.command) - eq_(self.idle_timeout['val'], c.idle_timeout) - eq_(self.hard_timeout['val'], c.hard_timeout) - eq_(self.priority['val'], c.priority) - eq_(self.buffer_id['val'], c.buffer_id) - eq_(self.out_port['val'], c.out_port) - eq_(self.flags['val'], c.flags) + self.assertEqual(self.cookie['val'], c.cookie) + self.assertEqual(self.command['val'], c.command) + self.assertEqual(self.idle_timeout['val'], c.idle_timeout) + self.assertEqual(self.hard_timeout['val'], c.hard_timeout) + self.assertEqual(self.priority['val'], c.priority) + self.assertEqual(self.buffer_id['val'], c.buffer_id) + self.assertEqual(self.out_port['val'], c.out_port) + self.assertEqual(self.flags['val'], c.flags) def test_init_actions(self): c = self._get_obj(self.actions) action = c.actions[0] - eq_(self.port, action.port) + self.assertEqual(self.port, action.port) def test_parser(self): # Not used. @@ -4882,9 +4856,9 @@ class TestOFPFlowMod(unittest.TestCase): c = self._get_obj(self.actions) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_FLOW_MOD, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_FLOW_MOD, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -4895,41 +4869,41 @@ class TestOFPFlowMod(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) # OFP_HEADER_PACK_STR - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_FLOW_MOD, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_FLOW_MOD, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) # OFP_MATCH_PACK_STR - eq_(self.wildcards['val'], res[4]) - eq_(self.in_port['val'], res[5]) - eq_(self.dl_src, res[6]) - eq_(self.dl_dst, res[7]) - eq_(self.dl_vlan['val'], res[8]) - eq_(self.dl_vlan_pcp['val'], res[9]) - eq_(self.dl_type['val'], res[10]) - eq_(self.nw_tos['val'], res[11]) - eq_(self.nw_proto['val'], res[12]) - eq_(self.nw_src['val'], res[13]) - eq_(self.nw_dst['val'], res[14]) - eq_(self.tp_src['val'], res[15]) - eq_(self.tp_dst['val'], res[16]) + self.assertEqual(self.wildcards['val'], res[4]) + self.assertEqual(self.in_port['val'], res[5]) + self.assertEqual(self.dl_src, res[6]) + self.assertEqual(self.dl_dst, res[7]) + self.assertEqual(self.dl_vlan['val'], res[8]) + self.assertEqual(self.dl_vlan_pcp['val'], res[9]) + self.assertEqual(self.dl_type['val'], res[10]) + self.assertEqual(self.nw_tos['val'], res[11]) + self.assertEqual(self.nw_proto['val'], res[12]) + self.assertEqual(self.nw_src['val'], res[13]) + self.assertEqual(self.nw_dst['val'], res[14]) + self.assertEqual(self.tp_src['val'], res[15]) + self.assertEqual(self.tp_dst['val'], res[16]) # OFP_FLOW_MOD_PACK_STR0 - eq_(self.cookie['val'], res[17]) - eq_(self.command['val'], res[18]) - eq_(self.idle_timeout['val'], res[19]) - eq_(self.hard_timeout['val'], res[20]) - eq_(self.priority['val'], res[21]) - eq_(self.buffer_id['val'], res[22]) - eq_(self.out_port['val'], res[23]) - eq_(self.flags['val'], res[24]) + self.assertEqual(self.cookie['val'], res[17]) + self.assertEqual(self.command['val'], res[18]) + self.assertEqual(self.idle_timeout['val'], res[19]) + self.assertEqual(self.hard_timeout['val'], res[20]) + self.assertEqual(self.priority['val'], res[21]) + self.assertEqual(self.buffer_id['val'], res[22]) + self.assertEqual(self.out_port['val'], res[23]) + self.assertEqual(self.flags['val'], res[24]) # OFP_ACTION_OUTPUT_PACK_STR - eq_(ofproto.OFPAT_OUTPUT, res[25]) - eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, res[26]) - eq_(self.port, res[27]) - eq_(1000, res[28]) + self.assertEqual(ofproto.OFPAT_OUTPUT, res[25]) + self.assertEqual(ofproto.OFP_ACTION_OUTPUT_SIZE, res[26]) + self.assertEqual(self.port, res[27]) + self.assertEqual(1000, res[28]) class TestOFPBarrierRequest(unittest.TestCase): @@ -4958,17 +4932,17 @@ class TestOFPBarrierRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_BARRIER_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_BARRIER_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = ofproto.OFP_HEADER_PACK_STR res = struct.unpack(fmt, six.binary_type(self.c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_BARRIER_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_BARRIER_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) class TestOFPQueueGetConfigRequest(unittest.TestCase): @@ -4994,7 +4968,7 @@ class TestOFPQueueGetConfigRequest(unittest.TestCase): pass def test_init(self): - eq_(self.port['val'], self.c.port) + self.assertEqual(self.port['val'], self.c.port) def test_parser(self): # Not used. @@ -5003,20 +4977,20 @@ class TestOFPQueueGetConfigRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) a = ofproto.OFP_HEADER_PACK_STR.replace('!', '') b = ofproto.OFP_QUEUE_GET_CONFIG_REQUEST_PACK_STR.replace('!', '') fmt = '!' + a + b res = struct.unpack(fmt, six.binary_type(self.c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) - eq_(self.port['val'], res[4]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(self.port['val'], res[4]) class TestOFPDescStatsRequest(unittest.TestCase): @@ -5038,8 +5012,8 @@ class TestOFPDescStatsRequest(unittest.TestCase): pass def test_init(self): - eq_(ofproto.OFPST_DESC, self.c.type) - eq_(self.flags['val'], self.c.flags) + self.assertEqual(ofproto.OFPST_DESC, self.c.type) + self.assertEqual(self.flags['val'], self.c.flags) def test_parser(self): # Not used. @@ -5048,9 +5022,9 @@ class TestOFPDescStatsRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5059,14 +5033,14 @@ class TestOFPDescStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(self.c.buf)) # OFP_HEADER_PACK_STR - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_STATS_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) # OFP_STATS_MSG_PACK_STR - eq_(ofproto.OFPST_DESC, res[4]) - eq_(self.flags['val'], res[5]) + self.assertEqual(ofproto.OFPST_DESC, res[4]) + self.assertEqual(self.flags['val'], res[5]) class TestOFPFlowStatsRequest(unittest.TestCase): @@ -5132,14 +5106,14 @@ class TestOFPFlowStatsRequest(unittest.TestCase): pass def test_init(self): - eq_(ofproto.OFPST_FLOW, self.c.type) - eq_(self.flags['val'], self.c.flags) - eq_(self.table_id['val'], self.c.table_id) - eq_(self.out_port['val'], self.c.out_port) + self.assertEqual(ofproto.OFPST_FLOW, self.c.type) + self.assertEqual(self.flags['val'], self.c.flags) + self.assertEqual(self.table_id['val'], self.c.table_id) + self.assertEqual(self.out_port['val'], self.c.out_port) # match match = self.c.match - eq_(self.match.__hash__(), match.__hash__()) + self.assertEqual(self.match.__hash__(), match.__hash__()) def test_parser(self): # Not used. @@ -5148,9 +5122,9 @@ class TestOFPFlowStatsRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5161,33 +5135,33 @@ class TestOFPFlowStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(self.c.buf)) # OFP_HEADER_PACK_STR - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_STATS_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) # OFP_STATS_MSG_PACK_STR - eq_(ofproto.OFPST_FLOW, res[4]) - eq_(self.flags['val'], res[5]) + self.assertEqual(ofproto.OFPST_FLOW, res[4]) + self.assertEqual(self.flags['val'], res[5]) # OFP_MATCH_PACK_STR - eq_(self.wildcards['val'], res[6]) - eq_(self.in_port['val'], res[7]) - eq_(self.dl_src, res[8]) - eq_(self.dl_dst, res[9]) - eq_(self.dl_vlan['val'], res[10]) - eq_(self.dl_vlan_pcp['val'], res[11]) - eq_(self.dl_type['val'], res[12]) - eq_(self.nw_tos['val'], res[13]) - eq_(self.nw_proto['val'], res[14]) - eq_(self.nw_src['val'], res[15]) - eq_(self.nw_dst['val'], res[16]) - eq_(self.tp_src['val'], res[17]) - eq_(self.tp_dst['val'], res[18]) + self.assertEqual(self.wildcards['val'], res[6]) + self.assertEqual(self.in_port['val'], res[7]) + self.assertEqual(self.dl_src, res[8]) + self.assertEqual(self.dl_dst, res[9]) + self.assertEqual(self.dl_vlan['val'], res[10]) + self.assertEqual(self.dl_vlan_pcp['val'], res[11]) + self.assertEqual(self.dl_type['val'], res[12]) + self.assertEqual(self.nw_tos['val'], res[13]) + self.assertEqual(self.nw_proto['val'], res[14]) + self.assertEqual(self.nw_src['val'], res[15]) + self.assertEqual(self.nw_dst['val'], res[16]) + self.assertEqual(self.tp_src['val'], res[17]) + self.assertEqual(self.tp_dst['val'], res[18]) # OFP_FLOW_STATS_REQUEST_ID_PORT_STR - eq_(self.table_id['val'], res[19]) - eq_(self.out_port['val'], res[20]) + self.assertEqual(self.table_id['val'], res[19]) + self.assertEqual(self.out_port['val'], res[20]) class TestOFPAggregateStatsRequest(unittest.TestCase): @@ -5253,14 +5227,14 @@ class TestOFPAggregateStatsRequest(unittest.TestCase): pass def test_init(self): - eq_(ofproto.OFPST_AGGREGATE, self.c.type) - eq_(self.flags['val'], self.c.flags) - eq_(self.table_id['val'], self.c.table_id) - eq_(self.out_port['val'], self.c.out_port) + self.assertEqual(ofproto.OFPST_AGGREGATE, self.c.type) + self.assertEqual(self.flags['val'], self.c.flags) + self.assertEqual(self.table_id['val'], self.c.table_id) + self.assertEqual(self.out_port['val'], self.c.out_port) # match match = self.c.match - eq_(self.match.__hash__(), match.__hash__()) + self.assertEqual(self.match.__hash__(), match.__hash__()) def test_parser(self): # Not used. @@ -5269,9 +5243,9 @@ class TestOFPAggregateStatsRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5282,33 +5256,33 @@ class TestOFPAggregateStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(self.c.buf)) # OFP_HEADER_PACK_STR - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_STATS_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) # OFP_STATS_MSG_PACK_STR - eq_(ofproto.OFPST_AGGREGATE, res[4]) - eq_(self.flags['val'], res[5]) + self.assertEqual(ofproto.OFPST_AGGREGATE, res[4]) + self.assertEqual(self.flags['val'], res[5]) # OFP_MATCH_PACK_STR - eq_(self.wildcards['val'], res[6]) - eq_(self.in_port['val'], res[7]) - eq_(self.dl_src, res[8]) - eq_(self.dl_dst, res[9]) - eq_(self.dl_vlan['val'], res[10]) - eq_(self.dl_vlan_pcp['val'], res[11]) - eq_(self.dl_type['val'], res[12]) - eq_(self.nw_tos['val'], res[13]) - eq_(self.nw_proto['val'], res[14]) - eq_(self.nw_src['val'], res[15]) - eq_(self.nw_dst['val'], res[16]) - eq_(self.tp_src['val'], res[17]) - eq_(self.tp_dst['val'], res[18]) + self.assertEqual(self.wildcards['val'], res[6]) + self.assertEqual(self.in_port['val'], res[7]) + self.assertEqual(self.dl_src, res[8]) + self.assertEqual(self.dl_dst, res[9]) + self.assertEqual(self.dl_vlan['val'], res[10]) + self.assertEqual(self.dl_vlan_pcp['val'], res[11]) + self.assertEqual(self.dl_type['val'], res[12]) + self.assertEqual(self.nw_tos['val'], res[13]) + self.assertEqual(self.nw_proto['val'], res[14]) + self.assertEqual(self.nw_src['val'], res[15]) + self.assertEqual(self.nw_dst['val'], res[16]) + self.assertEqual(self.tp_src['val'], res[17]) + self.assertEqual(self.tp_dst['val'], res[18]) # OFP_FLOW_STATS_REQUEST_ID_PORT_STR - eq_(self.table_id['val'], res[19]) - eq_(self.out_port['val'], res[20]) + self.assertEqual(self.table_id['val'], res[19]) + self.assertEqual(self.out_port['val'], res[20]) class TestOFPTableStatsRequest(unittest.TestCase): @@ -5330,8 +5304,8 @@ class TestOFPTableStatsRequest(unittest.TestCase): pass def test_init(self): - eq_(ofproto.OFPST_TABLE, self.c.type) - eq_(self.flags['val'], self.c.flags) + self.assertEqual(ofproto.OFPST_TABLE, self.c.type) + self.assertEqual(self.flags['val'], self.c.flags) def test_parser(self): # Not used. @@ -5340,9 +5314,9 @@ class TestOFPTableStatsRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5351,14 +5325,14 @@ class TestOFPTableStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(self.c.buf)) # OFP_HEADER_PACK_STR - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_STATS_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) # OFP_STATS_MSG_PACK_STR - eq_(ofproto.OFPST_TABLE, res[4]) - eq_(self.flags['val'], res[5]) + self.assertEqual(ofproto.OFPST_TABLE, res[4]) + self.assertEqual(self.flags['val'], res[5]) class TestOFPPortStatsRequest(unittest.TestCase): @@ -5386,9 +5360,9 @@ class TestOFPPortStatsRequest(unittest.TestCase): pass def test_init(self): - eq_(ofproto.OFPST_PORT, self.c.type) - eq_(self.flags['val'], self.c.flags) - eq_(self.port_no['val'], self.c.port_no) + self.assertEqual(ofproto.OFPST_PORT, self.c.type) + self.assertEqual(self.flags['val'], self.c.flags) + self.assertEqual(self.port_no['val'], self.c.port_no) def test_parser(self): # Not used. @@ -5397,9 +5371,9 @@ class TestOFPPortStatsRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5409,17 +5383,17 @@ class TestOFPPortStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(self.c.buf)) # OFP_HEADER_PACK_STR - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_STATS_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) # OFP_STATS_MSG_PACK_STR - eq_(ofproto.OFPST_PORT, res[4]) - eq_(self.flags['val'], res[5]) + self.assertEqual(ofproto.OFPST_PORT, res[4]) + self.assertEqual(self.flags['val'], res[5]) # OFP_PORT_STATS_REQUEST_PACK_STR - eq_(self.port_no['val'], res[6]) + self.assertEqual(self.port_no['val'], res[6]) class TestOFPQueueStatsRequest(unittest.TestCase): @@ -5449,10 +5423,10 @@ class TestOFPQueueStatsRequest(unittest.TestCase): pass def test_init(self): - eq_(ofproto.OFPST_QUEUE, self.c.type) - eq_(self.flags['val'], self.c.flags) - eq_(self.port_no['val'], self.c.port_no) - eq_(self.queue_id['val'], self.c.queue_id) + self.assertEqual(ofproto.OFPST_QUEUE, self.c.type) + self.assertEqual(self.flags['val'], self.c.flags) + self.assertEqual(self.port_no['val'], self.c.port_no) + self.assertEqual(self.queue_id['val'], self.c.queue_id) def test_parser(self): # Not used. @@ -5461,9 +5435,9 @@ class TestOFPQueueStatsRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5473,18 +5447,18 @@ class TestOFPQueueStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(self.c.buf)) # OFP_HEADER_PACK_STR - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_STATS_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) # OFP_STATS_MSG_PACK_STR - eq_(ofproto.OFPST_QUEUE, res[4]) - eq_(self.flags['val'], res[5]) + self.assertEqual(ofproto.OFPST_QUEUE, res[4]) + self.assertEqual(self.flags['val'], res[5]) # OFP_QUEUE_STATS_REQUEST_PACK_STR - eq_(self.port_no['val'], res[6]) - eq_(self.queue_id['val'], res[7]) + self.assertEqual(self.port_no['val'], res[6]) + self.assertEqual(self.queue_id['val'], res[7]) class TestOFPVendorStatsRequest(unittest.TestCase): @@ -5515,10 +5489,10 @@ class TestOFPVendorStatsRequest(unittest.TestCase): pass def test_init(self): - eq_(ofproto.OFPST_VENDOR, self.c.type) - eq_(self.flags['val'], self.c.flags) - eq_(self.vendor['val'], self.c.vendor) - eq_(self.specific_data, self.c.specific_data) + self.assertEqual(ofproto.OFPST_VENDOR, self.c.type) + self.assertEqual(self.flags['val'], self.c.flags) + self.assertEqual(self.vendor['val'], self.c.vendor) + self.assertEqual(self.specific_data, self.c.specific_data) def test_parser(self): # Not used. @@ -5527,9 +5501,9 @@ class TestOFPVendorStatsRequest(unittest.TestCase): def test_serialize(self): self.c.serialize() - eq_(ofproto.OFP_VERSION, self.c.version) - eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) - eq_(0, self.c.xid) + self.assertEqual(ofproto.OFP_VERSION, self.c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, self.c.msg_type) + self.assertEqual(0, self.c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5540,17 +5514,17 @@ class TestOFPVendorStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(self.c.buf)) # OFP_HEADER_PACK_STR - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_STATS_REQUEST, res[1]) - eq_(len(self.c.buf), res[2]) - eq_(0, res[3]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, res[1]) + self.assertEqual(len(self.c.buf), res[2]) + self.assertEqual(0, res[3]) # OFP_STATS_MSG_PACK_STR - eq_(ofproto.OFPST_VENDOR, res[4]) - eq_(self.flags['val'], res[5]) + self.assertEqual(ofproto.OFPST_VENDOR, res[4]) + self.assertEqual(self.flags['val'], res[5]) # OFP_VENDOR_STATS_MSG_PACK_STR - eq_(self.vendor['val'], res[6]) + self.assertEqual(self.vendor['val'], res[6]) # specific_data - eq_(self.specific_data, res[7]) + self.assertEqual(self.specific_data, res[7]) diff --git a/os_ken/tests/unit/ofproto/test_parser_v12.py b/os_ken/tests/unit/ofproto/test_parser_v12.py index 5fd2e267..4ec4b79f 100644 --- a/os_ken/tests/unit/ofproto/test_parser_v12.py +++ b/os_ken/tests/unit/ofproto/test_parser_v12.py @@ -13,14 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - import unittest import logging import six import socket from struct import * -from nose.tools import * from os_ken.ofproto.ofproto_v1_2_parser import * from os_ken.ofproto import ofproto_v1_2_parser from os_ken.ofproto import ofproto_v1_2 @@ -31,6 +28,7 @@ from os_ken import utils from os_ken.lib import addrconv from os_ken.lib import pack_utils + LOG = logging.getLogger('test_ofproto_v12') @@ -57,20 +55,20 @@ class TestRegisterParser(unittest.TestCase): res_parser = ofproto_v1_2_parser._MSG_PARSERS[msg_type] del ofproto_v1_2_parser._MSG_PARSERS[msg_type] - eq_(res.cls_msg_type, msg_type) - ok_(res.dummy) - eq_(res_parser(), 'dummy') + self.assertEqual(res.cls_msg_type, msg_type) + self.assertTrue(res.dummy) + self.assertEqual(res_parser(), 'dummy') - @raises(AssertionError) def test_cls_msg_type_none(self): cls = OFPHello(_Datapath) cls.cls_msg_type = None - ofproto_v1_2_parser._register_parser(cls) + self.assertRaises(AssertionError, + ofproto_v1_2_parser._register_parser, cls) - @raises(AssertionError) def test_cls_msg_type_already_registed(self): cls = OFPHello(_Datapath) - ofproto_v1_2_parser._register_parser(cls) + self.assertRaises(AssertionError, + ofproto_v1_2_parser._register_parser, cls) class TestMsgParser(unittest.TestCase): @@ -88,19 +86,19 @@ class TestMsgParser(unittest.TestCase): c = msg_parser(_Datapath, version, msg_type, msg_len, xid, buf) - eq_(version, c.version) - eq_(msg_type, c.msg_type) - eq_(msg_len, c.msg_len) - eq_(xid, c.xid) + self.assertEqual(version, c.version) + self.assertEqual(msg_type, c.msg_type) + self.assertEqual(msg_len, c.msg_len) + self.assertEqual(xid, c.xid) # buf fmt = ofproto.OFP_HEADER_PACK_STR res = struct.unpack(fmt, c.buf) - eq_(version, res[0]) - eq_(msg_type, res[1]) - eq_(msg_len, res[2]) - eq_(xid, res[3]) + self.assertEqual(version, res[0]) + self.assertEqual(msg_type, res[1]) + self.assertEqual(msg_len, res[2]) + self.assertEqual(xid, res[3]) def test_parser_mid(self): xid = 2147483648 @@ -133,11 +131,11 @@ class TestOFPHello(unittest.TestCase): res = OFPHello.parser(object, version, msg_type, msg_len, xid, bytearray(buf)) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(six.binary_type(buf), six.binary_type(res.buf)) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(six.binary_type(buf), six.binary_type(res.buf)) def test_parser_xid_min(self): xid = 0 @@ -154,9 +152,9 @@ class TestOFPHello(unittest.TestCase): def test_serialize(self): c = OFPHello(_Datapath) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_HELLO, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_HELLO, c.msg_type) + self.assertEqual(0, c.xid) class TestOFPErrorMsg(unittest.TestCase): @@ -175,9 +173,9 @@ class TestOFPErrorMsg(unittest.TestCase): def test_init(self): c = OFPErrorMsg(_Datapath) - eq_(c.code, None) - eq_(c.type, None) - eq_(c.data, None) + self.assertEqual(c.code, None) + self.assertEqual(c.type, None) + self.assertEqual(c.data, None) def _test_parser(self, type_, code, data=None): @@ -191,15 +189,15 @@ class TestOFPErrorMsg(unittest.TestCase): res = OFPErrorMsg.parser(object, self.version, self.msg_type, self.msg_len, self.xid, buf) - eq_(res.version, self.version) - eq_(res.msg_type, self.msg_type) - eq_(res.msg_len, self.msg_len) - eq_(res.xid, self.xid) - eq_(res.type, type_) - eq_(res.code, code) + self.assertEqual(res.version, self.version) + self.assertEqual(res.msg_type, self.msg_type) + self.assertEqual(res.msg_len, self.msg_len) + self.assertEqual(res.xid, self.xid) + self.assertEqual(res.type, type_) + self.assertEqual(res.code, code) if data is not None: - eq_(res.data, data) + self.assertEqual(res.data, data) def test_parser_mid(self): type_ = 32768 @@ -779,14 +777,14 @@ class TestOFPErrorMsg(unittest.TestCase): res = OFPErrorMsg.parser(object, self.version, self.msg_type, self.msg_len, self.xid, buf) - eq_(res.version, self.version) - eq_(res.msg_type, self.msg_type) - eq_(res.msg_len, self.msg_len) - eq_(res.xid, self.xid) - eq_(res.type, type_) - eq_(res.exp_type, exp_type) - eq_(res.experimenter, experimenter) - eq_(res.data, data) + self.assertEqual(res.version, self.version) + self.assertEqual(res.msg_type, self.msg_type) + self.assertEqual(res.msg_len, self.msg_len) + self.assertEqual(res.xid, self.xid) + self.assertEqual(res.type, type_) + self.assertEqual(res.exp_type, exp_type) + self.assertEqual(res.experimenter, experimenter) + self.assertEqual(res.data, data) def _test_serialize(self, type_, code, data): # OFP_ERROR_MSG_PACK_STR = '!HH' @@ -801,10 +799,10 @@ class TestOFPErrorMsg(unittest.TestCase): c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_ERROR, c.msg_type) - eq_(0, c.xid) - eq_(len(buf), c.msg_len) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_ERROR, c.msg_type) + self.assertEqual(0, c.xid) + self.assertEqual(len(buf), c.msg_len) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -813,13 +811,13 @@ class TestOFPErrorMsg(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_ERROR) - eq_(res[2], len(buf)) - eq_(res[3], 0) - eq_(res[4], type_) - eq_(res[5], code) - eq_(res[6], data) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_ERROR) + self.assertEqual(res[2], len(buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], type_) + self.assertEqual(res[5], code) + self.assertEqual(res[6], data) def test_serialize_mid(self): type_ = 32768 @@ -839,10 +837,9 @@ class TestOFPErrorMsg(unittest.TestCase): data = b'Error Message.' self._test_serialize(type_, code, data) - @raises(AssertionError) def test_serialize_check_data(self): c = OFPErrorMsg(_Datapath) - c.serialize() + self.assertRaises(AssertionError, c.serialize) def _test_serialize_p(self, type_, code): self._test_serialize(type_, code, b'Error Message.') @@ -1218,10 +1215,10 @@ class TestOFPErrorExperimenterMsg(unittest.TestCase): def test_init(self): c = OFPErrorExperimenterMsg(_Datapath) - eq_(c.type, 65535) - eq_(c.exp_type, None) - eq_(c.experimenter, None) - eq_(c.data, None) + self.assertEqual(c.type, 65535) + self.assertEqual(c.exp_type, None) + self.assertEqual(c.experimenter, None) + self.assertEqual(c.data, None) def _test_parser(self, exp_type, experimenter, data=None): # OFP_HEADER_PACK_STR @@ -1245,16 +1242,16 @@ class TestOFPErrorExperimenterMsg(unittest.TestCase): res = OFPErrorMsg.parser( object, version, msg_type, msg_len, xid, buf) - eq_(res.version, version) - eq_(res.msg_type, msg_type) - eq_(res.msg_len, msg_len) - eq_(res.xid, xid) - eq_(res.type, type_) - eq_(res.exp_type, exp_type) - eq_(res.experimenter, experimenter) + self.assertEqual(res.version, version) + self.assertEqual(res.msg_type, msg_type) + self.assertEqual(res.msg_len, msg_len) + self.assertEqual(res.xid, xid) + self.assertEqual(res.type, type_) + self.assertEqual(res.exp_type, exp_type) + self.assertEqual(res.experimenter, experimenter) if data is not None: - eq_(res.data, data) + self.assertEqual(res.data, data) def test_parser_mid(self): exp_type = 32768 @@ -1286,7 +1283,7 @@ class TestOFPEchoRequest(unittest.TestCase): def test_init(self): c = OFPEchoRequest(_Datapath) - eq_(c.data, None) + self.assertEqual(c.data, None) def _test_parser(self, data=None): fmt = ofproto.OFP_HEADER_PACK_STR @@ -1299,13 +1296,13 @@ class TestOFPEchoRequest(unittest.TestCase): res = OFPEchoRequest.parser(object, self.version, self.msg_type, self.msg_len, self.xid, buf) - eq_(res.version, self.version) - eq_(res.msg_type, self.msg_type) - eq_(res.msg_len, self.msg_len) - eq_(res.xid, self.xid) + self.assertEqual(res.version, self.version) + self.assertEqual(res.msg_type, self.msg_type) + self.assertEqual(res.msg_len, self.msg_len) + self.assertEqual(res.xid, self.xid) if data is not None: - eq_(res.data, data) + self.assertEqual(res.data, data) def test_parser_mid(self): data = b'Request Message.' @@ -1324,9 +1321,9 @@ class TestOFPEchoRequest(unittest.TestCase): c.data = data c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_ECHO_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_ECHO_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = ofproto.OFP_HEADER_PACK_STR @@ -1335,13 +1332,13 @@ class TestOFPEchoRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_ECHO_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_ECHO_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) if data is not None: - eq_(res[4], data) + self.assertEqual(res[4], data) def test_serialize_mid(self): data = b'Request Message.' @@ -1369,7 +1366,7 @@ class TestOFPEchoReply(unittest.TestCase): def test_init(self): c = OFPEchoReply(_Datapath) - eq_(c.data, None) + self.assertEqual(c.data, None) def _test_parser(self, data): fmt = ofproto.OFP_HEADER_PACK_STR @@ -1382,13 +1379,13 @@ class TestOFPEchoReply(unittest.TestCase): res = OFPEchoReply.parser(object, self.version, self.msg_type, self.msg_len, self.xid, buf) - eq_(res.version, self.version) - eq_(res.msg_type, self.msg_type) - eq_(res.msg_len, self.msg_len) - eq_(res.xid, self.xid) + self.assertEqual(res.version, self.version) + self.assertEqual(res.msg_type, self.msg_type) + self.assertEqual(res.msg_len, self.msg_len) + self.assertEqual(res.xid, self.xid) if data is not None: - eq_(res.data, data) + self.assertEqual(res.data, data) def test_parser_mid(self): data = b'Reply Message.' @@ -1411,9 +1408,9 @@ class TestOFPEchoReply(unittest.TestCase): c.data = data c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_ECHO_REPLY, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_ECHO_REPLY, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -1421,11 +1418,11 @@ class TestOFPEchoReply(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_ECHO_REPLY) - eq_(res[2], len(buf)) - eq_(res[3], 0) - eq_(res[4], data) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_ECHO_REPLY) + self.assertEqual(res[2], len(buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], data) def test_serialize_mid(self): data = b'Reply Message.' @@ -1435,10 +1432,9 @@ class TestOFPEchoReply(unittest.TestCase): data = b'Reply Message.'.ljust(65527) self._test_serialize(data) - @raises(AssertionError) def test_serialize_check_data(self): c = OFPEchoReply(_Datapath) - c.serialize() + self.assertRaises(AssertionError, c.serialize) class TestOFPExperimenter(unittest.TestCase): @@ -1465,12 +1461,12 @@ class TestOFPExperimenter(unittest.TestCase): res = OFPExperimenter.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(experimenter, res.experimenter) - eq_(exp_type, res.exp_type) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(experimenter, res.experimenter) + self.assertEqual(exp_type, res.exp_type) def test_parser_mid(self): xid = 2495926989 @@ -1517,17 +1513,17 @@ class TestOFPPort(unittest.TestCase): c = OFPPort(port_no, hw_addr, name, config, state, curr, advertised, supported, peer, curr_speed, max_speed) - eq_(port_no, c.port_no) - eq_(hw_addr, c.hw_addr) - eq_(name, c.name) - eq_(config, c.config) - eq_(state, c.state) - eq_(curr, c.curr) - eq_(advertised, c.advertised) - eq_(supported, c.supported) - eq_(peer, c.peer) - eq_(curr_speed, c.curr_speed) - eq_(max_speed, c.max_speed) + self.assertEqual(port_no, c.port_no) + self.assertEqual(hw_addr, c.hw_addr) + self.assertEqual(name, c.name) + self.assertEqual(config, c.config) + self.assertEqual(state, c.state) + self.assertEqual(curr, c.curr) + self.assertEqual(advertised, c.advertised) + self.assertEqual(supported, c.supported) + self.assertEqual(peer, c.peer) + self.assertEqual(curr_speed, c.curr_speed) + self.assertEqual(max_speed, c.max_speed) def _test_parser(self, port_no, hw_addr, config, state, curr, advertised, supported, peer, curr_speed, max_speed): @@ -1539,17 +1535,17 @@ class TestOFPPort(unittest.TestCase): res = OFPPort.parser(buf, 0) - eq_(port_no, res.port_no) - eq_(hw_addr, res.hw_addr) - eq_(name, res.name) - eq_(config, res.config) - eq_(state, res.state) - eq_(curr, res.curr) - eq_(advertised, res.advertised) - eq_(supported, res.supported) - eq_(peer, res.peer) - eq_(curr_speed, res.curr_speed) - eq_(max_speed, res.max_speed) + self.assertEqual(port_no, res.port_no) + self.assertEqual(hw_addr, res.hw_addr) + self.assertEqual(name, res.name) + self.assertEqual(config, res.config) + self.assertEqual(state, res.state) + self.assertEqual(curr, res.curr) + self.assertEqual(advertised, res.advertised) + self.assertEqual(supported, res.supported) + self.assertEqual(peer, res.peer) + self.assertEqual(curr_speed, res.curr_speed) + self.assertEqual(max_speed, res.max_speed) def test_parser_mid(self): port_no = 1119692796 @@ -1778,18 +1774,18 @@ class TestOFPFeaturesRequest(unittest.TestCase): c = OFPFeaturesRequest(_Datapath) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_FEATURES_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_FEATURES_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = ofproto.OFP_HEADER_PACK_STR res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_FEATURES_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_FEATURES_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) class TestOFPSwitchFeatures(unittest.TestCase): @@ -1831,19 +1827,19 @@ class TestOFPSwitchFeatures(unittest.TestCase): res = OFPSwitchFeatures.parser(object, version, msg_type, msg_len, xid, buf) - eq_(res.version, version) - eq_(res.msg_type, msg_type) - eq_(res.msg_len, msg_len) - eq_(res.xid, xid) + self.assertEqual(res.version, version) + self.assertEqual(res.msg_type, msg_type) + self.assertEqual(res.msg_len, msg_len) + self.assertEqual(res.xid, xid) - eq_(res.datapath_id, datapath_id) - eq_(res.n_buffers, n_buffers) - eq_(res.n_tables, n_tables) - eq_(res.capabilities, capabilities) - eq_(res._reserved, reserved) + self.assertEqual(res.datapath_id, datapath_id) + self.assertEqual(res.n_buffers, n_buffers) + self.assertEqual(res.n_tables, n_tables) + self.assertEqual(res.capabilities, capabilities) + self.assertEqual(res._reserved, reserved) for i in range(port_cnt): - eq_(res.ports[i].port_no, i) + self.assertEqual(res.ports[i].port_no, i) def test_parser_mid(self): xid = 2495926989 @@ -1890,17 +1886,17 @@ class TestOFPGetConfigRequest(unittest.TestCase): c = OFPGetConfigRequest(_Datapath) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_GET_CONFIG_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_GET_CONFIG_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = ofproto.OFP_HEADER_PACK_STR res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_GET_CONFIG_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_GET_CONFIG_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) class TestOFPGetConfigReply(unittest.TestCase): @@ -1925,12 +1921,12 @@ class TestOFPGetConfigReply(unittest.TestCase): res = OFPGetConfigReply.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(flags, res.flags) - eq_(miss_send_len, res.miss_send_len) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(flags, res.flags) + self.assertEqual(miss_send_len, res.miss_send_len) def test_parser_mid(self): xid = 3423224276 @@ -1987,16 +1983,16 @@ class TestOFPSetConfig(unittest.TestCase): c = OFPSetConfig(_Datapath, flags, miss_send_len) - eq_(flags, c.flags) - eq_(miss_send_len, c.miss_send_len) + self.assertEqual(flags, c.flags) + self.assertEqual(miss_send_len, c.miss_send_len) def _test_serialize(self, flags, miss_send_len): c = OFPSetConfig(_Datapath, flags, miss_send_len) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_SET_CONFIG, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_SET_CONFIG, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -2004,12 +2000,12 @@ class TestOFPSetConfig(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_SET_CONFIG) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], flags) - eq_(res[5], miss_send_len) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_SET_CONFIG) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], flags) + self.assertEqual(res[5], miss_send_len) def test_serialize_mid(self): flags = 41186 @@ -2046,19 +2042,17 @@ class TestOFPSetConfig(unittest.TestCase): miss_send_len = 13838 self._test_serialize(flags, miss_send_len) - @raises(AssertionError) def test_serialize_check_flags(self): flags = None miss_send_len = 13838 c = OFPSetConfig(_Datapath, flags, miss_send_len) - c.serialize() + self.assertRaises(AssertionError, c.serialize) - @raises(AssertionError) def test_serialize_check_miss_send_len(self): flags = 41186 miss_send_len = None c = OFPSetConfig(_Datapath, flags, miss_send_len) - c.serialize() + self.assertRaises(AssertionError, c.serialize) class TestOFPPacketIn(unittest.TestCase): @@ -2096,19 +2090,19 @@ class TestOFPPacketIn(unittest.TestCase): res = OFPPacketIn.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(buffer_id, res.buffer_id) - eq_(total_len, res.total_len) - eq_(reason, res.reason) - eq_(table_id, res.table_id) - ok_(hasattr(res, 'match')) - eq_(ofproto.OFPMT_OXM, res.match.type) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(buffer_id, res.buffer_id) + self.assertEqual(total_len, res.total_len) + self.assertEqual(reason, res.reason) + self.assertEqual(table_id, res.table_id) + self.assertTrue(hasattr(res, 'match')) + self.assertEqual(ofproto.OFPMT_OXM, res.match.type) if data: - eq_(data[:total_len], res.data) + self.assertEqual(data[:total_len], res.data) def test_data_is_total_len(self): xid = 3423224276 @@ -2202,22 +2196,22 @@ class TestOFPFlowRemoved(unittest.TestCase): res = OFPFlowRemoved.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(cookie, res.cookie) - eq_(priority, res.priority) - eq_(reason, res.reason) - eq_(table_id, res.table_id) - eq_(duration_sec, res.duration_sec) - eq_(duration_nsec, res.duration_nsec) - eq_(idle_timeout, res.idle_timeout) - eq_(hard_timeout, res.hard_timeout) - eq_(packet_count, res.packet_count) - eq_(byte_count, res.byte_count) - ok_(hasattr(res, 'match')) - eq_(ofproto.OFPMT_OXM, res.match.type) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(cookie, res.cookie) + self.assertEqual(priority, res.priority) + self.assertEqual(reason, res.reason) + self.assertEqual(table_id, res.table_id) + self.assertEqual(duration_sec, res.duration_sec) + self.assertEqual(duration_nsec, res.duration_nsec) + self.assertEqual(idle_timeout, res.idle_timeout) + self.assertEqual(hard_timeout, res.hard_timeout) + self.assertEqual(packet_count, res.packet_count) + self.assertEqual(byte_count, res.byte_count) + self.assertTrue(hasattr(res, 'match')) + self.assertEqual(ofproto.OFPMT_OXM, res.match.type) def test_parser_mid(self): xid = 3423224276 @@ -2356,18 +2350,18 @@ class TestOFPPortStatus(unittest.TestCase): res = OFPPortStatus.parser(object, version, msg_type, msg_len, xid, buf) - eq_(reason, res.reason) - eq_(port_no, res.desc.port_no) - eq_(hw_addr, res.desc.hw_addr) - eq_(name, res.desc.name) - eq_(config, res.desc.config) - eq_(state, res.desc.state) - eq_(curr, res.desc.curr) - eq_(advertised, res.desc.advertised) - eq_(supported, res.desc.supported) - eq_(peer, res.desc.peer) - eq_(curr_speed, res.desc.curr_speed) - eq_(max_speed, res.desc.max_speed) + self.assertEqual(reason, res.reason) + self.assertEqual(port_no, res.desc.port_no) + self.assertEqual(hw_addr, res.desc.hw_addr) + self.assertEqual(name, res.desc.name) + self.assertEqual(config, res.desc.config) + self.assertEqual(state, res.desc.state) + self.assertEqual(curr, res.desc.curr) + self.assertEqual(advertised, res.desc.advertised) + self.assertEqual(supported, res.desc.supported) + self.assertEqual(peer, res.desc.peer) + self.assertEqual(curr_speed, res.desc.curr_speed) + self.assertEqual(max_speed, res.desc.max_speed) def test_parser_mid(self): xid = 3423224276 @@ -2456,20 +2450,19 @@ class TestOFPPacketOut(unittest.TestCase): c = OFPPacketOut(_Datapath, buffer_id, in_port, actions, data) - eq_(buffer_id, c.buffer_id) - eq_(in_port, c.in_port) - eq_(0, c.actions_len) - eq_(data, c.data) - eq_(actions, c.actions) + self.assertEqual(buffer_id, c.buffer_id) + self.assertEqual(in_port, c.in_port) + self.assertEqual(0, c.actions_len) + self.assertEqual(data, c.data) + self.assertEqual(actions, c.actions) def test_init(self): in_port = 0x00040455 self._test_init(in_port) - @raises(AssertionError) def test_init_check_in_port(self): in_port = None - self._test_init(in_port) + self.assertRaises(AssertionError, self._test_init, in_port) def _test_serialize(self, buffer_id, in_port, action_cnt=0, data=None): actions = [] @@ -2479,9 +2472,9 @@ class TestOFPPacketOut(unittest.TestCase): c = OFPPacketOut(_Datapath, buffer_id, in_port, actions, data) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_PACKET_OUT, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_PACKET_OUT, c.msg_type) + self.assertEqual(0, c.xid) fmt = ofproto.OFP_HEADER_PACK_STR \ + ofproto.OFP_PACKET_OUT_PACK_STR[1:] \ @@ -2492,23 +2485,23 @@ class TestOFPPacketOut(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_PACKET_OUT) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], buffer_id) - eq_(res[5], in_port) - eq_(res[6], ofproto.OFP_ACTION_OUTPUT_SIZE * action_cnt) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_PACKET_OUT) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], buffer_id) + self.assertEqual(res[5], in_port) + self.assertEqual(res[6], ofproto.OFP_ACTION_OUTPUT_SIZE * action_cnt) for i in range(action_cnt): index = 7 + i * 4 - eq_(res[index], ofproto.OFPAT_OUTPUT) - eq_(res[index + 1], ofproto.OFP_ACTION_OUTPUT_SIZE) - eq_(res[index + 2], i) - eq_(res[index + 3], 0) + self.assertEqual(res[index], ofproto.OFPAT_OUTPUT) + self.assertEqual(res[index + 1], ofproto.OFP_ACTION_OUTPUT_SIZE) + self.assertEqual(res[index + 2], i) + self.assertEqual(res[index + 3], 0) if data: - eq_(res[-1], data) + self.assertEqual(res[-1], data) def test_serialize_true(self): buffer_id = 0xffffffff @@ -2539,13 +2532,13 @@ class TestOFPPacketOut(unittest.TestCase): in_port = ofproto.OFPP_CONTROLLER self._test_serialize(buffer_id, in_port) - @raises(AssertionError) def test_serialize_check_buffer_id(self): buffer_id = 2147483648 in_port = 1 action_cnt = 0 data = b'DATA' - self._test_serialize(buffer_id, in_port, action_cnt, data) + self.assertRaises(AssertionError, self._test_serialize, buffer_id, + in_port, action_cnt, data) class TestOFPFlowMod(unittest.TestCase): @@ -2578,19 +2571,19 @@ class TestOFPFlowMod(unittest.TestCase): idle_timeout, hard_timeout, priority, buffer_id, out_port, out_group, flags, match, instructions) - eq_(cookie, c.cookie) - eq_(cookie_mask, c.cookie_mask) - eq_(table_id, c.table_id) - eq_(command, c.command) - eq_(idle_timeout, c.idle_timeout) - eq_(hard_timeout, c.hard_timeout) - eq_(priority, c.priority) - eq_(buffer_id, c.buffer_id) - eq_(out_port, c.out_port) - eq_(out_group, c.out_group) - eq_(flags, c.flags) - eq_(in_port, c.match._flow.in_port) - eq_(instructions[0], c.instructions[0]) + self.assertEqual(cookie, c.cookie) + self.assertEqual(cookie_mask, c.cookie_mask) + self.assertEqual(table_id, c.table_id) + self.assertEqual(command, c.command) + self.assertEqual(idle_timeout, c.idle_timeout) + self.assertEqual(hard_timeout, c.hard_timeout) + self.assertEqual(priority, c.priority) + self.assertEqual(buffer_id, c.buffer_id) + self.assertEqual(out_port, c.out_port) + self.assertEqual(out_group, c.out_group) + self.assertEqual(flags, c.flags) + self.assertEqual(in_port, c.match._flow.in_port) + self.assertEqual(instructions[0], c.instructions[0]) def _test_serialize(self, cookie, cookie_mask, table_id, command, idle_timeout, hard_timeout, @@ -2609,9 +2602,9 @@ class TestOFPFlowMod(unittest.TestCase): out_port, out_group, flags, match, insts) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_FLOW_MOD, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_FLOW_MOD, c.msg_type) + self.assertEqual(0, c.xid) fmt = ofproto.OFP_HEADER_PACK_STR \ + ofproto.OFP_FLOW_MOD_PACK_STR0[1:] \ @@ -2621,37 +2614,37 @@ class TestOFPFlowMod(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_FLOW_MOD) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], cookie) - eq_(res[5], cookie_mask) - eq_(res[6], table_id) - eq_(res[7], command) - eq_(res[8], idle_timeout) - eq_(res[9], hard_timeout) - eq_(res[10], priority) - eq_(res[11], buffer_id) - eq_(res[12], out_port) - eq_(res[13], out_group) - eq_(res[14], flags) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_FLOW_MOD) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], cookie) + self.assertEqual(res[5], cookie_mask) + self.assertEqual(res[6], table_id) + self.assertEqual(res[7], command) + self.assertEqual(res[8], idle_timeout) + self.assertEqual(res[9], hard_timeout) + self.assertEqual(res[10], priority) + self.assertEqual(res[11], buffer_id) + self.assertEqual(res[12], out_port) + self.assertEqual(res[13], out_group) + self.assertEqual(res[14], flags) # OFP_MATCH (type, length, class, [field, hashmask], n_byte, ip_proto) - eq_(res[15], ofproto.OFPMT_OXM) - eq_(res[16], 10) # OFP_MATCH_STR + MTEthType.pack_str - eq_(res[17], ofproto.OFPXMC_OPENFLOW_BASIC) - eq_(res[18] >> 1, ofproto.OFPXMT_OFB_ETH_TYPE) - eq_(res[18] & 0b0001, 0) - eq_(res[19], calcsize(MTEthType.pack_str)) - eq_(res[20], dl_type) + self.assertEqual(res[15], ofproto.OFPMT_OXM) + self.assertEqual(res[16], 10) # OFP_MATCH_STR + MTEthType.pack_str + self.assertEqual(res[17], ofproto.OFPXMC_OPENFLOW_BASIC) + self.assertEqual(res[18] >> 1, ofproto.OFPXMT_OFB_ETH_TYPE) + self.assertEqual(res[18] & 0b0001, 0) + self.assertEqual(res[19], calcsize(MTEthType.pack_str)) + self.assertEqual(res[20], dl_type) # insts (type, length, table_id) for i in range(inst_cnt): index = 21 + 3 * i - eq_(res[index], ofproto.OFPIT_GOTO_TABLE) - eq_(res[index + 1], ofproto.OFP_INSTRUCTION_GOTO_TABLE_SIZE) - eq_(res[index + 2], i) + self.assertEqual(res[index], ofproto.OFPIT_GOTO_TABLE) + self.assertEqual(res[index + 1], ofproto.OFP_INSTRUCTION_GOTO_TABLE_SIZE) + self.assertEqual(res[index + 2], i) def test_serialize_mid(self): cookie = 2127614848199081640 @@ -2790,17 +2783,17 @@ class TestOFPInstructionGotoTable(unittest.TestCase): table_id = 3 c = OFPInstructionGotoTable(table_id) - eq_(self.type_, c.type) - eq_(self.len_, c.len) - eq_(table_id, c.table_id) + self.assertEqual(self.type_, c.type) + self.assertEqual(self.len_, c.len) + self.assertEqual(table_id, c.table_id) def _test_parser(self, table_id): buf = pack(self.fmt, self.type_, self.len_, table_id) res = OFPInstructionGotoTable.parser(buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) - eq_(res.table_id, table_id) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.table_id, table_id) def test_parser_mid(self): self._test_parser(3) @@ -2818,9 +2811,9 @@ class TestOFPInstructionGotoTable(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], table_id) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], table_id) def test_serialize_mid(self): self._test_serialize(3) @@ -2849,20 +2842,20 @@ class TestOFPInstructionWriteMetadata(unittest.TestCase): c = OFPInstructionWriteMetadata(self.metadata, self.metadata_mask) - eq_(self.type_, c.type) - eq_(self.len_, c.len) - eq_(self.metadata, c.metadata) - eq_(self.metadata_mask, c.metadata_mask) + self.assertEqual(self.type_, c.type) + self.assertEqual(self.len_, c.len) + self.assertEqual(self.metadata, c.metadata) + self.assertEqual(self.metadata_mask, c.metadata_mask) def _test_parser(self, metadata, metadata_mask): buf = pack(self.fmt, self.type_, self.len_, metadata, metadata_mask) res = OFPInstructionWriteMetadata.parser(buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) - eq_(res.metadata, metadata) - eq_(res.metadata_mask, metadata_mask) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.metadata, metadata) + self.assertEqual(res.metadata_mask, metadata_mask) def test_parser_metadata_mid(self): self._test_parser(self.metadata, self.metadata_mask) @@ -2891,10 +2884,10 @@ class TestOFPInstructionWriteMetadata(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], metadata) - eq_(res[3], metadata_mask) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], metadata) + self.assertEqual(res[3], metadata_mask) def test_serialize_metadata_mid(self): self._test_serialize(self.metadata, self.metadata_mask) @@ -2940,8 +2933,8 @@ class TestOFPInstructionActions(unittest.TestCase): def test_init(self): c = OFPInstructionActions(self.type_, self.actions) - eq_(self.type_, c.type) - eq_(self.actions, c.actions) + self.assertEqual(self.type_, c.type) + self.assertEqual(self.actions, c.actions) def _test_parser(self, action_cnt): # OFP_INSTRUCTION_ACTIONS_PACK_STR @@ -2965,16 +2958,16 @@ class TestOFPInstructionActions(unittest.TestCase): res = OFPInstructionActions.parser(buf, 0) # 8 - eq_(res.len, len_) - eq_(res.type, self.type_) + self.assertEqual(res.len, len_) + self.assertEqual(res.type, self.type_) # 8 + 16 * action_cnt < 65535 byte # action_cnt <= 4095 for a in range(action_cnt): - eq_(res.actions[a].type, actions[a].type) - eq_(res.actions[a].len, actions[a].len) - eq_(res.actions[a].port, actions[a].port) - eq_(res.actions[a].max_len, actions[a].max_len) + self.assertEqual(res.actions[a].type, actions[a].type) + self.assertEqual(res.actions[a].len, actions[a].len) + self.assertEqual(res.actions[a].port, actions[a].port) + self.assertEqual(res.actions[a].max_len, actions[a].max_len) def test_parser_mid(self): self._test_parser(2047) @@ -3010,15 +3003,15 @@ class TestOFPInstructionActions(unittest.TestCase): fmt += ofproto.OFP_ACTION_OUTPUT_PACK_STR.replace('!', '') res = struct.unpack(fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], len_) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], len_) for a in range(action_cnt): d = 2 + a * 4 - eq_(res[d], actions[a].type) - eq_(res[d + 1], actions[a].len) - eq_(res[d + 2], actions[a].port) - eq_(res[d + 3], actions[a].max_len) + self.assertEqual(res[d], actions[a].type) + self.assertEqual(res[d + 1], actions[a].len) + self.assertEqual(res[d + 2], actions[a].port) + self.assertEqual(res[d + 3], actions[a].max_len) def test_serialize_mid(self): self._test_serialize(2047) @@ -3045,8 +3038,8 @@ class TestOFPActionHeader(unittest.TestCase): c = OFPActionHeader(type_, len_) - eq_(type_, c.type) - eq_(len_, c.len) + self.assertEqual(type_, c.type) + self.assertEqual(len_, c.len) def _test_serialize(self, type_, len_): # OFP_ACTION_HEADER_PACK_STR @@ -3063,8 +3056,8 @@ class TestOFPActionHeader(unittest.TestCase): fmt = ofproto.OFP_ACTION_HEADER_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(res[0], type_) - eq_(res[1], len_) + self.assertEqual(res[0], type_) + self.assertEqual(res[1], len_) def test_serialize_mid(self): type_ = 11 @@ -3096,8 +3089,8 @@ class TestOFPActionOutput(unittest.TestCase): max_len = 1500 fmt = ofproto.OFP_ACTION_OUTPUT_PACK_STR c = OFPActionOutput(port, max_len) - eq_(port, c.port) - eq_(max_len, c.max_len) + self.assertEqual(port, c.port) + self.assertEqual(max_len, c.max_len) def _test_parser(self, port, max_len): fmt = ofproto.OFP_ACTION_OUTPUT_PACK_STR @@ -3107,10 +3100,10 @@ class TestOFPActionOutput(unittest.TestCase): res = c.parser(buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) - eq_(res.port, port) - eq_(res.max_len, max_len) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.port, port) + self.assertEqual(res.max_len, max_len) def test_parser_mid(self): port = 6606 @@ -3140,10 +3133,10 @@ class TestOFPActionOutput(unittest.TestCase): fmt = ofproto.OFP_ACTION_OUTPUT_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], port) - eq_(res[3], max_len) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], port) + self.assertEqual(res[3], max_len) def test_serialize_mid(self): port = 6606 @@ -3180,15 +3173,15 @@ class TestOFPActionGroup(unittest.TestCase): def test_init(self): c = OFPActionGroup(self.group_id) - eq_(self.group_id, c.group_id) + self.assertEqual(self.group_id, c.group_id) def _test_parser(self, group_id): buf = pack(self.fmt, self.type_, self.len_, group_id) res = OFPActionGroup.parser(buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) - eq_(res.group_id, group_id) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.group_id, group_id) def test_parser_mid(self): self._test_parser(self.group_id) @@ -3206,9 +3199,9 @@ class TestOFPActionGroup(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], group_id) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], group_id) def test_serialize_mid(self): self._test_serialize(self.group_id) @@ -3234,15 +3227,15 @@ class TestOFPActionSetQueue(unittest.TestCase): def test_init(self): c = OFPActionSetQueue(self.queue_id) - eq_(self.queue_id, c.queue_id) + self.assertEqual(self.queue_id, c.queue_id) def _test_parser(self, queue_id): buf = pack(self.fmt, self.type_, self.len_, queue_id) res = OFPActionSetQueue.parser(buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) - eq_(res.queue_id, queue_id) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.queue_id, queue_id) def test_parser_mid(self): self._test_parser(self.queue_id) @@ -3260,9 +3253,9 @@ class TestOFPActionSetQueue(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], queue_id) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], queue_id) def test_serialize_mid(self): self._test_serialize(self.queue_id) @@ -3288,15 +3281,15 @@ class TestOFPActionSetMplsTtl(unittest.TestCase): def test_init(self): c = OFPActionSetMplsTtl(self.mpls_ttl) - eq_(self.mpls_ttl, c.mpls_ttl) + self.assertEqual(self.mpls_ttl, c.mpls_ttl) def _test_parser(self, mpls_ttl): buf = pack(self.fmt, self.type_, self.len_, mpls_ttl) res = OFPActionSetMplsTtl.parser(buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) - eq_(res.mpls_ttl, mpls_ttl) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.mpls_ttl, mpls_ttl) def test_parser_mid(self): self._test_parser(self.mpls_ttl) @@ -3314,9 +3307,9 @@ class TestOFPActionSetMplsTtl(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], mpls_ttl) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], mpls_ttl) def test_serialize_mid(self): self._test_serialize(self.mpls_ttl) @@ -3341,16 +3334,16 @@ class TestOFPActionDecMplsTtl(unittest.TestCase): def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) def test_serialize(self): buf = bytearray() self.c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) class TestOFPActionSetNwTtl(unittest.TestCase): @@ -3367,15 +3360,15 @@ class TestOFPActionSetNwTtl(unittest.TestCase): def test_init(self): c = OFPActionSetNwTtl(self.nw_ttl) - eq_(self.nw_ttl, c.nw_ttl) + self.assertEqual(self.nw_ttl, c.nw_ttl) def _test_parser(self, nw_ttl): buf = pack(self.fmt, self.type_, self.len_, nw_ttl) res = OFPActionSetNwTtl.parser(buf, 0) - eq_(res.type, self.type_) - eq_(res.len, self.len_) - eq_(res.nw_ttl, nw_ttl) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.nw_ttl, nw_ttl) def test_parser_mid(self): self._test_parser(self.nw_ttl) @@ -3393,9 +3386,9 @@ class TestOFPActionSetNwTtl(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], nw_ttl) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], nw_ttl) def test_serialize_mid(self): self._test_serialize(self.nw_ttl) @@ -3420,16 +3413,16 @@ class TestOFPActionDecNwTtl(unittest.TestCase): def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) def test_serialize(self): buf = bytearray() self.c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) class TestOFPActionCopyTtlOut(unittest.TestCase): @@ -3444,16 +3437,16 @@ class TestOFPActionCopyTtlOut(unittest.TestCase): def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) def test_serialize(self): buf = bytearray() self.c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) class TestOFPActionCopyTtlIn(unittest.TestCase): @@ -3471,16 +3464,16 @@ class TestOFPActionCopyTtlIn(unittest.TestCase): def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(res.len, self.len_) - eq_(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.type, self.type_) def test_serialize(self): buf = bytearray() self.c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) class TestOFPActionPushVlan(unittest.TestCase): @@ -3496,15 +3489,15 @@ class TestOFPActionPushVlan(unittest.TestCase): def test_init(self): ethertype = 0x8100 c = OFPActionPushVlan(ethertype) - eq_(ethertype, c.ethertype) + self.assertEqual(ethertype, c.ethertype) def _test_parser(self, ethertype): buf = pack(self.fmt, self.type_, self.len_, ethertype) res = OFPActionPushVlan.parser(buf, 0) - eq_(res.type, self.type_) - eq_(res.len, self.len_) - eq_(res.ethertype, ethertype) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.ethertype, ethertype) def test_parser_mid(self): self._test_parser(0x8100) @@ -3521,9 +3514,9 @@ class TestOFPActionPushVlan(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], ethertype) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], ethertype) def test_serialize_mid(self): self._test_serialize(0x8100) @@ -3548,15 +3541,15 @@ class TestOFPActionPushMpls(unittest.TestCase): def test_init(self): ethertype = 0x8100 c = OFPActionPushMpls(ethertype) - eq_(ethertype, c.ethertype) + self.assertEqual(ethertype, c.ethertype) def _test_parser(self, ethertype): buf = pack(self.fmt, self.type_, self.len_, ethertype) res = OFPActionPushMpls.parser(buf, 0) - eq_(res.type, self.type_) - eq_(res.len, self.len_) - eq_(res.ethertype, ethertype) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.ethertype, ethertype) def test_parser_mid(self): self._test_parser(0x8100) @@ -3573,9 +3566,9 @@ class TestOFPActionPushMpls(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], ethertype) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], ethertype) def test_serialize_mid(self): self._test_serialize(0x8100) @@ -3601,16 +3594,16 @@ class TestOFPActionPopVlan(unittest.TestCase): def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.type_, res.type) - eq_(self.len_, res.len) + self.assertEqual(self.type_, res.type) + self.assertEqual(self.len_, res.len) def test_serialize(self): buf = bytearray() self.c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) class TestOFPActionPopMpls(unittest.TestCase): @@ -3626,15 +3619,15 @@ class TestOFPActionPopMpls(unittest.TestCase): def test_init(self): ethertype = 0x8100 c = OFPActionPopMpls(ethertype) - eq_(ethertype, c.ethertype) + self.assertEqual(ethertype, c.ethertype) def _test_parser(self, ethertype): buf = pack(self.fmt, self.type_, self.len_, ethertype) res = OFPActionPopMpls.parser(buf, 0) - eq_(res.type, self.type_) - eq_(res.len, self.len_) - eq_(res.ethertype, ethertype) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.ethertype, ethertype) def test_parser_mid(self): self._test_parser(0x8100) @@ -3651,9 +3644,9 @@ class TestOFPActionPopMpls(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], ethertype) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], ethertype) def test_serialize_mid(self): self._test_serialize(0x8100) @@ -3683,15 +3676,15 @@ class TestOFPActionSetField(unittest.TestCase): c = OFPActionSetField(field) def test_init(self): - eq_(self.field, self.c.field) + self.assertEqual(self.field, self.c.field) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(res.type, self.type_) - eq_(res.len, self.len_) - eq_(res.field.header, self.header) - eq_(res.field.value, self.in_port) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.field.header, self.header) + self.assertEqual(res.field.value, self.in_port) def test_serialize(self): buf = bytearray() @@ -3699,10 +3692,10 @@ class TestOFPActionSetField(unittest.TestCase): res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], self.header) - eq_(res[3], self.in_port) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], self.header) + self.assertEqual(res[3], self.in_port) class TestOFPActionExperimenter(unittest.TestCase): @@ -3718,15 +3711,15 @@ class TestOFPActionExperimenter(unittest.TestCase): def test_init(self): experimenter = 4294967295 c = OFPActionExperimenter(experimenter) - eq_(experimenter, c.experimenter) + self.assertEqual(experimenter, c.experimenter) def _test_parser(self, experimenter): buf = pack(self.fmt, self.type_, self.len_, experimenter) res = OFPActionExperimenter.parser(buf, 0) - eq_(res.type, self.type_) - eq_(res.len, self.len_) - eq_(res.experimenter, experimenter) + self.assertEqual(res.type, self.type_) + self.assertEqual(res.len, self.len_) + self.assertEqual(res.experimenter, experimenter) def test_parser_mid(self): experimenter = 2147483648 @@ -3747,9 +3740,9 @@ class TestOFPActionExperimenter(unittest.TestCase): c.serialize(buf, 0) res = struct.unpack(self.fmt, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.len_) - eq_(res[2], experimenter) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.len_) + self.assertEqual(res[2], experimenter) def test_serialize_mid(self): experimenter = 2147483648 @@ -3781,12 +3774,12 @@ class TestOFPBucket(unittest.TestCase): actions = [OFPActionOutput(port, max_len)] c = OFPBucket(weight, watch_port, watch_group, actions) - eq_(weight, c.weight) - eq_(watch_port, c.watch_port) - eq_(watch_group, c.watch_group) - eq_(1, len(c.actions)) - eq_(port, c.actions[0].port) - eq_(max_len, c.actions[0].max_len) + self.assertEqual(weight, c.weight) + self.assertEqual(watch_port, c.watch_port) + self.assertEqual(watch_group, c.watch_group) + self.assertEqual(1, len(c.actions)) + self.assertEqual(port, c.actions[0].port) + self.assertEqual(max_len, c.actions[0].max_len) def _test_parser(self, weight, watch_port, watch_group, action_cnt): # OFP_BUCKET_PACK_STR @@ -3811,17 +3804,17 @@ class TestOFPBucket(unittest.TestCase): res = OFPBucket.parser(buf, 0) # 16 - eq_(weight, res.weight) - eq_(watch_port, res.watch_port) - eq_(watch_group, res.watch_group) + self.assertEqual(weight, res.weight) + self.assertEqual(watch_port, res.watch_port) + self.assertEqual(watch_group, res.watch_group) # 16 + 16 * action_cnt < 65535 byte # action_cnt <= 4094 for a in range(action_cnt): - eq_(actions[a].type, res.actions[a].type) - eq_(actions[a].len, res.actions[a].len) - eq_(actions[a].port, res.actions[a].port) - eq_(actions[a].max_len, res.actions[a].max_len) + self.assertEqual(actions[a].type, res.actions[a].type) + self.assertEqual(actions[a].len, res.actions[a].len) + self.assertEqual(actions[a].port, res.actions[a].port) + self.assertEqual(actions[a].max_len, res.actions[a].max_len) def test_parser_mid(self): weight = 4386 @@ -3872,17 +3865,17 @@ class TestOFPBucket(unittest.TestCase): fmt += ofproto.OFP_ACTION_OUTPUT_PACK_STR[1:] res = struct.unpack(fmt, six.binary_type(buf)) - eq_(res[0], len_) - eq_(res[1], weight) - eq_(res[2], watch_port) - eq_(res[3], watch_group) + self.assertEqual(res[0], len_) + self.assertEqual(res[1], weight) + self.assertEqual(res[2], watch_port) + self.assertEqual(res[3], watch_group) for a in range(action_cnt): d = 4 + a * 4 - eq_(res[d], actions[a].type) - eq_(res[d + 1], actions[a].len) - eq_(res[d + 2], actions[a].port) - eq_(res[d + 3], actions[a].max_len) + self.assertEqual(res[d], actions[a].type) + self.assertEqual(res[d + 1], actions[a].len) + self.assertEqual(res[d + 2], actions[a].port) + self.assertEqual(res[d + 3], actions[a].max_len) def test_serialize_mid(self): weight = 4386 @@ -3933,13 +3926,13 @@ class TestOFPGroupMod(unittest.TestCase): buckets = [OFPBucket(weight, watch_port, watch_group, actions)] c = OFPGroupMod(_Datapath, command, type_, group_id, buckets) - eq_(command, c.command) - eq_(type_, c.type) - eq_(group_id, c.group_id) - eq_(1, len(c.buckets)) - eq_(1, len(c.buckets[0].actions)) - eq_(port, c.buckets[0].actions[0].port) - eq_(max_len, c.buckets[0].actions[0].max_len) + self.assertEqual(command, c.command) + self.assertEqual(type_, c.type) + self.assertEqual(group_id, c.group_id) + self.assertEqual(1, len(c.buckets)) + self.assertEqual(1, len(c.buckets[0].actions)) + self.assertEqual(port, c.buckets[0].actions[0].port) + self.assertEqual(max_len, c.buckets[0].actions[0].max_len) def _test_serialize(self, command, type_, group_id, bucket_cnt): len_ = ofproto.OFP_BUCKET_SIZE \ @@ -3957,10 +3950,10 @@ class TestOFPGroupMod(unittest.TestCase): c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_GROUP_MOD, c.msg_type) - eq_(0, c.xid) - eq_(len(c.buf), c.msg_len) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_GROUP_MOD, c.msg_type) + self.assertEqual(0, c.xid) + self.assertEqual(len(c.buf), c.msg_len) # 16 byte fmt = ofproto.OFP_HEADER_PACK_STR \ @@ -3977,23 +3970,23 @@ class TestOFPGroupMod(unittest.TestCase): msg_len = ofproto.OFP_GROUP_MOD_SIZE \ + (len_ * bucket_cnt) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_GROUP_MOD) - eq_(res[2], msg_len) - eq_(res[3], 0) - eq_(res[4], command) - eq_(res[5], type_) - eq_(res[6], group_id) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_GROUP_MOD) + self.assertEqual(res[2], msg_len) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], command) + self.assertEqual(res[5], type_) + self.assertEqual(res[6], group_id) for d in range(bucket_cnt): e = 7 + d * 8 - eq_(res[e + 1], buckets[d].weight) - eq_(res[e + 2], buckets[d].watch_port) - eq_(res[e + 3], buckets[d].watch_group) - eq_(res[e + 4], buckets[d].actions[0].type) - eq_(res[e + 5], buckets[d].actions[0].len) - eq_(res[e + 6], buckets[d].actions[0].port) - eq_(res[e + 7], buckets[d].actions[0].max_len) + self.assertEqual(res[e + 1], buckets[d].weight) + self.assertEqual(res[e + 2], buckets[d].watch_port) + self.assertEqual(res[e + 3], buckets[d].watch_group) + self.assertEqual(res[e + 4], buckets[d].actions[0].type) + self.assertEqual(res[e + 5], buckets[d].actions[0].len) + self.assertEqual(res[e + 6], buckets[d].actions[0].port) + self.assertEqual(res[e + 7], buckets[d].actions[0].max_len) def test_serialize_mid(self): command = 32768 @@ -4054,20 +4047,20 @@ class TestOFPPortMod(unittest.TestCase): def test_init(self): c = OFPPortMod(_Datapath, self.port_no, self.hw_addr, self.config, self.mask, self.advertise) - eq_(self.port_no, c.port_no) - eq_(self.hw_addr, c.hw_addr) - eq_(self.config, c.config) - eq_(self.mask, c.mask) - eq_(self.advertise, c.advertise) + self.assertEqual(self.port_no, c.port_no) + self.assertEqual(self.hw_addr, c.hw_addr) + self.assertEqual(self.config, c.config) + self.assertEqual(self.mask, c.mask) + self.assertEqual(self.advertise, c.advertise) def _test_serialize(self, port_no, hw_addr, config, mask, advertise): c = OFPPortMod(_Datapath, port_no, hw_addr, config, mask, advertise) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_PORT_MOD, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_PORT_MOD, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -4075,15 +4068,15 @@ class TestOFPPortMod(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_PORT_MOD) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], port_no) - eq_(res[5], addrconv.mac.text_to_bin(hw_addr)) - eq_(res[6], config) - eq_(res[7], mask) - eq_(res[8], advertise) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_PORT_MOD) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], port_no) + self.assertEqual(res[5], addrconv.mac.text_to_bin(hw_addr)) + self.assertEqual(res[6], config) + self.assertEqual(res[7], mask) + self.assertEqual(res[8], advertise) def test_serialize_mid(self): self._test_serialize(self.port_no, self.hw_addr, @@ -4245,16 +4238,16 @@ class TestOFPTableMod(unittest.TestCase): def test_init(self): c = OFPTableMod(_Datapath, self.table_id, self.config) - eq_(self.table_id, c.table_id) - eq_(self.config, c.config) + self.assertEqual(self.table_id, c.table_id) + self.assertEqual(self.config, c.config) def _test_serialize(self, table_id, config): c = OFPTableMod(_Datapath, table_id, config) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_TABLE_MOD, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_TABLE_MOD, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -4262,12 +4255,12 @@ class TestOFPTableMod(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_TABLE_MOD) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], table_id) - eq_(res[5], config) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_TABLE_MOD) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], table_id) + self.assertEqual(res[5], config) def test_serialize_mid(self): self._test_serialize(self.table_id, self.config) @@ -4306,8 +4299,8 @@ class TestOFPStatsRequest(unittest.TestCase): c = OFPStatsRequest(_Datapath, type_) def test_init(self): - eq_(self.type_, self.c.type) - eq_(0, self.c.flags) + self.assertEqual(self.type_, self.c.type) + self.assertEqual(0, self.c.flags) def test_serialize_body(self): len_ = ofproto.OFP_HEADER_SIZE \ @@ -4319,8 +4312,8 @@ class TestOFPStatsRequest(unittest.TestCase): res = struct.unpack_from(fmt, six.binary_type(self.c.buf), ofproto.OFP_HEADER_SIZE) - eq_(res[0], self.type_) - eq_(res[1], 0) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], 0) class TestOFPStatsReply(unittest.TestCase): @@ -4360,15 +4353,15 @@ class TestOFPStatsReply(unittest.TestCase): res = self.c.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(type_, res.type) - eq_(flags, res.flags) - eq_(packet_count, res.body.packet_count) - eq_(byte_count, res.body.byte_count) - eq_(flow_count, res.body.flow_count) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(type_, res.type) + self.assertEqual(flags, res.flags) + self.assertEqual(packet_count, res.body.packet_count) + self.assertEqual(byte_count, res.body.byte_count) + self.assertEqual(flow_count, res.body.flow_count) def test_parser_single_struct_flase(self): # OFP_HEADER_PACK_STR @@ -4404,17 +4397,17 @@ class TestOFPStatsReply(unittest.TestCase): res = self.c.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(type_, res.type) - eq_(flags, res.flags) - eq_(port_no, res.body[0].port_no) - eq_(queue_id, res.body[0].queue_id) - eq_(tx_bytes, res.body[0].tx_bytes) - eq_(tx_packets, res.body[0].tx_packets) - eq_(tx_errors, res.body[0].tx_errors) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(type_, res.type) + self.assertEqual(flags, res.flags) + self.assertEqual(port_no, res.body[0].port_no) + self.assertEqual(queue_id, res.body[0].queue_id) + self.assertEqual(tx_bytes, res.body[0].tx_bytes) + self.assertEqual(tx_packets, res.body[0].tx_packets) + self.assertEqual(tx_errors, res.body[0].tx_errors) def test_parser_max(self): # OFP_HEADER_PACK_STR @@ -4436,12 +4429,12 @@ class TestOFPStatsReply(unittest.TestCase): buf += pack(fmt, type_, flags) res = self.c.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(type_, res.type) - eq_(flags, res.flags) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(type_, res.type) + self.assertEqual(flags, res.flags) def test_parser_min(self): # OFP_HEADER_PACK_STR @@ -4463,12 +4456,12 @@ class TestOFPStatsReply(unittest.TestCase): buf += pack(fmt, type_, flags) res = self.c.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(type_, res.type) - eq_(flags, res.flags) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(type_, res.type) + self.assertEqual(flags, res.flags) class TestOFPDescStatsRequest(unittest.TestCase): @@ -4485,12 +4478,12 @@ class TestOFPDescStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_STATS_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], ofproto.OFPST_DESC) - eq_(res[5], 0) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_STATS_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], ofproto.OFPST_DESC) + self.assertEqual(res[5], 0) class TestOFPDescStats(unittest.TestCase): @@ -4514,20 +4507,20 @@ class TestOFPDescStats(unittest.TestCase): c = OFPDescStats(mfr_desc, hw_desc, sw_desc, serial_num, dp_desc) def test_init(self): - eq_(self.mfr_desc, self.c.mfr_desc) - eq_(self.hw_desc, self.c.hw_desc) - eq_(self.sw_desc, self.c.sw_desc) - eq_(self.serial_num, self.c.serial_num) - eq_(self.dp_desc, self.c.dp_desc) + self.assertEqual(self.mfr_desc, self.c.mfr_desc) + self.assertEqual(self.hw_desc, self.c.hw_desc) + self.assertEqual(self.sw_desc, self.c.sw_desc) + self.assertEqual(self.serial_num, self.c.serial_num) + self.assertEqual(self.dp_desc, self.c.dp_desc) def test_parser(self): res = self.c.parser(self.buf, 0) - eq_(self.mfr_desc, res.mfr_desc) - eq_(self.hw_desc, res.hw_desc) - eq_(self.sw_desc, res.sw_desc) - eq_(self.serial_num, res.serial_num) - eq_(self.dp_desc, res.dp_desc) + self.assertEqual(self.mfr_desc, res.mfr_desc) + self.assertEqual(self.hw_desc, res.hw_desc) + self.assertEqual(self.sw_desc, res.sw_desc) + self.assertEqual(self.serial_num, res.serial_num) + self.assertEqual(self.dp_desc, res.dp_desc) class TestOFPFlowStatsRequest(unittest.TestCase): @@ -4552,12 +4545,12 @@ class TestOFPFlowStatsRequest(unittest.TestCase): self.out_group, self.cookie, self.cookie_mask, match) - eq_(self.table_id, c.table_id) - eq_(self.out_port, c.out_port) - eq_(self.out_group, c.out_group) - eq_(self.cookie, c.cookie) - eq_(self.cookie_mask, c.cookie_mask) - eq_(in_port, c.match._flow.in_port) + self.assertEqual(self.table_id, c.table_id) + self.assertEqual(self.out_port, c.out_port) + self.assertEqual(self.out_group, c.out_group) + self.assertEqual(self.cookie, c.cookie) + self.assertEqual(self.cookie_mask, c.cookie_mask) + self.assertEqual(in_port, c.match._flow.in_port) def _test_serialize(self, table_id, out_port, out_group, cookie, cookie_mask): @@ -4569,9 +4562,9 @@ class TestOFPFlowStatsRequest(unittest.TestCase): out_group, cookie, cookie_mask, match) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_STATS_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = ofproto.OFP_HEADER_PACK_STR \ + ofproto.OFP_STATS_REQUEST_PACK_STR[1:] \ @@ -4581,28 +4574,28 @@ class TestOFPFlowStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_STATS_REQUEST) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_STATS_REQUEST) size = ofproto.OFP_STATS_REPLY_SIZE \ + ofproto.OFP_FLOW_STATS_REQUEST_SIZE \ + calcsize(MTEthType.pack_str + '6x') - eq_(res[2], size) - eq_(res[3], 0) - eq_(res[4], ofproto.OFPST_FLOW) - eq_(res[5], 0) - eq_(res[6], table_id) - eq_(res[7], out_port) - eq_(res[8], out_group) - eq_(res[9], cookie) - eq_(res[10], cookie_mask) + self.assertEqual(res[2], size) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], ofproto.OFPST_FLOW) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], table_id) + self.assertEqual(res[7], out_port) + self.assertEqual(res[8], out_group) + self.assertEqual(res[9], cookie) + self.assertEqual(res[10], cookie_mask) # match - eq_(res[11], ofproto.OFPMT_OXM) - eq_(res[12], 10) - eq_(res[13], ofproto.OFPXMC_OPENFLOW_BASIC) - eq_(res[14] >> 1, ofproto.OFPXMT_OFB_ETH_TYPE) - eq_(res[14] & 0b0001, 0) - eq_(res[15], calcsize(MTEthType.pack_str)) - eq_(res[16], dl_type) + self.assertEqual(res[11], ofproto.OFPMT_OXM) + self.assertEqual(res[12], 10) + self.assertEqual(res[13], ofproto.OFPXMC_OPENFLOW_BASIC) + self.assertEqual(res[14] >> 1, ofproto.OFPXMT_OFB_ETH_TYPE) + self.assertEqual(res[14] & 0b0001, 0) + self.assertEqual(res[15], calcsize(MTEthType.pack_str)) + self.assertEqual(res[16], dl_type) def test_serialize_mid(self): self._test_serialize(self.table_id, self.out_port, self.out_group, @@ -4658,17 +4651,17 @@ class TestOFPFlowStats(unittest.TestCase): priority, idle_timeout, hard_timeout, cookie, packet_count, byte_count, match, instructions) - eq_(table_id, c.table_id) - eq_(duration_sec, c.duration_sec) - eq_(duration_nsec, c.duration_nsec) - eq_(priority, c.priority) - eq_(idle_timeout, c.idle_timeout) - eq_(hard_timeout, c.hard_timeout) - eq_(cookie, c.cookie) - eq_(packet_count, c.packet_count) - eq_(byte_count, c.byte_count) - eq_(in_port, c.match._flow.in_port) - eq_(goto_table, c.instructions[0].table_id) + self.assertEqual(table_id, c.table_id) + self.assertEqual(duration_sec, c.duration_sec) + self.assertEqual(duration_nsec, c.duration_nsec) + self.assertEqual(priority, c.priority) + self.assertEqual(idle_timeout, c.idle_timeout) + self.assertEqual(hard_timeout, c.hard_timeout) + self.assertEqual(cookie, c.cookie) + self.assertEqual(packet_count, c.packet_count) + self.assertEqual(byte_count, c.byte_count) + self.assertEqual(in_port, c.match._flow.in_port) + self.assertEqual(goto_table, c.instructions[0].table_id) def _test_parser(self, table_id, duration_sec, duration_nsec, priority, idle_timeout, hard_timeout, cookie, @@ -4703,19 +4696,19 @@ class TestOFPFlowStats(unittest.TestCase): # parse res = OFPFlowStats.parser(buf, 0) - eq_(length, res.length) - eq_(table_id, res.table_id) - eq_(duration_sec, res.duration_sec) - eq_(duration_nsec, res.duration_nsec) - eq_(priority, res.priority) - eq_(idle_timeout, res.idle_timeout) - eq_(hard_timeout, res.hard_timeout) - eq_(cookie, res.cookie) - eq_(packet_count, res.packet_count) - eq_(byte_count, res.byte_count) - eq_(dl_type, res.match.fields[0].value) + self.assertEqual(length, res.length) + self.assertEqual(table_id, res.table_id) + self.assertEqual(duration_sec, res.duration_sec) + self.assertEqual(duration_nsec, res.duration_nsec) + self.assertEqual(priority, res.priority) + self.assertEqual(idle_timeout, res.idle_timeout) + self.assertEqual(hard_timeout, res.hard_timeout) + self.assertEqual(cookie, res.cookie) + self.assertEqual(packet_count, res.packet_count) + self.assertEqual(byte_count, res.byte_count) + self.assertEqual(dl_type, res.match.fields[0].value) for i in range(inst_cnt): - eq_(1, res.instructions[i].table_id) + self.assertEqual(1, res.instructions[i].table_id) def test_parser_mid(self): table_id = 81 @@ -4775,12 +4768,12 @@ class TestOFPAggregateStatsRequest(unittest.TestCase): self.cookie, self.cookie_mask, match) - eq_(self.table_id, c.table_id) - eq_(self.out_port, c.out_port) - eq_(self.out_group, c.out_group) - eq_(self.cookie, c.cookie) - eq_(self.cookie_mask, c.cookie_mask) - eq_(dl_type, c.match._flow.dl_type) + self.assertEqual(self.table_id, c.table_id) + self.assertEqual(self.out_port, c.out_port) + self.assertEqual(self.out_group, c.out_group) + self.assertEqual(self.cookie, c.cookie) + self.assertEqual(self.cookie_mask, c.cookie_mask) + self.assertEqual(dl_type, c.match._flow.dl_type) def _test_serialize(self, table_id, out_port, out_group, cookie, cookie_mask): @@ -4792,9 +4785,9 @@ class TestOFPAggregateStatsRequest(unittest.TestCase): cookie_mask, match) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_STATS_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = ofproto.OFP_HEADER_PACK_STR \ + ofproto.OFP_STATS_REQUEST_PACK_STR[1:] \ @@ -4803,25 +4796,25 @@ class TestOFPAggregateStatsRequest(unittest.TestCase): + MTEthType.pack_str[1:] + '6x' res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_STATS_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], ofproto.OFPST_AGGREGATE) - eq_(res[5], 0) - eq_(res[6], table_id) - eq_(res[7], out_port) - eq_(res[8], out_group) - eq_(res[9], cookie) - eq_(res[10], cookie_mask) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_STATS_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], ofproto.OFPST_AGGREGATE) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], table_id) + self.assertEqual(res[7], out_port) + self.assertEqual(res[8], out_group) + self.assertEqual(res[9], cookie) + self.assertEqual(res[10], cookie_mask) # match - eq_(res[11], ofproto.OFPMT_OXM) - eq_(res[12], 10) - eq_(res[13], ofproto.OFPXMC_OPENFLOW_BASIC) - eq_(res[14] >> 1, ofproto.OFPXMT_OFB_ETH_TYPE) - eq_(res[14] & 0b0001, 0) - eq_(res[15], calcsize(MTEthType.pack_str)) - eq_(res[16], dl_type) + self.assertEqual(res[11], ofproto.OFPMT_OXM) + self.assertEqual(res[12], 10) + self.assertEqual(res[13], ofproto.OFPXMC_OPENFLOW_BASIC) + self.assertEqual(res[14] >> 1, ofproto.OFPXMT_OFB_ETH_TYPE) + self.assertEqual(res[14] & 0b0001, 0) + self.assertEqual(res[15], calcsize(MTEthType.pack_str)) + self.assertEqual(res[16], dl_type) def test_serialize_mid(self): self._test_serialize(self.table_id, self.out_port, self.out_group, @@ -4865,18 +4858,18 @@ class TestOFPAggregateStatsReply(unittest.TestCase): c = OFPAggregateStatsReply(self.packet_count, self.byte_count, self.flow_count) - eq_(c.packet_count, self.packet_count) - eq_(c.byte_count, self.byte_count) - eq_(c.flow_count, self.flow_count) + self.assertEqual(c.packet_count, self.packet_count) + self.assertEqual(c.byte_count, self.byte_count) + self.assertEqual(c.flow_count, self.flow_count) def _test_parser(self, packet_count, byte_count, flow_count): fmt = ofproto.OFP_AGGREGATE_STATS_REPLY_PACK_STR buf = pack(fmt, packet_count, byte_count, flow_count) res = OFPAggregateStatsReply.parser(buf, 0) - eq_(packet_count, res.packet_count) - eq_(byte_count, res.byte_count) - eq_(flow_count, res.flow_count) + self.assertEqual(packet_count, res.packet_count) + self.assertEqual(byte_count, res.byte_count) + self.assertEqual(flow_count, res.flow_count) def test_parser_mid(self): self._test_parser(self.packet_count, self.byte_count, @@ -4911,12 +4904,12 @@ class TestOFPTableStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_STATS_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], ofproto.OFPST_TABLE) - eq_(res[5], 0) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_STATS_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], ofproto.OFPST_TABLE) + self.assertEqual(res[5], 0) class TestOFPTableStats(unittest.TestCase): @@ -4947,22 +4940,22 @@ class TestOFPTableStats(unittest.TestCase): config, max_entries, active_count, lookup_count, matched_count) - eq_(table_id, res.table_id) - eq_(name, res.name) - eq_(match, res.match) - eq_(wildcards, res.wildcards) - eq_(write_actions, res.write_actions) - eq_(apply_actions, res.apply_actions) - eq_(write_setfields, res.write_setfields) - eq_(apply_setfields, res.apply_setfields) - eq_(metadata_match, res.metadata_match) - eq_(metadata_write, res.metadata_write) - eq_(instructions, res.instructions) - eq_(config, res.config) - eq_(max_entries, res.max_entries) - eq_(active_count, res.active_count) - eq_(lookup_count, res.lookup_count) - eq_(matched_count, res.matched_count) + self.assertEqual(table_id, res.table_id) + self.assertEqual(name, res.name) + self.assertEqual(match, res.match) + self.assertEqual(wildcards, res.wildcards) + self.assertEqual(write_actions, res.write_actions) + self.assertEqual(apply_actions, res.apply_actions) + self.assertEqual(write_setfields, res.write_setfields) + self.assertEqual(apply_setfields, res.apply_setfields) + self.assertEqual(metadata_match, res.metadata_match) + self.assertEqual(metadata_write, res.metadata_write) + self.assertEqual(instructions, res.instructions) + self.assertEqual(config, res.config) + self.assertEqual(max_entries, res.max_entries) + self.assertEqual(active_count, res.active_count) + self.assertEqual(lookup_count, res.lookup_count) + self.assertEqual(matched_count, res.matched_count) def _test_parser(self, table_id, name, match, wildcards, write_actions, apply_actions, write_setfields, apply_setfields, @@ -4983,22 +4976,22 @@ class TestOFPTableStats(unittest.TestCase): res = OFPTableStats.parser(buf, 0) - eq_(table_id, res.table_id) - eq_(name, res.name.replace(b'\x00', b'')) - eq_(match, res.match) - eq_(wildcards, res.wildcards) - eq_(write_actions, res.write_actions) - eq_(apply_actions, res.apply_actions) - eq_(write_setfields, res.write_setfields) - eq_(apply_setfields, res.apply_setfields) - eq_(metadata_match, res.metadata_match) - eq_(metadata_write, res.metadata_write) - eq_(instructions, res.instructions) - eq_(config, res.config) - eq_(max_entries, res.max_entries) - eq_(active_count, res.active_count) - eq_(lookup_count, res.lookup_count) - eq_(matched_count, res.matched_count) + self.assertEqual(table_id, res.table_id) + self.assertEqual(name, res.name.replace(b'\x00', b'')) + self.assertEqual(match, res.match) + self.assertEqual(wildcards, res.wildcards) + self.assertEqual(write_actions, res.write_actions) + self.assertEqual(apply_actions, res.apply_actions) + self.assertEqual(write_setfields, res.write_setfields) + self.assertEqual(apply_setfields, res.apply_setfields) + self.assertEqual(metadata_match, res.metadata_match) + self.assertEqual(metadata_write, res.metadata_write) + self.assertEqual(instructions, res.instructions) + self.assertEqual(config, res.config) + self.assertEqual(max_entries, res.max_entries) + self.assertEqual(active_count, res.active_count) + self.assertEqual(lookup_count, res.lookup_count) + self.assertEqual(matched_count, res.matched_count) def test_parser_mid(self): table_id = 91 @@ -5288,15 +5281,15 @@ class TestOFPPortStatsRequest(unittest.TestCase): def test_init(self): c = OFPPortStatsRequest(_Datapath, self.port_no) - eq_(self.port_no, c.port_no) + self.assertEqual(self.port_no, c.port_no) def _test_serialize(self, port_no): c = OFPPortStatsRequest(_Datapath, port_no) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_STATS_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5304,13 +5297,13 @@ class TestOFPPortStatsRequest(unittest.TestCase): + ofproto.OFP_PORT_STATS_REQUEST_PACK_STR.replace('!', '') res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_STATS_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], ofproto.OFPST_PORT) - eq_(res[5], 0) - eq_(res[6], port_no) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_STATS_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], ofproto.OFPST_PORT) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], port_no) def test_serialize_mid(self): self._test_serialize(self.port_no) @@ -5370,19 +5363,19 @@ class TestOFPPortStats(unittest.TestCase): rx_errors, tx_errors, rx_frame_err, rx_over_err, rx_crc_err, collisions) - eq_(port_no, res.port_no) - eq_(rx_packets, res.rx_packets) - eq_(tx_packets, res.tx_packets) - eq_(rx_bytes, res.rx_bytes) - eq_(tx_bytes, res.tx_bytes) - eq_(rx_dropped, res.rx_dropped) - eq_(tx_dropped, res.tx_dropped) - eq_(rx_errors, res.rx_errors) - eq_(tx_errors, res.tx_errors) - eq_(rx_frame_err, res.rx_frame_err) - eq_(rx_over_err, res.rx_over_err) - eq_(rx_crc_err, res.rx_crc_err) - eq_(collisions, res.collisions) + self.assertEqual(port_no, res.port_no) + self.assertEqual(rx_packets, res.rx_packets) + self.assertEqual(tx_packets, res.tx_packets) + self.assertEqual(rx_bytes, res.rx_bytes) + self.assertEqual(tx_bytes, res.tx_bytes) + self.assertEqual(rx_dropped, res.rx_dropped) + self.assertEqual(tx_dropped, res.tx_dropped) + self.assertEqual(rx_errors, res.rx_errors) + self.assertEqual(tx_errors, res.tx_errors) + self.assertEqual(rx_frame_err, res.rx_frame_err) + self.assertEqual(rx_over_err, res.rx_over_err) + self.assertEqual(rx_crc_err, res.rx_crc_err) + self.assertEqual(collisions, res.collisions) def _test_parser(self, port_no, rx_packets, tx_packets, rx_bytes, tx_bytes, rx_dropped, tx_dropped, @@ -5397,19 +5390,19 @@ class TestOFPPortStats(unittest.TestCase): res = OFPPortStats.parser(buf, 0) - eq_(port_no, res.port_no) - eq_(rx_packets, res.rx_packets) - eq_(tx_packets, res.tx_packets) - eq_(rx_bytes, res.rx_bytes) - eq_(tx_bytes, res.tx_bytes) - eq_(rx_dropped, res.rx_dropped) - eq_(tx_dropped, res.tx_dropped) - eq_(rx_errors, res.rx_errors) - eq_(tx_errors, res.tx_errors) - eq_(rx_frame_err, res.rx_frame_err) - eq_(rx_over_err, res.rx_over_err) - eq_(rx_crc_err, res.rx_crc_err) - eq_(collisions, res.collisions) + self.assertEqual(port_no, res.port_no) + self.assertEqual(rx_packets, res.rx_packets) + self.assertEqual(tx_packets, res.tx_packets) + self.assertEqual(rx_bytes, res.rx_bytes) + self.assertEqual(tx_bytes, res.tx_bytes) + self.assertEqual(rx_dropped, res.rx_dropped) + self.assertEqual(tx_dropped, res.tx_dropped) + self.assertEqual(rx_errors, res.rx_errors) + self.assertEqual(tx_errors, res.tx_errors) + self.assertEqual(rx_frame_err, res.rx_frame_err) + self.assertEqual(rx_over_err, res.rx_over_err) + self.assertEqual(rx_crc_err, res.rx_crc_err) + self.assertEqual(collisions, res.collisions) def test_parser_mid(self): port_no = 6606 @@ -5524,16 +5517,16 @@ class TestOFPQueueStatsRequest(unittest.TestCase): def test_init(self): c = OFPQueueStatsRequest(_Datapath, self.port_no, self.queue_id) - eq_(self.port_no, c.port_no) - eq_(self.queue_id, c.queue_id) + self.assertEqual(self.port_no, c.port_no) + self.assertEqual(self.queue_id, c.queue_id) def _test_serialize(self, port_no, queue_id): c = OFPQueueStatsRequest(_Datapath, port_no, queue_id) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_STATS_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5541,14 +5534,14 @@ class TestOFPQueueStatsRequest(unittest.TestCase): + ofproto.OFP_QUEUE_STATS_REQUEST_PACK_STR.replace('!', '') res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_STATS_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], ofproto.OFPST_QUEUE) - eq_(res[5], 0) - eq_(res[6], port_no) - eq_(res[7], queue_id) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_STATS_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], ofproto.OFPST_QUEUE) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], port_no) + self.assertEqual(res[7], queue_id) def test_serialize_mid(self): self._test_serialize(self.port_no, self.queue_id) @@ -5598,11 +5591,11 @@ class TestOFPQueueStats(unittest.TestCase): res = OFPQueueStats(port_no, queue_id, tx_bytes, tx_packets, tx_errors) - eq_(port_no, res.port_no) - eq_(queue_id, res.queue_id) - eq_(tx_bytes, res.tx_bytes) - eq_(tx_packets, res.tx_packets) - eq_(tx_errors, res.tx_errors) + self.assertEqual(port_no, res.port_no) + self.assertEqual(queue_id, res.queue_id) + self.assertEqual(tx_bytes, res.tx_bytes) + self.assertEqual(tx_packets, res.tx_packets) + self.assertEqual(tx_errors, res.tx_errors) def _test_parser(self, port_no, queue_id, tx_bytes, tx_packets, tx_errors): @@ -5612,11 +5605,11 @@ class TestOFPQueueStats(unittest.TestCase): buf = pack(fmt, port_no, queue_id, tx_bytes, tx_packets, tx_errors) res = OFPQueueStats.parser(buf, 0) - eq_(port_no, res.port_no) - eq_(queue_id, res.queue_id) - eq_(tx_bytes, res.tx_bytes) - eq_(tx_packets, res.tx_packets) - eq_(tx_errors, res.tx_errors) + self.assertEqual(port_no, res.port_no) + self.assertEqual(queue_id, res.queue_id) + self.assertEqual(tx_bytes, res.tx_bytes) + self.assertEqual(tx_packets, res.tx_packets) + self.assertEqual(tx_errors, res.tx_errors) def test_parser_mid(self): port_no = 41186 @@ -5693,16 +5686,16 @@ class TestOFPBucketCounter(unittest.TestCase): def test_init(self): c = OFPBucketCounter(self.packet_count, self.byte_count) - eq_(self.packet_count, c.packet_count) - eq_(self.byte_count, c.byte_count) + self.assertEqual(self.packet_count, c.packet_count) + self.assertEqual(self.byte_count, c.byte_count) def _test_parser(self, packet_count, byte_count): fmt = ofproto.OFP_BUCKET_COUNTER_PACK_STR buf = pack(fmt, packet_count, byte_count) res = OFPBucketCounter.parser(buf, 0) - eq_(packet_count, res.packet_count) - eq_(byte_count, res.byte_count) + self.assertEqual(packet_count, res.packet_count) + self.assertEqual(byte_count, res.byte_count) def test_parser_mid(self): self._test_parser(self.packet_count, self.byte_count) @@ -5728,15 +5721,15 @@ class TestOFPGroupStatsRequest(unittest.TestCase): def test_init(self): c = OFPGroupStatsRequest(_Datapath, self.group_id) - eq_(self.group_id, c.group_id) + self.assertEqual(self.group_id, c.group_id) def _test_serialize(self, group_id): c = OFPGroupStatsRequest(_Datapath, group_id) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_STATS_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_STATS_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -5744,13 +5737,13 @@ class TestOFPGroupStatsRequest(unittest.TestCase): + ofproto.OFP_GROUP_STATS_REQUEST_PACK_STR.replace('!', '') res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_STATS_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], ofproto.OFPST_GROUP) - eq_(res[5], 0) - eq_(res[6], group_id) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_STATS_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], ofproto.OFPST_GROUP) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], group_id) def test_serialize_mid(self): self._test_serialize(self.group_id) @@ -5796,11 +5789,11 @@ class TestOFPGroupStats(unittest.TestCase): self.packet_count, self.byte_count, self.bucket_counters) - eq_(self.group_id, c.group_id) - eq_(self.ref_count, c.ref_count) - eq_(self.packet_count, c.packet_count) - eq_(self.byte_count, c.byte_count) - eq_(self.bucket_counters, c.bucket_counters) + self.assertEqual(self.group_id, c.group_id) + self.assertEqual(self.ref_count, c.ref_count) + self.assertEqual(self.packet_count, c.packet_count) + self.assertEqual(self.byte_count, c.byte_count) + self.assertEqual(self.bucket_counters, c.bucket_counters) def _test_parser(self, group_id, ref_count, packet_count, byte_count, bucket_counter_cnt): @@ -5827,18 +5820,18 @@ class TestOFPGroupStats(unittest.TestCase): res = OFPGroupStats.parser(buf, 0) # 32 - eq_(length, res.length) - eq_(group_id, res.group_id) - eq_(ref_count, res.ref_count) - eq_(packet_count, res.packet_count) - eq_(byte_count, res.byte_count) + self.assertEqual(length, res.length) + self.assertEqual(group_id, res.group_id) + self.assertEqual(ref_count, res.ref_count) + self.assertEqual(packet_count, res.packet_count) + self.assertEqual(byte_count, res.byte_count) # 32 + 16 * bucket_counter_cnt < 65535 byte # bucket_counter_cnt <= 4093 for b in range(bucket_counter_cnt): - eq_(bucket_counters[b].packet_count, + self.assertEqual(bucket_counters[b].packet_count, res.bucket_counters[b].packet_count) - eq_(bucket_counters[b].byte_count, + self.assertEqual(bucket_counters[b].byte_count, res.bucket_counters[b].byte_count) def test_parser_mid(self): @@ -5882,12 +5875,12 @@ class TestOFPGroupDescStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_STATS_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], ofproto.OFPST_GROUP_DESC) - eq_(res[5], 0) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_STATS_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], ofproto.OFPST_GROUP_DESC) + self.assertEqual(res[5], 0) class TestOFPGroupDescStats(unittest.TestCase): @@ -5919,9 +5912,9 @@ class TestOFPGroupDescStats(unittest.TestCase): def test_init(self): c = OFPGroupDescStats(self.type_, self.group_id, self.buckets) - eq_(self.type_, c.type) - eq_(self.group_id, c.group_id) - eq_(self.buckets, c.buckets) + self.assertEqual(self.type_, c.type) + self.assertEqual(self.group_id, c.group_id) + self.assertEqual(self.buckets, c.buckets) def _test_parser(self, type_, group_id, bucket_cnt): # OFP_GROUP_DESC_STATS_PACK_STR = '!HBxI' @@ -5947,18 +5940,18 @@ class TestOFPGroupDescStats(unittest.TestCase): res = OFPGroupDescStats.parser(buf, 0) # 8 byte - eq_(type_, res.type) - eq_(group_id, res.group_id) + self.assertEqual(type_, res.type) + self.assertEqual(group_id, res.group_id) # 8 + ( 16 + 16 ) * b < 65535 byte # b <= 2047 byte for b in range(bucket_cnt): - eq_(buckets[b].weight, res.buckets[b].weight) - eq_(buckets[b].watch_port, res.buckets[b].watch_port) - eq_(buckets[b].watch_group, res.buckets[b].watch_group) - eq_(buckets[b].actions[0].port, + self.assertEqual(buckets[b].weight, res.buckets[b].weight) + self.assertEqual(buckets[b].watch_port, res.buckets[b].watch_port) + self.assertEqual(buckets[b].watch_group, res.buckets[b].watch_group) + self.assertEqual(buckets[b].actions[0].port, res.buckets[b].actions[0].port) - eq_(buckets[b].actions[0].max_len, + self.assertEqual(buckets[b].actions[0].max_len, res.buckets[b].actions[0].max_len) def test_parser_mid(self): @@ -6003,12 +5996,12 @@ class TestOFPGroupFeaturesStatsRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_STATS_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], ofproto.OFPST_GROUP_FEATURES) - eq_(res[5], 0) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_STATS_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], ofproto.OFPST_GROUP_FEATURES) + self.assertEqual(res[5], 0) class TestOFPGroupFeaturesStats(unittest.TestCase): @@ -6027,10 +6020,10 @@ class TestOFPGroupFeaturesStats(unittest.TestCase): def test_init(self): c = OFPGroupFeaturesStats(self.types, self.capabilities, self.max_groups, self.actions) - eq_(self.types, c.types) - eq_(self.capabilities, c.capabilities) - eq_(self.max_groups, c.max_groups) - eq_(self.actions, c.actions) + self.assertEqual(self.types, c.types) + self.assertEqual(self.capabilities, c.capabilities) + self.assertEqual(self.max_groups, c.max_groups) + self.assertEqual(self.actions, c.actions) def _test_parser(self, types, capabilities, max_groups, actions): @@ -6048,10 +6041,10 @@ class TestOFPGroupFeaturesStats(unittest.TestCase): res = OFPGroupFeaturesStats.parser(buf, 0) # max_groups and actions after the parser is tuple - eq_(types, res.types) - eq_(capabilities, res.capabilities) - eq_(max_groups, res.max_groups) - eq_(actions, res.actions) + self.assertEqual(types, res.types) + self.assertEqual(capabilities, res.capabilities) + self.assertEqual(max_groups, res.max_groups) + self.assertEqual(actions, res.actions) def test_parser_mid(self): self._test_parser(self.types, self.capabilities, @@ -6125,25 +6118,25 @@ class TestOFPQueueGetConfigRequest(unittest.TestCase): def test_init(self): c = OFPQueueGetConfigRequest(_Datapath, self.port) - eq_(self.port, c.port) + self.assertEqual(self.port, c.port) def _test_serialize(self, port): c = OFPQueueGetConfigRequest(_Datapath, port) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = ofproto.OFP_HEADER_PACK_STR \ + ofproto.OFP_QUEUE_GET_CONFIG_REQUEST_PACK_STR[1:] res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(res[0], ofproto.OFP_VERSION) - eq_(res[1], ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST) - eq_(res[2], len(c.buf)) - eq_(res[3], 0) - eq_(res[4], port) + self.assertEqual(res[0], ofproto.OFP_VERSION) + self.assertEqual(res[1], ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST) + self.assertEqual(res[2], len(c.buf)) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], port) def test_serialize_mid(self): self._test_serialize(self.port) @@ -6168,8 +6161,8 @@ class TestOFPQueuePropHeader(unittest.TestCase): def test_init(self): c = OFPQueuePropHeader(self.property_, self.len_) - eq_(self.property_, c.property) - eq_(self.len_, c.len) + self.assertEqual(self.property_, c.property) + self.assertEqual(self.len_, c.len) def _test_serialize(self, property_, len_): c = OFPQueuePropHeader(property_, len_) @@ -6179,8 +6172,8 @@ class TestOFPQueuePropHeader(unittest.TestCase): fmt = ofproto.OFP_QUEUE_PROP_HEADER_PACK_STR res = struct.unpack(fmt, six.binary_type(buf)) - eq_(res[0], property_) - eq_(res[1], len_) + self.assertEqual(res[0], property_) + self.assertEqual(res[1], len_) def test_serialize_mid(self): self._test_serialize(self.property_, self.len_) @@ -6203,9 +6196,9 @@ class TestOFPPacketQueue(unittest.TestCase): properties = [4, 5, 6] c = OFPPacketQueue(queue_id, port, properties) - eq_(queue_id, c.queue_id) - eq_(port, c.port) - eq_(properties, c.properties) + self.assertEqual(queue_id, c.queue_id) + self.assertEqual(port, c.port) + self.assertEqual(properties, c.properties) def _test_parser(self, queue_id, port, prop_cnt): # OFP_PACKET_QUEUE_PACK_STR = '!IIH6x' @@ -6229,15 +6222,15 @@ class TestOFPPacketQueue(unittest.TestCase): res = OFPPacketQueue.parser(buf, 0) - eq_(queue_id, res.queue_id) - eq_(port, res.port) - eq_(queue_len, res.len) - eq_(prop_cnt, len(res.properties)) + self.assertEqual(queue_id, res.queue_id) + self.assertEqual(port, res.port) + self.assertEqual(queue_len, res.len) + self.assertEqual(prop_cnt, len(res.properties)) for rate, p in enumerate(res.properties): - eq_(prop_type, p.property) - eq_(prop_len, p.len) - eq_(rate, p.rate) + self.assertEqual(prop_type, p.property) + self.assertEqual(prop_len, p.len) + self.assertEqual(rate, p.rate) def test_parser_mid(self): queue_id = 1 @@ -6271,7 +6264,7 @@ class TestOFPQueuePropMinRate(unittest.TestCase): # OFP_QUEUE_PROP_MIN_RATE_PACK_STR...H6x buf = pack(ofproto.OFP_QUEUE_PROP_MIN_RATE_PACK_STR, rate) res = OFPQueuePropMinRate.parser(buf, 0) - eq_(rate, res.rate) + self.assertEqual(rate, res.rate) def test_parser_mid(self): self._test_parser(32768) @@ -6295,7 +6288,7 @@ class TestOFPQueuePropMaxRate(unittest.TestCase): # OFP_QUEUE_PROP_MAX_RATE_PACK_STR...H6x buf = pack(ofproto.OFP_QUEUE_PROP_MAX_RATE_PACK_STR, rate) res = OFPQueuePropMaxRate.parser(buf, 0) - eq_(rate, res.rate) + self.assertEqual(rate, res.rate) def test_parser_mid(self): self._test_parser(100) @@ -6359,24 +6352,24 @@ class TestOFPQueueGetConfigReply(unittest.TestCase): res = OFPQueueGetConfigReply.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) - eq_(port, res.port) - eq_(queue_cnt, len(res.queues)) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) + self.assertEqual(port, res.port) + self.assertEqual(queue_cnt, len(res.queues)) for i, val in enumerate(res.queues): c = queues[i] - eq_(c['queue_id'], val.queue_id) - eq_(c['queue_port'], val.port) - eq_(c['queue_len'], val.len) - eq_(1, len(val.properties)) + self.assertEqual(c['queue_id'], val.queue_id) + self.assertEqual(c['queue_port'], val.port) + self.assertEqual(c['queue_len'], val.len) + self.assertEqual(1, len(val.properties)) prop = val.properties[0] - eq_(c['prop_type'], prop.property) - eq_(c['prop_len'], prop.len) - eq_(c['prop_rate'], prop.rate) + self.assertEqual(c['prop_type'], prop.property) + self.assertEqual(c['prop_len'], prop.len) + self.assertEqual(c['prop_rate'], prop.rate) def test_parser_mid(self): self._test_parser(2495926989, 65037, 2) @@ -6397,17 +6390,17 @@ class TestOFPBarrierRequest(unittest.TestCase): c = OFPBarrierRequest(_Datapath) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_BARRIER_REQUEST, c.msg_type) - eq_(ofproto.OFP_HEADER_SIZE, c.msg_len) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_BARRIER_REQUEST, c.msg_type) + self.assertEqual(ofproto.OFP_HEADER_SIZE, c.msg_len) + self.assertEqual(0, c.xid) fmt = ofproto.OFP_HEADER_PACK_STR res = unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_BARRIER_REQUEST, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_BARRIER_REQUEST, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, c.xid) class TestOFPBarrierReply(unittest.TestCase): @@ -6424,10 +6417,10 @@ class TestOFPBarrierReply(unittest.TestCase): res = OFPBarrierReply.parser(object, version, msg_type, msg_len, xid, buf) - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) def test_parser_mid(self): self._test_parser(2147483648) @@ -6450,16 +6443,16 @@ class TestOFPRoleRequest(unittest.TestCase): def test_init(self): c = OFPRoleRequest(_Datapath, self.role, self.generation_id) - eq_(self.role, c.role) - eq_(self.generation_id, c.generation_id) + self.assertEqual(self.role, c.role) + self.assertEqual(self.generation_id, c.generation_id) def _test_serialize(self, role, generation_id): c = OFPRoleRequest(_Datapath, role, generation_id) c.serialize() - eq_(ofproto.OFP_VERSION, c.version) - eq_(ofproto.OFPT_ROLE_REQUEST, c.msg_type) - eq_(0, c.xid) + self.assertEqual(ofproto.OFP_VERSION, c.version) + self.assertEqual(ofproto.OFPT_ROLE_REQUEST, c.msg_type) + self.assertEqual(0, c.xid) fmt = '!' \ + ofproto.OFP_HEADER_PACK_STR.replace('!', '') \ @@ -6467,12 +6460,12 @@ class TestOFPRoleRequest(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(c.buf)) - eq_(ofproto.OFP_VERSION, res[0]) - eq_(ofproto.OFPT_ROLE_REQUEST, res[1]) - eq_(len(c.buf), res[2]) - eq_(0, res[3]) - eq_(role, res[4]) - eq_(generation_id, res[5]) + self.assertEqual(ofproto.OFP_VERSION, res[0]) + self.assertEqual(ofproto.OFPT_ROLE_REQUEST, res[1]) + self.assertEqual(len(c.buf), res[2]) + self.assertEqual(0, res[3]) + self.assertEqual(role, res[4]) + self.assertEqual(generation_id, res[5]) def test_serialize_mid(self): self._test_serialize(self.role, self.generation_id) @@ -6526,14 +6519,14 @@ class TestOFPRoleReply(unittest.TestCase): res = OFPRoleReply.parser(object, version, msg_type, msg_len, xid, buf) # OFP_HEADER_PACK_STR - eq_(version, res.version) - eq_(msg_type, res.msg_type) - eq_(msg_len, res.msg_len) - eq_(xid, res.xid) + self.assertEqual(version, res.version) + self.assertEqual(msg_type, res.msg_type) + self.assertEqual(msg_len, res.msg_len) + self.assertEqual(xid, res.xid) # OFP_ROLE_REQUEST_PACK_STR - eq_(role, res.role) - eq_(generation_id, res.generation_id) + self.assertEqual(role, res.role) + self.assertEqual(generation_id, res.generation_id) def test_parser_mid(self): self._test_parser(self.role, self.generation_id) @@ -6569,61 +6562,61 @@ class TestOFPMatch(unittest.TestCase): res = OFPMatch() # wc check - eq_(res._wc.metadata_mask, 0) - eq_(res._wc.dl_dst_mask, 0) - eq_(res._wc.dl_src_mask, 0) - eq_(res._wc.vlan_vid_mask, 0) - eq_(res._wc.ipv4_src_mask, 0) - eq_(res._wc.ipv4_dst_mask, 0) - eq_(res._wc.arp_spa_mask, 0) - eq_(res._wc.arp_tpa_mask, 0) - eq_(res._wc.arp_sha_mask, 0) - eq_(res._wc.arp_tha_mask, 0) - eq_(res._wc.ipv6_src_mask, []) - eq_(res._wc.ipv6_dst_mask, []) - eq_(res._wc.ipv6_flabel_mask, 0) - eq_(res._wc.wildcards, (1 << 64) - 1) + self.assertEqual(res._wc.metadata_mask, 0) + self.assertEqual(res._wc.dl_dst_mask, 0) + self.assertEqual(res._wc.dl_src_mask, 0) + self.assertEqual(res._wc.vlan_vid_mask, 0) + self.assertEqual(res._wc.ipv4_src_mask, 0) + self.assertEqual(res._wc.ipv4_dst_mask, 0) + self.assertEqual(res._wc.arp_spa_mask, 0) + self.assertEqual(res._wc.arp_tpa_mask, 0) + self.assertEqual(res._wc.arp_sha_mask, 0) + self.assertEqual(res._wc.arp_tha_mask, 0) + self.assertEqual(res._wc.ipv6_src_mask, []) + self.assertEqual(res._wc.ipv6_dst_mask, []) + self.assertEqual(res._wc.ipv6_flabel_mask, 0) + self.assertEqual(res._wc.wildcards, (1 << 64) - 1) # flow check - eq_(res._flow.in_port, 0) - eq_(res._flow.in_phy_port, 0) - eq_(res._flow.metadata, 0) - eq_(res._flow.dl_dst, mac.DONTCARE) - eq_(res._flow.dl_src, mac.DONTCARE) - eq_(res._flow.dl_type, 0) - eq_(res._flow.vlan_vid, 0) - eq_(res._flow.vlan_pcp, 0) - eq_(res._flow.ip_dscp, 0) - eq_(res._flow.ip_ecn, 0) - eq_(res._flow.ip_proto, 0) - eq_(res._flow.ipv4_src, 0) - eq_(res._flow.ipv4_dst, 0) - eq_(res._flow.tcp_src, 0) - eq_(res._flow.tcp_dst, 0) - eq_(res._flow.udp_src, 0) - eq_(res._flow.udp_dst, 0) - eq_(res._flow.sctp_src, 0) - eq_(res._flow.sctp_dst, 0) - eq_(res._flow.icmpv4_type, 0) - eq_(res._flow.icmpv4_code, 0) - eq_(res._flow.arp_op, 0) - eq_(res._flow.arp_spa, 0) - eq_(res._flow.arp_tpa, 0) - eq_(res._flow.arp_sha, 0) - eq_(res._flow.arp_tha, 0) - eq_(res._flow.ipv6_src, []) - eq_(res._flow.ipv6_dst, []) - eq_(res._flow.ipv6_flabel, 0) - eq_(res._flow.icmpv6_type, 0) - eq_(res._flow.icmpv6_code, 0) - eq_(res._flow.ipv6_nd_target, []) - eq_(res._flow.ipv6_nd_sll, 0) - eq_(res._flow.ipv6_nd_tll, 0) - eq_(res._flow.mpls_label, 0) - eq_(res._flow.mpls_tc, 0) + self.assertEqual(res._flow.in_port, 0) + self.assertEqual(res._flow.in_phy_port, 0) + self.assertEqual(res._flow.metadata, 0) + self.assertEqual(res._flow.dl_dst, mac.DONTCARE) + self.assertEqual(res._flow.dl_src, mac.DONTCARE) + self.assertEqual(res._flow.dl_type, 0) + self.assertEqual(res._flow.vlan_vid, 0) + self.assertEqual(res._flow.vlan_pcp, 0) + self.assertEqual(res._flow.ip_dscp, 0) + self.assertEqual(res._flow.ip_ecn, 0) + self.assertEqual(res._flow.ip_proto, 0) + self.assertEqual(res._flow.ipv4_src, 0) + self.assertEqual(res._flow.ipv4_dst, 0) + self.assertEqual(res._flow.tcp_src, 0) + self.assertEqual(res._flow.tcp_dst, 0) + self.assertEqual(res._flow.udp_src, 0) + self.assertEqual(res._flow.udp_dst, 0) + self.assertEqual(res._flow.sctp_src, 0) + self.assertEqual(res._flow.sctp_dst, 0) + self.assertEqual(res._flow.icmpv4_type, 0) + self.assertEqual(res._flow.icmpv4_code, 0) + self.assertEqual(res._flow.arp_op, 0) + self.assertEqual(res._flow.arp_spa, 0) + self.assertEqual(res._flow.arp_tpa, 0) + self.assertEqual(res._flow.arp_sha, 0) + self.assertEqual(res._flow.arp_tha, 0) + self.assertEqual(res._flow.ipv6_src, []) + self.assertEqual(res._flow.ipv6_dst, []) + self.assertEqual(res._flow.ipv6_flabel, 0) + self.assertEqual(res._flow.icmpv6_type, 0) + self.assertEqual(res._flow.icmpv6_code, 0) + self.assertEqual(res._flow.ipv6_nd_target, []) + self.assertEqual(res._flow.ipv6_nd_sll, 0) + self.assertEqual(res._flow.ipv6_nd_tll, 0) + self.assertEqual(res._flow.mpls_label, 0) + self.assertEqual(res._flow.mpls_tc, 0) # flow check - eq_(res.fields, []) + self.assertEqual(res.fields, []) def _test_serialize_and_parser(self, match, header, value, mask=None): cls_ = OFPMatchField._FIELDS_HEADERS.get(header) @@ -6633,34 +6626,34 @@ class TestOFPMatch(unittest.TestCase): # serialize buf = bytearray() length = match.serialize(buf, 0) - eq_(length, len(buf)) + self.assertEqual(length, len(buf)) if mask and len(buf) > calcsize(fmt): fmt += pack_str res = list(unpack_from(fmt, six.binary_type(buf), 0)[3:]) if type(value) is list: res_value = res[:calcsize(pack_str) // 2] - eq_(res_value, value) + self.assertEqual(res_value, value) if mask: res_mask = res[calcsize(pack_str) // 2:] - eq_(res_mask, mask) + self.assertEqual(res_mask, mask) else: res_value = res.pop(0) if cls_.__name__ == 'MTVlanVid': - eq_(res_value, value | ofproto.OFPVID_PRESENT) + self.assertEqual(res_value, value | ofproto.OFPVID_PRESENT) else: - eq_(res_value, value) + self.assertEqual(res_value, value) if mask and res and res[0]: res_mask = res[0] - eq_(res_mask, mask) + self.assertEqual(res_mask, mask) # parser res = match.parser(six.binary_type(buf), 0) - eq_(res.type, ofproto.OFPMT_OXM) - eq_(res.fields[0].header, header) - eq_(res.fields[0].value, value) + self.assertEqual(res.type, ofproto.OFPMT_OXM) + self.assertEqual(res.fields[0].header, header) + self.assertEqual(res.fields[0].value, value) if mask and res.fields[0].mask is not None: - eq_(res.fields[0].mask, mask) + self.assertEqual(res.fields[0].mask, mask) # to_jsondict jsondict = match.to_jsondict() @@ -6669,8 +6662,8 @@ class TestOFPMatch(unittest.TestCase): match2 = match.from_jsondict(jsondict["OFPMatch"]) buf2 = bytearray() match2.serialize(buf2, 0) - eq_(str(match), str(match2)) - eq_(buf, buf2) + self.assertEqual(str(match), str(match2)) + self.assertEqual(buf, buf2) def test_parse_unknown_field(self): buf = bytearray() @@ -6865,17 +6858,17 @@ class TestOFPMatch(unittest.TestCase): # serialize buf = bytearray() length = match.serialize(buf, 0) - eq_(length, len(buf)) + self.assertEqual(length, len(buf)) res = list(unpack_from(fmt, six.binary_type(buf), 0)[3:]) res_value = res.pop(0) - eq_(res_value, value) + self.assertEqual(res_value, value) # parser res = match.parser(six.binary_type(buf), 0) - eq_(res.type, ofproto.OFPMT_OXM) - eq_(res.fields[0].header, header) - eq_(res.fields[0].value, value) + self.assertEqual(res.type, ofproto.OFPMT_OXM) + self.assertEqual(res.fields[0].header, header) + self.assertEqual(res.fields[0].value, value) # to_jsondict jsondict = match.to_jsondict() @@ -6884,8 +6877,8 @@ class TestOFPMatch(unittest.TestCase): match2 = match.from_jsondict(jsondict["OFPMatch"]) buf2 = bytearray() match2.serialize(buf2, 0) - eq_(str(match), str(match2)) - eq_(buf, buf2) + self.assertEqual(str(match), str(match2)) + self.assertEqual(buf, buf2) def test_set_vlan_vid_mid(self): self._test_set_vlan_vid(2047) @@ -7547,15 +7540,15 @@ class TestOFPMatchField(unittest.TestCase): res = OFPMatchField(header) - eq_(res.header, header) - eq_(res.n_bytes, (header & 0xff) // 2) - eq_(res.length, 0) + self.assertEqual(res.header, header) + self.assertEqual(res.n_bytes, (header & 0xff) // 2) + self.assertEqual(res.length, 0) def test_init_hasmask_false(self): header = 0x0000 res = OFPMatchField(header) - eq_(res.header, header) - eq_(res.n_bytes, header & 0xff) - eq_(res.length, 0) + self.assertEqual(res.header, header) + self.assertEqual(res.n_bytes, header & 0xff) + self.assertEqual(res.length, 0) diff --git a/os_ken/tests/unit/ofproto/test_parser_v13.py b/os_ken/tests/unit/ofproto/test_parser_v13.py index 90804ea2..03808d67 100644 --- a/os_ken/tests/unit/ofproto/test_parser_v13.py +++ b/os_ken/tests/unit/ofproto/test_parser_v13.py @@ -20,15 +20,9 @@ import logging import six import socket from struct import * -from nose.tools import * from os_ken.ofproto.ofproto_v1_3_parser import * -from os_ken.ofproto import ofproto_v1_3_parser from os_ken.ofproto import ofproto_v1_3 from os_ken.ofproto import ofproto_protocol -from os_ken.ofproto import ether -from os_ken.ofproto.ofproto_parser import MsgBase -from os_ken import utils -from os_ken.lib import addrconv LOG = logging.getLogger('test_ofproto_v13') @@ -45,10 +39,10 @@ class TestOFPMatch(unittest.TestCase): res = OFPMatch() # wc check - eq_(res._wc.vlan_vid_mask, 0) + self.assertEqual(res._wc.vlan_vid_mask, 0) # flow check - eq_(res._flow.vlan_vid, 0) + self.assertEqual(res._flow.vlan_vid, 0) def _test_serialize_and_parser(self, match, header, value, mask=None): cls_ = OFPMatchField._FIELDS_HEADERS.get(header) @@ -58,34 +52,34 @@ class TestOFPMatch(unittest.TestCase): # serialize buf = bytearray() length = match.serialize(buf, 0) - eq_(length, len(buf)) + self.assertEqual(length, len(buf)) if mask and len(buf) > calcsize(fmt): fmt += pack_str res = list(unpack_from(fmt, six.binary_type(buf), 0)[3:]) if type(value) is list: res_value = res[:calcsize(pack_str) // 2] - eq_(res_value, value) + self.assertEqual(res_value, value) if mask: res_mask = res[calcsize(pack_str) // 2:] - eq_(res_mask, mask) + self.assertEqual(res_mask, mask) else: res_value = res.pop(0) if cls_.__name__ == 'MTVlanVid': - eq_(res_value, value | ofproto.OFPVID_PRESENT) + self.assertEqual(res_value, value | ofproto.OFPVID_PRESENT) else: - eq_(res_value, value) + self.assertEqual(res_value, value) if mask and res and res[0]: res_mask = res[0] - eq_(res_mask, mask) + self.assertEqual(res_mask, mask) # parser res = match.parser(six.binary_type(buf), 0) - eq_(res.type, ofproto.OFPMT_OXM) - eq_(res.fields[0].header, header) - eq_(res.fields[0].value, value) + self.assertEqual(res.type, ofproto.OFPMT_OXM) + self.assertEqual(res.fields[0].header, header) + self.assertEqual(res.fields[0].value, value) if mask and res.fields[0].mask is not None: - eq_(res.fields[0].mask, mask) + self.assertEqual(res.fields[0].mask, mask) # to_jsondict jsondict = match.to_jsondict() @@ -94,8 +88,8 @@ class TestOFPMatch(unittest.TestCase): match2 = match.from_jsondict(jsondict["OFPMatch"]) buf2 = bytearray() match2.serialize(buf2, 0) - eq_(str(match), str(match2)) - eq_(buf, buf2) + self.assertEqual(str(match), str(match2)) + self.assertEqual(buf, buf2) # set_vlan_vid def _test_set_vlan_vid(self, vid, mask=None): @@ -120,17 +114,17 @@ class TestOFPMatch(unittest.TestCase): # serialize buf = bytearray() length = match.serialize(buf, 0) - eq_(length, len(buf)) + self.assertEqual(length, len(buf)) res = list(unpack_from(fmt, six.binary_type(buf), 0)[3:]) res_value = res.pop(0) - eq_(res_value, value) + self.assertEqual(res_value, value) # parser res = match.parser(six.binary_type(buf), 0) - eq_(res.type, ofproto.OFPMT_OXM) - eq_(res.fields[0].header, header) - eq_(res.fields[0].value, value) + self.assertEqual(res.type, ofproto.OFPMT_OXM) + self.assertEqual(res.fields[0].header, header) + self.assertEqual(res.fields[0].value, value) # to_jsondict jsondict = match.to_jsondict() @@ -139,8 +133,8 @@ class TestOFPMatch(unittest.TestCase): match2 = match.from_jsondict(jsondict["OFPMatch"]) buf2 = bytearray() match2.serialize(buf2, 0) - eq_(str(match), str(match2)) - eq_(buf, buf2) + self.assertEqual(str(match), str(match2)) + self.assertEqual(buf, buf2) def test_set_vlan_vid_mid(self): self._test_set_vlan_vid(2047) diff --git a/os_ken/tests/unit/packet/test_arp.py b/os_ken/tests/unit/packet/test_arp.py index d8e44f0a..8d43d91d 100644 --- a/os_ken/tests/unit/packet/test_arp.py +++ b/os_ken/tests/unit/packet/test_arp.py @@ -19,7 +19,6 @@ import unittest import logging import struct from struct import * -from nose.tools import * from os_ken.ofproto import ether from os_ken.lib.packet.ethernet import ethernet from os_ken.lib.packet.packet import Packet @@ -67,15 +66,15 @@ class Test_arp(unittest.TestCase): return p def test_init(self): - eq_(self.hwtype, self.a.hwtype) - eq_(self.proto, self.a.proto) - eq_(self.hlen, self.a.hlen) - eq_(self.plen, self.a.plen) - eq_(self.opcode, self.a.opcode) - eq_(self.src_mac, self.a.src_mac) - eq_(self.src_ip, self.a.src_ip) - eq_(self.dst_mac, self.a.dst_mac) - eq_(self.dst_ip, self.a.dst_ip) + self.assertEqual(self.hwtype, self.a.hwtype) + self.assertEqual(self.proto, self.a.proto) + self.assertEqual(self.hlen, self.a.hlen) + self.assertEqual(self.plen, self.a.plen) + self.assertEqual(self.opcode, self.a.opcode) + self.assertEqual(self.src_mac, self.a.src_mac) + self.assertEqual(self.src_ip, self.a.src_ip) + self.assertEqual(self.dst_mac, self.a.dst_mac) + self.assertEqual(self.dst_ip, self.a.dst_ip) def test_parser(self): _res = self.a.parser(self.buf) @@ -84,15 +83,15 @@ class Test_arp(unittest.TestCase): else: res = _res - eq_(res.hwtype, self.hwtype) - eq_(res.proto, self.proto) - eq_(res.hlen, self.hlen) - eq_(res.plen, self.plen) - eq_(res.opcode, self.opcode) - eq_(res.src_mac, self.src_mac) - eq_(res.src_ip, self.src_ip) - eq_(res.dst_mac, self.dst_mac) - eq_(res.dst_ip, self.dst_ip) + self.assertEqual(res.hwtype, self.hwtype) + self.assertEqual(res.proto, self.proto) + self.assertEqual(res.hlen, self.hlen) + self.assertEqual(res.plen, self.plen) + self.assertEqual(res.opcode, self.opcode) + self.assertEqual(res.src_mac, self.src_mac) + self.assertEqual(res.src_ip, self.src_ip) + self.assertEqual(res.dst_mac, self.dst_mac) + self.assertEqual(res.dst_ip, self.dst_ip) def test_serialize(self): data = bytearray() @@ -102,15 +101,15 @@ class Test_arp(unittest.TestCase): fmt = arp._PACK_STR res = struct.unpack(fmt, buf) - eq_(res[0], self.hwtype) - eq_(res[1], self.proto) - eq_(res[2], self.hlen) - eq_(res[3], self.plen) - eq_(res[4], self.opcode) - eq_(res[5], addrconv.mac.text_to_bin(self.src_mac)) - eq_(res[6], addrconv.ipv4.text_to_bin(self.src_ip)) - eq_(res[7], addrconv.mac.text_to_bin(self.dst_mac)) - eq_(res[8], addrconv.ipv4.text_to_bin(self.dst_ip)) + self.assertEqual(res[0], self.hwtype) + self.assertEqual(res[1], self.proto) + self.assertEqual(res[2], self.hlen) + self.assertEqual(res[3], self.plen) + self.assertEqual(res[4], self.opcode) + self.assertEqual(res[5], addrconv.mac.text_to_bin(self.src_mac)) + self.assertEqual(res[6], addrconv.ipv4.text_to_bin(self.src_ip)) + self.assertEqual(res[7], addrconv.mac.text_to_bin(self.dst_mac)) + self.assertEqual(res[8], addrconv.ipv4.text_to_bin(self.dst_ip)) def _build_arp(self, vlan_enabled): if vlan_enabled is True: @@ -132,52 +131,51 @@ class Test_arp(unittest.TestCase): p = self._build_arp(True) e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_8021Q) + self.assertTrue(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_8021Q) v = self.find_protocol(p, "vlan") - ok_(v) - eq_(v.ethertype, ether.ETH_TYPE_ARP) + self.assertTrue(v) + self.assertEqual(v.ethertype, ether.ETH_TYPE_ARP) a = self.find_protocol(p, "arp") - ok_(a) + self.assertTrue(a) - eq_(a.hwtype, self.hwtype) - eq_(a.proto, self.proto) - eq_(a.hlen, self.hlen) - eq_(a.plen, self.plen) - eq_(a.opcode, self.opcode) - eq_(a.src_mac, self.src_mac) - eq_(a.src_ip, self.src_ip) - eq_(a.dst_mac, self.dst_mac) - eq_(a.dst_ip, self.dst_ip) + self.assertEqual(a.hwtype, self.hwtype) + self.assertEqual(a.proto, self.proto) + self.assertEqual(a.hlen, self.hlen) + self.assertEqual(a.plen, self.plen) + self.assertEqual(a.opcode, self.opcode) + self.assertEqual(a.src_mac, self.src_mac) + self.assertEqual(a.src_ip, self.src_ip) + self.assertEqual(a.dst_mac, self.dst_mac) + self.assertEqual(a.dst_ip, self.dst_ip) def test_build_arp_novlan(self): p = self._build_arp(False) e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_ARP) + self.assertTrue(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_ARP) a = self.find_protocol(p, "arp") - ok_(a) + self.assertTrue(a) - eq_(a.hwtype, self.hwtype) - eq_(a.proto, self.proto) - eq_(a.hlen, self.hlen) - eq_(a.plen, self.plen) - eq_(a.opcode, self.opcode) - eq_(a.src_mac, self.src_mac) - eq_(a.src_ip, self.src_ip) - eq_(a.dst_mac, self.dst_mac) - eq_(a.dst_ip, self.dst_ip) + self.assertEqual(a.hwtype, self.hwtype) + self.assertEqual(a.proto, self.proto) + self.assertEqual(a.hlen, self.hlen) + self.assertEqual(a.plen, self.plen) + self.assertEqual(a.opcode, self.opcode) + self.assertEqual(a.src_mac, self.src_mac) + self.assertEqual(a.src_ip, self.src_ip) + self.assertEqual(a.dst_mac, self.dst_mac) + self.assertEqual(a.dst_ip, self.dst_ip) - @raises(Exception) def test_malformed_arp(self): m_short_buf = self.buf[1:arp._MIN_LEN] - arp.parser(m_short_buf) + self.assertRaises(Exception, arp.parser, m_short_buf) def test_json(self): jsondict = self.a.to_jsondict() a = arp.from_jsondict(jsondict['arp']) - eq_(str(self.a), str(a)) + self.assertEqual(str(self.a), str(a)) diff --git a/os_ken/tests/unit/packet/test_bfd.py b/os_ken/tests/unit/packet/test_bfd.py index bac0fb96..2ee7b35a 100644 --- a/os_ken/tests/unit/packet/test_bfd.py +++ b/os_ken/tests/unit/packet/test_bfd.py @@ -17,7 +17,6 @@ import unittest import logging import struct import inspect -from nose.tools import ok_, eq_, nottest from os_ken.ofproto import ether from os_ken.ofproto import inet @@ -95,52 +94,52 @@ class TestBFD(unittest.TestCase): pkt = packet.Packet(buf) i = iter(pkt) - eq_(type(next(i)), ethernet.ethernet) - eq_(type(next(i)), ipv4.ipv4) - eq_(type(next(i)), udp.udp) - eq_(type(bfd.bfd.parser(next(i))[0]), bfd.bfd) + self.assertEqual(type(next(i)), ethernet.ethernet) + self.assertEqual(type(next(i)), ipv4.ipv4) + self.assertEqual(type(next(i)), udp.udp) + self.assertEqual(type(bfd.bfd.parser(next(i))[0]), bfd.bfd) def test_parse_with_auth_simple(self): buf = self.data_auth_simple pkt = packet.Packet(buf) i = iter(pkt) - eq_(type(next(i)), ethernet.ethernet) - eq_(type(next(i)), ipv4.ipv4) - eq_(type(next(i)), udp.udp) + self.assertEqual(type(next(i)), ethernet.ethernet) + self.assertEqual(type(next(i)), ipv4.ipv4) + self.assertEqual(type(next(i)), udp.udp) bfd_obj = bfd.bfd.parser(next(i))[0] - eq_(type(bfd_obj), bfd.bfd) - eq_(type(bfd_obj.auth_cls), bfd.SimplePassword) - ok_(bfd_obj.authenticate(self.auth_keys)) + self.assertEqual(type(bfd_obj), bfd.bfd) + self.assertEqual(type(bfd_obj.auth_cls), bfd.SimplePassword) + self.assertTrue(bfd_obj.authenticate(self.auth_keys)) def test_parse_with_auth_md5(self): buf = self.data_auth_md5 pkt = packet.Packet(buf) i = iter(pkt) - eq_(type(next(i)), ethernet.ethernet) - eq_(type(next(i)), ipv4.ipv4) - eq_(type(next(i)), udp.udp) + self.assertEqual(type(next(i)), ethernet.ethernet) + self.assertEqual(type(next(i)), ipv4.ipv4) + self.assertEqual(type(next(i)), udp.udp) bfd_obj = bfd.bfd.parser(next(i))[0] - eq_(type(bfd_obj), bfd.bfd) - eq_(type(bfd_obj.auth_cls), bfd.KeyedMD5) - ok_(bfd_obj.authenticate(self.auth_keys)) + self.assertEqual(type(bfd_obj), bfd.bfd) + self.assertEqual(type(bfd_obj.auth_cls), bfd.KeyedMD5) + self.assertTrue(bfd_obj.authenticate(self.auth_keys)) def test_parse_with_auth_sha1(self): buf = self.data_auth_sha1 pkt = packet.Packet(buf) i = iter(pkt) - eq_(type(next(i)), ethernet.ethernet) - eq_(type(next(i)), ipv4.ipv4) - eq_(type(next(i)), udp.udp) + self.assertEqual(type(next(i)), ethernet.ethernet) + self.assertEqual(type(next(i)), ipv4.ipv4) + self.assertEqual(type(next(i)), udp.udp) bfd_obj = bfd.bfd.parser(next(i))[0] - eq_(type(bfd_obj), bfd.bfd) - eq_(type(bfd_obj.auth_cls), bfd.KeyedSHA1) - ok_(bfd_obj.authenticate(self.auth_keys)) + self.assertEqual(type(bfd_obj), bfd.bfd) + self.assertEqual(type(bfd_obj.auth_cls), bfd.KeyedSHA1) + self.assertTrue(bfd_obj.authenticate(self.auth_keys)) def test_serialize(self): pkt = packet.Packet() @@ -162,10 +161,10 @@ class TestBFD(unittest.TestCase): required_min_echo_rx_interval=0) pkt.add_protocol(bfd_pkt) - eq_(len(pkt.protocols), 4) + self.assertEqual(len(pkt.protocols), 4) pkt.serialize() - eq_(pkt.data, self.data) + self.assertEqual(pkt.data, self.data) def test_serialize_with_auth_simple(self): pkt = packet.Packet() @@ -193,10 +192,10 @@ class TestBFD(unittest.TestCase): pkt.add_protocol(bfd_pkt) - eq_(len(pkt.protocols), 4) + self.assertEqual(len(pkt.protocols), 4) pkt.serialize() - eq_(pkt.data, self.data_auth_simple) + self.assertEqual(pkt.data, self.data_auth_simple) def test_serialize_with_auth_md5(self): pkt = packet.Packet() @@ -224,10 +223,10 @@ class TestBFD(unittest.TestCase): pkt.add_protocol(bfd_pkt) - eq_(len(pkt.protocols), 4) + self.assertEqual(len(pkt.protocols), 4) pkt.serialize() - eq_(pkt.data, self.data_auth_md5) + self.assertEqual(pkt.data, self.data_auth_md5) def test_serialize_with_auth_sha1(self): pkt = packet.Packet() @@ -255,10 +254,10 @@ class TestBFD(unittest.TestCase): pkt.add_protocol(bfd_pkt) - eq_(len(pkt.protocols), 4) + self.assertEqual(len(pkt.protocols), 4) pkt.serialize() - eq_(pkt.data, self.data_auth_sha1) + self.assertEqual(pkt.data, self.data_auth_sha1) def test_json(self): bfd1 = bfd.bfd(ver=1, diag=bfd.BFD_DIAG_CTRL_DETECT_TIME_EXPIRED, @@ -269,7 +268,7 @@ class TestBFD(unittest.TestCase): jsondict = bfd1.to_jsondict() bfd2 = bfd.bfd.from_jsondict(jsondict['bfd']) - eq_(str(bfd1), str(bfd2)) + self.assertEqual(str(bfd1), str(bfd2)) def test_json_with_auth_simple(self): auth_cls = bfd.SimplePassword(auth_key_id=2, @@ -285,7 +284,7 @@ class TestBFD(unittest.TestCase): jsondict = bfd1.to_jsondict() bfd2 = bfd.bfd.from_jsondict(jsondict['bfd']) - eq_(str(bfd1), str(bfd2)) + self.assertEqual(str(bfd1), str(bfd2)) def test_json_with_auth_md5(self): auth_cls = bfd.KeyedMD5(auth_key_id=2, seq=16859, @@ -301,7 +300,7 @@ class TestBFD(unittest.TestCase): jsondict = bfd1.to_jsondict() bfd2 = bfd.bfd.from_jsondict(jsondict['bfd']) - eq_(str(bfd1), str(bfd2)) + self.assertEqual(str(bfd1), str(bfd2)) def test_json_with_auth_sha1(self): auth_cls = bfd.KeyedSHA1(auth_key_id=2, seq=16859, @@ -317,4 +316,4 @@ class TestBFD(unittest.TestCase): jsondict = bfd1.to_jsondict() bfd2 = bfd.bfd.from_jsondict(jsondict['bfd']) - eq_(str(bfd1), str(bfd2)) + self.assertEqual(str(bfd1), str(bfd2)) diff --git a/os_ken/tests/unit/packet/test_bgp.py b/os_ken/tests/unit/packet/test_bgp.py index c6d601cd..8c8a1780 100644 --- a/os_ken/tests/unit/packet/test_bgp.py +++ b/os_ken/tests/unit/packet/test_bgp.py @@ -19,8 +19,6 @@ import os import sys import unittest -from nose.tools import eq_ -from nose.tools import ok_ from os_ken.utils import binary_str from os_ken.lib import pcaplib @@ -150,9 +148,9 @@ class Test_bgp(unittest.TestCase): msg = bgp.BGPOpen(my_as=30000, bgp_identifier='192.0.2.1') binmsg = msg.serialize() msg2, _, rest = bgp.BGPMessage.parser(binmsg) - eq_(str(msg), str(msg2)) - eq_(len(msg), 29) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(len(msg), 29) + self.assertEqual(rest, b'') def test_open2(self): opt_param = [bgp.BGPOptParamCapabilityUnknown(cap_code=200, @@ -172,17 +170,17 @@ class Test_bgp(unittest.TestCase): opt_param=opt_param) binmsg = msg.serialize() msg2, _, rest = bgp.BGPMessage.parser(binmsg) - eq_(str(msg), str(msg2)) - ok_(len(msg) > 29) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg2)) + self.assertTrue(len(msg) > 29) + self.assertEqual(rest, b'') def test_update1(self): msg = bgp.BGPUpdate() binmsg = msg.serialize() msg2, _, rest = bgp.BGPMessage.parser(binmsg) - eq_(str(msg), str(msg2)) - eq_(len(msg), 23) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(len(msg), 23) + self.assertEqual(rest, b'') def test_update2(self): withdrawn_routes = [bgp.BGPWithdrawnRoute(length=0, @@ -313,34 +311,34 @@ class Test_bgp(unittest.TestCase): nlri=nlri) binmsg = msg.serialize() msg2, _, rest = bgp.BGPMessage.parser(binmsg) - eq_(str(msg), str(msg2)) - ok_(len(msg) > 23) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg2)) + self.assertTrue(len(msg) > 23) + self.assertEqual(rest, b'') def test_keepalive(self): msg = bgp.BGPKeepAlive() binmsg = msg.serialize() msg2, _, rest = bgp.BGPMessage.parser(binmsg) - eq_(str(msg), str(msg2)) - eq_(len(msg), 19) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(len(msg), 19) + self.assertEqual(rest, b'') def test_notification(self): data = b'hoge' msg = bgp.BGPNotification(error_code=1, error_subcode=2, data=data) binmsg = msg.serialize() msg2, _, rest = bgp.BGPMessage.parser(binmsg) - eq_(str(msg), str(msg2)) - eq_(len(msg), 21 + len(data)) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(len(msg), 21 + len(data)) + self.assertEqual(rest, b'') def test_route_refresh(self): msg = bgp.BGPRouteRefresh(afi=afi.IP, safi=safi.MPLS_VPN) binmsg = msg.serialize() msg2, _, rest = bgp.BGPMessage.parser(binmsg) - eq_(str(msg), str(msg2)) - eq_(len(msg), 23) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(len(msg), 23) + self.assertEqual(rest, b'') def test_stream_parser(self): msgs = [ @@ -354,7 +352,7 @@ class Test_bgp(unittest.TestCase): for b in binmsgs: for m in sp.parse(b): results.append(m) - eq_(str(results), str(msgs)) + self.assertEqual(str(results), str(msgs)) def test_parser(self): files = [ @@ -391,12 +389,12 @@ class Test_bgp(unittest.TestCase): open(BGP4_PACKET_DATA_DIR + f + '.pcap', 'rb')): # Checks if BGP message can be parsed as expected. pkt = packet.Packet(buf) - ok_(isinstance(pkt.protocols[-1], bgp.BGPMessage), + self.assertTrue(isinstance(pkt.protocols[-1], bgp.BGPMessage), 'Failed to parse BGP message: %s' % pkt) # Checks if BGP message can be serialized as expected. pkt.serialize() - eq_(buf, pkt.data, + self.assertEqual(buf, pkt.data, "b'%s' != b'%s'" % (binary_str(buf), binary_str(pkt.data))) def test_vlan_action_parser(self): @@ -411,8 +409,8 @@ class Test_bgp(unittest.TestCase): ) binmsg = action.serialize() msg, rest = bgp.BGPFlowSpecVlanActionCommunity.parse(binmsg) - eq_(str(action), str(msg)) - eq_(rest, b'') + self.assertEqual(str(action), str(msg)) + self.assertEqual(rest, b'') def test_tpid_action_parser(self): action = bgp.BGPFlowSpecTPIDActionCommunity( @@ -423,8 +421,8 @@ class Test_bgp(unittest.TestCase): ) binmsg = action.serialize() msg, rest = bgp.BGPFlowSpecTPIDActionCommunity.parse(binmsg) - eq_(str(action), str(msg)) - eq_(rest, b'') + self.assertEqual(str(action), str(msg)) + self.assertEqual(rest, b'') def test_json1(self): opt_param = [bgp.BGPOptParamCapabilityUnknown(cap_code=200, @@ -439,7 +437,7 @@ class Test_bgp(unittest.TestCase): opt_param=opt_param) jsondict = msg1.to_jsondict() msg2 = bgp.BGPOpen.from_jsondict(jsondict['BGPOpen']) - eq_(str(msg1), str(msg2)) + self.assertEqual(str(msg1), str(msg2)) def test_json2(self): withdrawn_routes = [bgp.BGPWithdrawnRoute(length=0, @@ -568,7 +566,7 @@ class Test_bgp(unittest.TestCase): nlri=nlri) jsondict = msg1.to_jsondict() msg2 = bgp.BGPUpdate.from_jsondict(jsondict['BGPUpdate']) - eq_(str(msg1), str(msg2)) + self.assertEqual(str(msg1), str(msg2)) def test_flowspec_user_interface_ipv4(self): rules = RULES_BASE + [ @@ -614,11 +612,11 @@ class Test_bgp(unittest.TestCase): msg2 = bgp.FlowSpecIPv4NLRI(rules=rules) binmsg = msg.serialize() binmsg2 = msg2.serialize() - eq_(str(msg), str(msg2)) - eq_(binary_str(binmsg), binary_str(binmsg2)) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(binary_str(binmsg), binary_str(binmsg2)) msg3, rest = bgp.FlowSpecIPv4NLRI.parser(binmsg) - eq_(str(msg), str(msg3)) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg3)) + self.assertEqual(rest, b'') def test_flowspec_user_interface_vpv4(self): rules = RULES_BASE + [ @@ -664,11 +662,11 @@ class Test_bgp(unittest.TestCase): msg2 = bgp.FlowSpecVPNv4NLRI(route_dist='65001:250', rules=rules) binmsg = msg.serialize() binmsg2 = msg2.serialize() - eq_(str(msg), str(msg2)) - eq_(binary_str(binmsg), binary_str(binmsg2)) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(binary_str(binmsg), binary_str(binmsg2)) msg3, rest = bgp.FlowSpecVPNv4NLRI.parser(binmsg) - eq_(str(msg), str(msg3)) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg3)) + self.assertEqual(rest, b'') def test_flowspec_user_interface_ipv6(self): rules = RULES_BASE + [ @@ -721,11 +719,11 @@ class Test_bgp(unittest.TestCase): msg2 = bgp.FlowSpecIPv6NLRI(rules=rules) binmsg = msg.serialize() binmsg2 = msg2.serialize() - eq_(str(msg), str(msg2)) - eq_(binary_str(binmsg), binary_str(binmsg2)) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(binary_str(binmsg), binary_str(binmsg2)) msg3, rest = bgp.FlowSpecIPv6NLRI.parser(binmsg) - eq_(str(msg), str(msg3)) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg3)) + self.assertEqual(rest, b'') def test_flowspec_user_interface_vpnv6(self): rules = RULES_BASE + [ @@ -779,11 +777,11 @@ class Test_bgp(unittest.TestCase): msg2 = bgp.FlowSpecVPNv6NLRI(route_dist='65001:250', rules=rules) binmsg = msg.serialize() binmsg2 = msg2.serialize() - eq_(str(msg), str(msg2)) - eq_(binary_str(binmsg), binary_str(binmsg2)) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(binary_str(binmsg), binary_str(binmsg2)) msg3, rest = bgp.FlowSpecVPNv6NLRI.parser(binmsg) - eq_(str(msg), str(msg3)) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg3)) + self.assertEqual(rest, b'') def test_flowspec_user_interface_l2vpn(self): rules = RULES_L2VPN_BASE @@ -804,8 +802,8 @@ class Test_bgp(unittest.TestCase): msg2 = bgp.FlowSpecL2VPNNLRI(route_dist='65001:250', rules=rules) binmsg = msg.serialize() binmsg2 = msg2.serialize() - eq_(str(msg), str(msg2)) - eq_(binary_str(binmsg), binary_str(binmsg2)) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(binary_str(binmsg), binary_str(binmsg2)) msg3, rest = bgp.FlowSpecL2VPNNLRI.parser(binmsg) - eq_(str(msg), str(msg3)) - eq_(rest, b'') + self.assertEqual(str(msg), str(msg3)) + self.assertEqual(rest, b'') diff --git a/os_ken/tests/unit/packet/test_bmp.py b/os_ken/tests/unit/packet/test_bmp.py index da831af5..cad95cbd 100644 --- a/os_ken/tests/unit/packet/test_bmp.py +++ b/os_ken/tests/unit/packet/test_bmp.py @@ -14,8 +14,6 @@ # limitations under the License. import unittest -from nose.tools import eq_ -from nose.tools import ok_ from time import time from os_ken.lib.packet import bmp @@ -51,8 +49,8 @@ class Test_bmp(unittest.TestCase): timestamp=self._time()) binmsg = msg.serialize() msg2, rest = bmp.BMPMessage.parser(binmsg) - eq_(msg.to_jsondict(), msg2.to_jsondict()) - eq_(rest, b'') + self.assertEqual(msg.to_jsondict(), msg2.to_jsondict()) + self.assertEqual(rest, b'') def test_route_monitoring_adj_rib_out(self): update = bgp.BGPUpdate() @@ -67,8 +65,8 @@ class Test_bmp(unittest.TestCase): timestamp=self._time()) binmsg = msg.serialize() msg2, rest = bmp.BMPMessage.parser(binmsg) - eq_(msg.to_jsondict(), msg2.to_jsondict()) - eq_(rest, b'') + self.assertEqual(msg.to_jsondict(), msg2.to_jsondict()) + self.assertEqual(rest, b'') def test_statistics_report(self): stats = [{'type': bmp.BMP_STAT_TYPE_REJECTED, 'value': 100}, @@ -89,8 +87,8 @@ class Test_bmp(unittest.TestCase): timestamp=self._time()) binmsg = msg.serialize() msg2, rest = bmp.BMPMessage.parser(binmsg) - eq_(msg.to_jsondict(), msg2.to_jsondict()) - eq_(rest, b'') + self.assertEqual(msg.to_jsondict(), msg2.to_jsondict()) + self.assertEqual(rest, b'') def test_peer_down_notification(self): reason = bmp.BMP_PEER_DOWN_REASON_LOCAL_BGP_NOTIFICATION @@ -106,8 +104,8 @@ class Test_bmp(unittest.TestCase): timestamp=self._time()) binmsg = msg.serialize() msg2, rest = bmp.BMPMessage.parser(binmsg) - eq_(msg.to_jsondict(), msg2.to_jsondict()) - eq_(rest, b'') + self.assertEqual(msg.to_jsondict(), msg2.to_jsondict()) + self.assertEqual(rest, b'') def test_peer_up_notification(self): opt_param = [bgp.BGPOptParamCapabilityUnknown(cap_code=200, @@ -131,8 +129,8 @@ class Test_bmp(unittest.TestCase): timestamp=self._time()) binmsg = msg.serialize() msg2, rest = bmp.BMPMessage.parser(binmsg) - eq_(msg.to_jsondict(), msg2.to_jsondict()) - eq_(rest, b'') + self.assertEqual(msg.to_jsondict(), msg2.to_jsondict()) + self.assertEqual(rest, b'') def test_initiation(self): initiation_info = [{'type': bmp.BMP_INIT_TYPE_STRING, @@ -140,8 +138,8 @@ class Test_bmp(unittest.TestCase): msg = bmp.BMPInitiation(info=initiation_info) binmsg = msg.serialize() msg2, rest = bmp.BMPMessage.parser(binmsg) - eq_(msg.to_jsondict(lambda v: v), msg2.to_jsondict(lambda v: v)) - eq_(rest, b'') + self.assertEqual(msg.to_jsondict(lambda v: v), msg2.to_jsondict(lambda v: v)) + self.assertEqual(rest, b'') def test_termination(self): termination_info = [{'type': bmp.BMP_TERM_TYPE_STRING, @@ -151,5 +149,5 @@ class Test_bmp(unittest.TestCase): msg = bmp.BMPTermination(info=termination_info) binmsg = msg.serialize() msg2, rest = bmp.BMPMessage.parser(binmsg) - eq_(msg.to_jsondict(lambda v: v), msg2.to_jsondict(lambda v: v)) - eq_(rest, b'') + self.assertEqual(msg.to_jsondict(lambda v: v), msg2.to_jsondict(lambda v: v)) + self.assertEqual(rest, b'') diff --git a/os_ken/tests/unit/packet/test_bpdu.py b/os_ken/tests/unit/packet/test_bpdu.py index 1daf70db..adc91485 100644 --- a/os_ken/tests/unit/packet/test_bpdu.py +++ b/os_ken/tests/unit/packet/test_bpdu.py @@ -19,7 +19,6 @@ import unittest import logging import struct -from nose.tools import eq_ from os_ken.lib.packet import bpdu @@ -92,48 +91,48 @@ class Test_ConfigurationBPDUs(unittest.TestCase): self.forward_delay)) def test_init(self): - eq_(self.protocol_id, self.msg._protocol_id) - eq_(self.version_id, self.msg._version_id) - eq_(self.bpdu_type, self.msg._bpdu_type) - eq_(self.flags, self.msg.flags) - eq_(self.root_priority, self.msg.root_priority) - eq_(self.root_system_id_extension, + self.assertEqual(self.protocol_id, self.msg._protocol_id) + self.assertEqual(self.version_id, self.msg._version_id) + self.assertEqual(self.bpdu_type, self.msg._bpdu_type) + self.assertEqual(self.flags, self.msg.flags) + self.assertEqual(self.root_priority, self.msg.root_priority) + self.assertEqual(self.root_system_id_extension, self.msg.root_system_id_extension) - eq_(self.root_mac_address, self.msg.root_mac_address) - eq_(self.root_path_cost, self.msg.root_path_cost) - eq_(self.bridge_priority, self.msg.bridge_priority) - eq_(self.bridge_system_id_extension, + self.assertEqual(self.root_mac_address, self.msg.root_mac_address) + self.assertEqual(self.root_path_cost, self.msg.root_path_cost) + self.assertEqual(self.bridge_priority, self.msg.bridge_priority) + self.assertEqual(self.bridge_system_id_extension, self.msg.bridge_system_id_extension) - eq_(self.bridge_mac_address, self.msg.bridge_mac_address) - eq_(self.port_priority, self.msg.port_priority) - eq_(self.port_number, self.msg.port_number) - eq_(self.message_age, self.msg.message_age) - eq_(self.max_age, self.msg.max_age) - eq_(self.hello_time, self.msg.hello_time) - eq_(self.forward_delay, self.msg.forward_delay) + self.assertEqual(self.bridge_mac_address, self.msg.bridge_mac_address) + self.assertEqual(self.port_priority, self.msg.port_priority) + self.assertEqual(self.port_number, self.msg.port_number) + self.assertEqual(self.message_age, self.msg.message_age) + self.assertEqual(self.max_age, self.msg.max_age) + self.assertEqual(self.hello_time, self.msg.hello_time) + self.assertEqual(self.forward_delay, self.msg.forward_delay) def test_parser(self): r1, r2, _ = bpdu.bpdu.parser(self.buf) - eq_(type(r1), type(self.msg)) - eq_(r1._protocol_id, self.protocol_id) - eq_(r1._version_id, self.version_id) - eq_(r1._bpdu_type, self.bpdu_type) - eq_(r1.flags, self.flags) - eq_(r1.root_priority, self.root_priority) - eq_(r1.root_system_id_extension, self.root_system_id_extension) - eq_(r1.root_mac_address, self.root_mac_address) - eq_(r1.root_path_cost, self.root_path_cost) - eq_(r1.bridge_priority, self.bridge_priority) - eq_(r1.bridge_system_id_extension, self.bridge_system_id_extension) - eq_(r1.bridge_mac_address, self.bridge_mac_address) - eq_(r1.port_priority, self.port_priority) - eq_(r1.port_number, self.port_number) - eq_(r1.message_age, self.message_age) - eq_(r1.max_age, self.max_age) - eq_(r1.hello_time, self.hello_time) - eq_(r1.forward_delay, self.forward_delay) - eq_(r2, None) + self.assertEqual(type(r1), type(self.msg)) + self.assertEqual(r1._protocol_id, self.protocol_id) + self.assertEqual(r1._version_id, self.version_id) + self.assertEqual(r1._bpdu_type, self.bpdu_type) + self.assertEqual(r1.flags, self.flags) + self.assertEqual(r1.root_priority, self.root_priority) + self.assertEqual(r1.root_system_id_extension, self.root_system_id_extension) + self.assertEqual(r1.root_mac_address, self.root_mac_address) + self.assertEqual(r1.root_path_cost, self.root_path_cost) + self.assertEqual(r1.bridge_priority, self.bridge_priority) + self.assertEqual(r1.bridge_system_id_extension, self.bridge_system_id_extension) + self.assertEqual(r1.bridge_mac_address, self.bridge_mac_address) + self.assertEqual(r1.port_priority, self.port_priority) + self.assertEqual(r1.port_number, self.port_number) + self.assertEqual(r1.message_age, self.message_age) + self.assertEqual(r1.max_age, self.max_age) + self.assertEqual(r1.hello_time, self.hello_time) + self.assertEqual(r1.forward_delay, self.forward_delay) + self.assertEqual(r2, None) def test_serialize(self): data = bytearray() @@ -141,32 +140,32 @@ class Test_ConfigurationBPDUs(unittest.TestCase): buf = self.msg.serialize(data, prev) res = struct.unpack(self.fmt, buf) - eq_(res[0], self.protocol_id) - eq_(res[1], self.version_id) - eq_(res[2], self.bpdu_type) - eq_(res[3], self.flags) - eq_(bpdu.ConfigurationBPDUs._decode_bridge_id(res[4]), + self.assertEqual(res[0], self.protocol_id) + self.assertEqual(res[1], self.version_id) + self.assertEqual(res[2], self.bpdu_type) + self.assertEqual(res[3], self.flags) + self.assertEqual(bpdu.ConfigurationBPDUs._decode_bridge_id(res[4]), (self.root_priority, self.root_system_id_extension, self.root_mac_address)) - eq_(res[5], self.root_path_cost) - eq_(bpdu.ConfigurationBPDUs._decode_bridge_id(res[6]), + self.assertEqual(res[5], self.root_path_cost) + self.assertEqual(bpdu.ConfigurationBPDUs._decode_bridge_id(res[6]), (self.bridge_priority, self.bridge_system_id_extension, self.bridge_mac_address)) - eq_(bpdu.ConfigurationBPDUs._decode_port_id(res[7]), + self.assertEqual(bpdu.ConfigurationBPDUs._decode_port_id(res[7]), (self.port_priority, self.port_number)) - eq_(bpdu.ConfigurationBPDUs._decode_timer(res[8]), self.message_age) - eq_(bpdu.ConfigurationBPDUs._decode_timer(res[9]), self.max_age) - eq_(bpdu.ConfigurationBPDUs._decode_timer(res[10]), self.hello_time) - eq_(bpdu.ConfigurationBPDUs._decode_timer(res[11]), self.forward_delay) + self.assertEqual(bpdu.ConfigurationBPDUs._decode_timer(res[8]), self.message_age) + self.assertEqual(bpdu.ConfigurationBPDUs._decode_timer(res[9]), self.max_age) + self.assertEqual(bpdu.ConfigurationBPDUs._decode_timer(res[10]), self.hello_time) + self.assertEqual(bpdu.ConfigurationBPDUs._decode_timer(res[11]), self.forward_delay) def test_json(self): jsondict = self.msg.to_jsondict() msg = bpdu.ConfigurationBPDUs.from_jsondict( jsondict['ConfigurationBPDUs']) - eq_(str(self.msg), str(msg)) + self.assertEqual(str(self.msg), str(msg)) class Test_TopologyChangeNotificationBPDUs(unittest.TestCase): @@ -187,18 +186,18 @@ class Test_TopologyChangeNotificationBPDUs(unittest.TestCase): self.bpdu_type) def test_init(self): - eq_(self.protocol_id, self.msg._protocol_id) - eq_(self.version_id, self.msg._version_id) - eq_(self.bpdu_type, self.msg._bpdu_type) + self.assertEqual(self.protocol_id, self.msg._protocol_id) + self.assertEqual(self.version_id, self.msg._version_id) + self.assertEqual(self.bpdu_type, self.msg._bpdu_type) def test_parser(self): r1, r2, _ = bpdu.bpdu.parser(self.buf) - eq_(type(r1), type(self.msg)) - eq_(r1._protocol_id, self.protocol_id) - eq_(r1._version_id, self.version_id) - eq_(r1._bpdu_type, self.bpdu_type) - eq_(r2, None) + self.assertEqual(type(r1), type(self.msg)) + self.assertEqual(r1._protocol_id, self.protocol_id) + self.assertEqual(r1._version_id, self.version_id) + self.assertEqual(r1._bpdu_type, self.bpdu_type) + self.assertEqual(r2, None) def test_serialize(self): data = bytearray() @@ -206,15 +205,15 @@ class Test_TopologyChangeNotificationBPDUs(unittest.TestCase): buf = self.msg.serialize(data, prev) res = struct.unpack(self.fmt, buf) - eq_(res[0], self.protocol_id) - eq_(res[1], self.version_id) - eq_(res[2], self.bpdu_type) + self.assertEqual(res[0], self.protocol_id) + self.assertEqual(res[1], self.version_id) + self.assertEqual(res[2], self.bpdu_type) def test_json(self): jsondict = self.msg.to_jsondict() msg = bpdu.TopologyChangeNotificationBPDUs.from_jsondict( jsondict['TopologyChangeNotificationBPDUs']) - eq_(str(self.msg), str(msg)) + self.assertEqual(str(self.msg), str(msg)) class Test_RstBPDUs(unittest.TestCase): @@ -282,50 +281,50 @@ class Test_RstBPDUs(unittest.TestCase): self.version_1_length) def test_init(self): - eq_(self.protocol_id, self.msg._protocol_id) - eq_(self.version_id, self.msg._version_id) - eq_(self.bpdu_type, self.msg._bpdu_type) - eq_(self.flags, self.msg.flags) - eq_(self.root_priority, self.msg.root_priority) - eq_(self.root_system_id_extension, + self.assertEqual(self.protocol_id, self.msg._protocol_id) + self.assertEqual(self.version_id, self.msg._version_id) + self.assertEqual(self.bpdu_type, self.msg._bpdu_type) + self.assertEqual(self.flags, self.msg.flags) + self.assertEqual(self.root_priority, self.msg.root_priority) + self.assertEqual(self.root_system_id_extension, self.msg.root_system_id_extension) - eq_(self.root_mac_address, self.msg.root_mac_address) - eq_(self.root_path_cost, self.msg.root_path_cost) - eq_(self.bridge_priority, self.msg.bridge_priority) - eq_(self.bridge_system_id_extension, + self.assertEqual(self.root_mac_address, self.msg.root_mac_address) + self.assertEqual(self.root_path_cost, self.msg.root_path_cost) + self.assertEqual(self.bridge_priority, self.msg.bridge_priority) + self.assertEqual(self.bridge_system_id_extension, self.msg.bridge_system_id_extension) - eq_(self.bridge_mac_address, self.msg.bridge_mac_address) - eq_(self.port_priority, self.msg.port_priority) - eq_(self.port_number, self.msg.port_number) - eq_(self.message_age, self.msg.message_age) - eq_(self.max_age, self.msg.max_age) - eq_(self.hello_time, self.msg.hello_time) - eq_(self.forward_delay, self.msg.forward_delay) - eq_(self.version_1_length, self.msg._version_1_length) + self.assertEqual(self.bridge_mac_address, self.msg.bridge_mac_address) + self.assertEqual(self.port_priority, self.msg.port_priority) + self.assertEqual(self.port_number, self.msg.port_number) + self.assertEqual(self.message_age, self.msg.message_age) + self.assertEqual(self.max_age, self.msg.max_age) + self.assertEqual(self.hello_time, self.msg.hello_time) + self.assertEqual(self.forward_delay, self.msg.forward_delay) + self.assertEqual(self.version_1_length, self.msg._version_1_length) def test_parser(self): r1, r2, _ = bpdu.bpdu.parser(self.buf) - eq_(type(r1), type(self.msg)) - eq_(r1._protocol_id, self.protocol_id) - eq_(r1._version_id, self.version_id) - eq_(r1._bpdu_type, self.bpdu_type) - eq_(r1.flags, self.flags) - eq_(r1.root_priority, self.root_priority) - eq_(r1.root_system_id_extension, self.root_system_id_extension) - eq_(r1.root_mac_address, self.root_mac_address) - eq_(r1.root_path_cost, self.root_path_cost) - eq_(r1.bridge_priority, self.bridge_priority) - eq_(r1.bridge_system_id_extension, self.bridge_system_id_extension) - eq_(r1.bridge_mac_address, self.bridge_mac_address) - eq_(r1.port_priority, self.port_priority) - eq_(r1.port_number, self.port_number) - eq_(r1.message_age, self.message_age) - eq_(r1.max_age, self.max_age) - eq_(r1.hello_time, self.hello_time) - eq_(r1.forward_delay, self.forward_delay) - eq_(r1._version_1_length, self.version_1_length) - eq_(r2, None) + self.assertEqual(type(r1), type(self.msg)) + self.assertEqual(r1._protocol_id, self.protocol_id) + self.assertEqual(r1._version_id, self.version_id) + self.assertEqual(r1._bpdu_type, self.bpdu_type) + self.assertEqual(r1.flags, self.flags) + self.assertEqual(r1.root_priority, self.root_priority) + self.assertEqual(r1.root_system_id_extension, self.root_system_id_extension) + self.assertEqual(r1.root_mac_address, self.root_mac_address) + self.assertEqual(r1.root_path_cost, self.root_path_cost) + self.assertEqual(r1.bridge_priority, self.bridge_priority) + self.assertEqual(r1.bridge_system_id_extension, self.bridge_system_id_extension) + self.assertEqual(r1.bridge_mac_address, self.bridge_mac_address) + self.assertEqual(r1.port_priority, self.port_priority) + self.assertEqual(r1.port_number, self.port_number) + self.assertEqual(r1.message_age, self.message_age) + self.assertEqual(r1.max_age, self.max_age) + self.assertEqual(r1.hello_time, self.hello_time) + self.assertEqual(r1.forward_delay, self.forward_delay) + self.assertEqual(r1._version_1_length, self.version_1_length) + self.assertEqual(r2, None) def test_serialize(self): data = bytearray() @@ -333,32 +332,32 @@ class Test_RstBPDUs(unittest.TestCase): buf = self.msg.serialize(data, prev) res = struct.unpack(self.fmt, buf) - eq_(res[0], self.protocol_id) - eq_(res[1], self.version_id) - eq_(res[2], self.bpdu_type) - eq_(res[3], self.flags) - eq_(bpdu.RstBPDUs._decode_bridge_id(res[4]), + self.assertEqual(res[0], self.protocol_id) + self.assertEqual(res[1], self.version_id) + self.assertEqual(res[2], self.bpdu_type) + self.assertEqual(res[3], self.flags) + self.assertEqual(bpdu.RstBPDUs._decode_bridge_id(res[4]), (self.root_priority, self.root_system_id_extension, self.root_mac_address)) - eq_(res[5], self.root_path_cost) - eq_(bpdu.RstBPDUs._decode_bridge_id(res[6]), + self.assertEqual(res[5], self.root_path_cost) + self.assertEqual(bpdu.RstBPDUs._decode_bridge_id(res[6]), (self.bridge_priority, self.bridge_system_id_extension, self.bridge_mac_address)) - eq_(bpdu.RstBPDUs._decode_port_id(res[7]), + self.assertEqual(bpdu.RstBPDUs._decode_port_id(res[7]), (self.port_priority, self.port_number)) - eq_(bpdu.RstBPDUs._decode_timer(res[8]), self.message_age) - eq_(bpdu.RstBPDUs._decode_timer(res[9]), self.max_age) - eq_(bpdu.RstBPDUs._decode_timer(res[10]), self.hello_time) - eq_(bpdu.RstBPDUs._decode_timer(res[11]), self.forward_delay) - eq_(res[12], self.version_1_length) + self.assertEqual(bpdu.RstBPDUs._decode_timer(res[8]), self.message_age) + self.assertEqual(bpdu.RstBPDUs._decode_timer(res[9]), self.max_age) + self.assertEqual(bpdu.RstBPDUs._decode_timer(res[10]), self.hello_time) + self.assertEqual(bpdu.RstBPDUs._decode_timer(res[11]), self.forward_delay) + self.assertEqual(res[12], self.version_1_length) def test_json(self): jsondict = self.msg.to_jsondict() msg = bpdu.RstBPDUs.from_jsondict(jsondict['RstBPDUs']) - eq_(str(self.msg), str(msg)) + self.assertEqual(str(self.msg), str(msg)) class Test_UnknownVersion(unittest.TestCase): @@ -411,8 +410,8 @@ class Test_UnknownVersion(unittest.TestCase): def test_parser(self): r1, r2, _ = bpdu.bpdu.parser(self.buf) - eq_(r1, self.buf) - eq_(r2, None) + self.assertEqual(r1, self.buf) + self.assertEqual(r2, None) class Test_UnknownType(unittest.TestCase): @@ -465,5 +464,5 @@ class Test_UnknownType(unittest.TestCase): def test_parser(self): r1, r2, _ = bpdu.bpdu.parser(self.buf) - eq_(r1, self.buf) - eq_(r2, None) + self.assertEqual(r1, self.buf) + self.assertEqual(r2, None) diff --git a/os_ken/tests/unit/packet/test_cfm.py b/os_ken/tests/unit/packet/test_cfm.py index ffc11d9b..dc1bc0bb 100644 --- a/os_ken/tests/unit/packet/test_cfm.py +++ b/os_ken/tests/unit/packet/test_cfm.py @@ -20,7 +20,6 @@ import inspect import six import struct -from nose.tools import * from os_ken.lib import addrconv from os_ken.lib.packet import cfm @@ -205,7 +204,7 @@ class Test_cfm(unittest.TestCase): pass def test_init(self): - eq_(str(self.message), str(self.ins.op)) + self.assertEqual(str(self.message), str(self.ins.op)) def test_init_cc_message(self): self.setUp_cc_message() @@ -234,7 +233,7 @@ class Test_cfm(unittest.TestCase): res = _res[0] else: res = _res - eq_(str(self.message), str(res.op)) + self.assertEqual(str(self.message), str(res.op)) def test_parser_with_cc_message(self): self.setUp_cc_message() @@ -266,7 +265,7 @@ class Test_cfm(unittest.TestCase): prev = None buf = self.ins.serialize(data, prev) cc_message = cfm.cc_message.parser(six.binary_type(buf)) - eq_(repr(self.message), repr(cc_message)) + self.assertEqual(repr(self.message), repr(cc_message)) def test_serialize_with_loopback_message(self): self.setUp_loopback_message() @@ -275,7 +274,7 @@ class Test_cfm(unittest.TestCase): prev = None buf = self.ins.serialize(data, prev) loopback_message = cfm.loopback_message.parser(six.binary_type(buf)) - eq_(repr(self.message), repr(loopback_message)) + self.assertEqual(repr(self.message), repr(loopback_message)) def test_serialize_with_loopback_reply(self): self.setUp_loopback_reply() @@ -284,7 +283,7 @@ class Test_cfm(unittest.TestCase): prev = None buf = self.ins.serialize(data, prev) loopback_reply = cfm.loopback_reply.parser(six.binary_type(buf)) - eq_(repr(self.message), repr(loopback_reply)) + self.assertEqual(repr(self.message), repr(loopback_reply)) def test_serialize_with_link_trace_message(self): self.setUp_link_trace_message() @@ -293,7 +292,7 @@ class Test_cfm(unittest.TestCase): prev = None buf = self.ins.serialize(data, prev) link_trace_message = cfm.link_trace_message.parser(six.binary_type(buf)) - eq_(repr(self.message), repr(link_trace_message)) + self.assertEqual(repr(self.message), repr(link_trace_message)) def test_serialize_with_link_trace_reply(self): self.setUp_link_trace_reply() @@ -302,7 +301,7 @@ class Test_cfm(unittest.TestCase): prev = None buf = self.ins.serialize(data, prev) link_trace_reply = cfm.link_trace_reply.parser(six.binary_type(buf)) - eq_(repr(self.message), repr(link_trace_reply)) + self.assertEqual(repr(self.message), repr(link_trace_reply)) def test_to_string(self): cfm_values = {'op': self.message} @@ -310,8 +309,8 @@ class Test_cfm(unittest.TestCase): for k, v in inspect.getmembers(self.ins) if k in cfm_values]) cfm_str = '%s(%s)' % (cfm.cfm.__name__, _cfm_str) - eq_(str(self.ins), cfm_str) - eq_(repr(self.ins), cfm_str) + self.assertEqual(str(self.ins), cfm_str) + self.assertEqual(repr(self.ins), cfm_str) def test_to_string_cc_message(self): self.setUp_cc_message() @@ -338,23 +337,23 @@ class Test_cfm(unittest.TestCase): def test_len_cc_message(self): self.setUp_cc_message() - eq_(len(self.ins), 0 + len(self.message)) + self.assertEqual(len(self.ins), 0 + len(self.message)) def test_len_loopback_message(self): self.setUp_loopback_message() - eq_(len(self.ins), 0 + len(self.message)) + self.assertEqual(len(self.ins), 0 + len(self.message)) def test_len_loopback_reply(self): self.setUp_loopback_reply() - eq_(len(self.ins), 0 + len(self.message)) + self.assertEqual(len(self.ins), 0 + len(self.message)) def test_len_link_trace_message(self): self.setUp_link_trace_message() - eq_(len(self.ins), 0 + len(self.message)) + self.assertEqual(len(self.ins), 0 + len(self.message)) def test_len_link_trace_reply(self): self.setUp_link_trace_reply() - eq_(len(self.ins), 0 + len(self.message)) + self.assertEqual(len(self.ins), 0 + len(self.message)) def test_default_args(self): pass @@ -362,7 +361,7 @@ class Test_cfm(unittest.TestCase): def test_json(self): jsondict = self.ins.to_jsondict() ins = cfm.cfm.from_jsondict(jsondict['cfm']) - eq_(str(self.ins), str(ins)) + self.assertEqual(str(self.ins), str(ins)) def test_json_with_cc_message(self): self.setUp_cc_message() @@ -443,19 +442,19 @@ class Test_cc_message(unittest.TestCase): pass def test_init(self): - eq_(self.md_lv, self.ins.md_lv) - eq_(self.version, self.ins.version) - eq_(self.rdi, self.ins.rdi) - eq_(self.interval, self.ins.interval) - eq_(self.seq_num, self.ins.seq_num) - eq_(self.mep_id, self.ins.mep_id) - eq_(self.md_name_format, self.ins.md_name_format) - eq_(self.md_name_length, self.ins.md_name_length) - eq_(self.md_name, self.ins.md_name) - eq_(self.short_ma_name_format, self.ins.short_ma_name_format) - eq_(self.short_ma_name_length, self.ins.short_ma_name_length) - eq_(self.short_ma_name, self.ins.short_ma_name) - eq_(self.tlvs, self.ins.tlvs) + self.assertEqual(self.md_lv, self.ins.md_lv) + self.assertEqual(self.version, self.ins.version) + self.assertEqual(self.rdi, self.ins.rdi) + self.assertEqual(self.interval, self.ins.interval) + self.assertEqual(self.seq_num, self.ins.seq_num) + self.assertEqual(self.mep_id, self.ins.mep_id) + self.assertEqual(self.md_name_format, self.ins.md_name_format) + self.assertEqual(self.md_name_length, self.ins.md_name_length) + self.assertEqual(self.md_name, self.ins.md_name) + self.assertEqual(self.short_ma_name_format, self.ins.short_ma_name_format) + self.assertEqual(self.short_ma_name_length, self.ins.short_ma_name_length) + self.assertEqual(self.short_ma_name, self.ins.short_ma_name) + self.assertEqual(self.tlvs, self.ins.tlvs) def test_parser(self): _res = cfm.cc_message.parser(self.buf) @@ -463,19 +462,19 @@ class Test_cc_message(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.md_lv, res.md_lv) - eq_(self.version, res.version) - eq_(self.rdi, res.rdi) - eq_(self.interval, res.interval) - eq_(self.seq_num, res.seq_num) - eq_(self.mep_id, res.mep_id) - eq_(self.md_name_format, res.md_name_format) - eq_(self.md_name_length, res.md_name_length) - eq_(self.md_name, res.md_name) - eq_(self.short_ma_name_format, res.short_ma_name_format) - eq_(self.short_ma_name_length, res.short_ma_name_length) - eq_(self.short_ma_name, res.short_ma_name) - eq_(self.tlvs, res.tlvs) + self.assertEqual(self.md_lv, res.md_lv) + self.assertEqual(self.version, res.version) + self.assertEqual(self.rdi, res.rdi) + self.assertEqual(self.interval, res.interval) + self.assertEqual(self.seq_num, res.seq_num) + self.assertEqual(self.mep_id, res.mep_id) + self.assertEqual(self.md_name_format, res.md_name_format) + self.assertEqual(self.md_name_length, res.md_name_length) + self.assertEqual(self.md_name, res.md_name) + self.assertEqual(self.short_ma_name_format, res.short_ma_name_format) + self.assertEqual(self.short_ma_name_length, res.short_ma_name_length) + self.assertEqual(self.short_ma_name, res.short_ma_name) + self.assertEqual(self.tlvs, res.tlvs) def test_parser_with_no_maintenance_domain_name_present(self): form = '!4BIH3B8s37x12x4xB' @@ -498,36 +497,36 @@ class Test_cc_message(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.md_lv, res.md_lv) - eq_(self.version, res.version) - eq_(self.rdi, res.rdi) - eq_(self.interval, res.interval) - eq_(self.seq_num, res.seq_num) - eq_(self.mep_id, res.mep_id) - eq_(cfm.cc_message._MD_FMT_NO_MD_NAME_PRESENT, res.md_name_format) - eq_(self.short_ma_name_format, res.short_ma_name_format) - eq_(self.short_ma_name_length, res.short_ma_name_length) - eq_(self.short_ma_name, res.short_ma_name) - eq_(self.tlvs, res.tlvs) + self.assertEqual(self.md_lv, res.md_lv) + self.assertEqual(self.version, res.version) + self.assertEqual(self.rdi, res.rdi) + self.assertEqual(self.interval, res.interval) + self.assertEqual(self.seq_num, res.seq_num) + self.assertEqual(self.mep_id, res.mep_id) + self.assertEqual(cfm.cc_message._MD_FMT_NO_MD_NAME_PRESENT, res.md_name_format) + self.assertEqual(self.short_ma_name_format, res.short_ma_name_format) + self.assertEqual(self.short_ma_name_length, res.short_ma_name_length) + self.assertEqual(self.short_ma_name, res.short_ma_name) + self.assertEqual(self.tlvs, res.tlvs) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.md_lv, res[0] >> 5) - eq_(self.version, res[0] & 0x1f) - eq_(self.opcode, res[1]) - eq_(self.rdi, res[2] >> 7) - eq_(self.interval, res[2] & 0x07) - eq_(self.first_tlv_offset, res[3]) - eq_(self.seq_num, res[4]) - eq_(self.mep_id, res[5]) - eq_(self.md_name_format, res[6]) - eq_(self.md_name_length, res[7]) - eq_(self.md_name, res[8]) - eq_(self.short_ma_name_format, res[9]) - eq_(self.short_ma_name_length, res[10]) - eq_(self.short_ma_name, res[11]) - eq_(self.end_tlv, res[12]) + self.assertEqual(self.md_lv, res[0] >> 5) + self.assertEqual(self.version, res[0] & 0x1f) + self.assertEqual(self.opcode, res[1]) + self.assertEqual(self.rdi, res[2] >> 7) + self.assertEqual(self.interval, res[2] & 0x07) + self.assertEqual(self.first_tlv_offset, res[3]) + self.assertEqual(self.seq_num, res[4]) + self.assertEqual(self.mep_id, res[5]) + self.assertEqual(self.md_name_format, res[6]) + self.assertEqual(self.md_name_length, res[7]) + self.assertEqual(self.md_name, res[8]) + self.assertEqual(self.short_ma_name_format, res[9]) + self.assertEqual(self.short_ma_name_length, res[10]) + self.assertEqual(self.short_ma_name, res[11]) + self.assertEqual(self.end_tlv, res[12]) def test_serialize_with_md_name_length_zero(self): ins = cfm.cc_message( @@ -547,21 +546,21 @@ class Test_cc_message(unittest.TestCase): ) buf = ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.md_lv, res[0] >> 5) - eq_(self.version, res[0] & 0x1f) - eq_(self.opcode, res[1]) - eq_(self.rdi, res[2] >> 7) - eq_(self.interval, res[2] & 0x07) - eq_(self.first_tlv_offset, res[3]) - eq_(self.seq_num, res[4]) - eq_(self.mep_id, res[5]) - eq_(self.md_name_format, res[6]) - eq_(self.md_name_length, res[7]) - eq_(self.md_name, res[8]) - eq_(self.short_ma_name_format, res[9]) - eq_(self.short_ma_name_length, res[10]) - eq_(self.short_ma_name, res[11]) - eq_(self.end_tlv, res[12]) + self.assertEqual(self.md_lv, res[0] >> 5) + self.assertEqual(self.version, res[0] & 0x1f) + self.assertEqual(self.opcode, res[1]) + self.assertEqual(self.rdi, res[2] >> 7) + self.assertEqual(self.interval, res[2] & 0x07) + self.assertEqual(self.first_tlv_offset, res[3]) + self.assertEqual(self.seq_num, res[4]) + self.assertEqual(self.mep_id, res[5]) + self.assertEqual(self.md_name_format, res[6]) + self.assertEqual(self.md_name_length, res[7]) + self.assertEqual(self.md_name, res[8]) + self.assertEqual(self.short_ma_name_format, res[9]) + self.assertEqual(self.short_ma_name_length, res[10]) + self.assertEqual(self.short_ma_name, res[11]) + self.assertEqual(self.end_tlv, res[12]) def test_serialize_with_no_maintenance_domain_name_present(self): form = '!4BIH3B8s37x12x4xB' @@ -582,37 +581,37 @@ class Test_cc_message(unittest.TestCase): ) buf = ins.serialize() res = struct.unpack_from(form, six.binary_type(buf)) - eq_(self.md_lv, res[0] >> 5) - eq_(self.version, res[0] & 0x1f) - eq_(self.opcode, res[1]) - eq_(self.rdi, res[2] >> 7) - eq_(self.interval, res[2] & 0x07) - eq_(self.first_tlv_offset, res[3]) - eq_(self.seq_num, res[4]) - eq_(self.mep_id, res[5]) - eq_(cfm.cc_message._MD_FMT_NO_MD_NAME_PRESENT, res[6]) - eq_(self.short_ma_name_format, res[7]) - eq_(self.short_ma_name_length, res[8]) - eq_(self.short_ma_name, res[9]) - eq_(self.end_tlv, res[10]) + self.assertEqual(self.md_lv, res[0] >> 5) + self.assertEqual(self.version, res[0] & 0x1f) + self.assertEqual(self.opcode, res[1]) + self.assertEqual(self.rdi, res[2] >> 7) + self.assertEqual(self.interval, res[2] & 0x07) + self.assertEqual(self.first_tlv_offset, res[3]) + self.assertEqual(self.seq_num, res[4]) + self.assertEqual(self.mep_id, res[5]) + self.assertEqual(cfm.cc_message._MD_FMT_NO_MD_NAME_PRESENT, res[6]) + self.assertEqual(self.short_ma_name_format, res[7]) + self.assertEqual(self.short_ma_name_length, res[8]) + self.assertEqual(self.short_ma_name, res[9]) + self.assertEqual(self.end_tlv, res[10]) def test_len(self): # 75 octet (If tlv does not exist) - eq_(75, len(self.ins)) + self.assertEqual(75, len(self.ins)) def test_default_args(self): ins = cfm.cc_message() buf = ins.serialize() res = struct.unpack_from(cfm.cc_message._PACK_STR, six.binary_type(buf)) - eq_(res[0] >> 5, 0) - eq_(res[0] & 0x1f, 0) - eq_(res[1], 1) - eq_(res[2] >> 7, 0) - eq_(res[2] & 0x07, 4) - eq_(res[3], 70) - eq_(res[4], 0) - eq_(res[5], 1) - eq_(res[6], 4) + self.assertEqual(res[0] >> 5, 0) + self.assertEqual(res[0] & 0x1f, 0) + self.assertEqual(res[1], 1) + self.assertEqual(res[2] >> 7, 0) + self.assertEqual(res[2] & 0x07, 4) + self.assertEqual(res[3], 70) + self.assertEqual(res[4], 0) + self.assertEqual(res[5], 1) + self.assertEqual(res[6], 4) class Test_loopback_message(unittest.TestCase): @@ -649,10 +648,10 @@ class Test_loopback_message(unittest.TestCase): pass def test_init(self): - eq_(self.md_lv, self.ins.md_lv) - eq_(self.version, self.ins.version) - eq_(self.transaction_id, self.ins.transaction_id) - eq_(self.tlvs, self.ins.tlvs) + self.assertEqual(self.md_lv, self.ins.md_lv) + self.assertEqual(self.version, self.ins.version) + self.assertEqual(self.transaction_id, self.ins.transaction_id) + self.assertEqual(self.tlvs, self.ins.tlvs) def test_parser(self): _res = cfm.loopback_message.parser(self.buf) @@ -660,37 +659,37 @@ class Test_loopback_message(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.md_lv, res.md_lv) - eq_(self.version, res.version) - eq_(self.transaction_id, res.transaction_id) - eq_(self.tlvs, res.tlvs) + self.assertEqual(self.md_lv, res.md_lv) + self.assertEqual(self.version, res.version) + self.assertEqual(self.transaction_id, res.transaction_id) + self.assertEqual(self.tlvs, res.tlvs) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.md_lv, res[0] >> 5) - eq_(self.version, res[0] & 0x1f) - eq_(self.opcode, res[1]) - eq_(self.flags, res[2]) - eq_(self.first_tlv_offset, res[3]) - eq_(self.transaction_id, res[4]) - eq_(self.end_tlv, res[5]) + self.assertEqual(self.md_lv, res[0] >> 5) + self.assertEqual(self.version, res[0] & 0x1f) + self.assertEqual(self.opcode, res[1]) + self.assertEqual(self.flags, res[2]) + self.assertEqual(self.first_tlv_offset, res[3]) + self.assertEqual(self.transaction_id, res[4]) + self.assertEqual(self.end_tlv, res[5]) def test_len(self): # 9 octet (If tlv does not exist) - eq_(9, len(self.ins)) + self.assertEqual(9, len(self.ins)) def test_default_args(self): ins = cfm.loopback_message() buf = ins.serialize() res = struct.unpack_from(cfm.loopback_message._PACK_STR, six.binary_type(buf)) - eq_(res[0] >> 5, 0) - eq_(res[0] & 0x1f, 0) - eq_(res[1], 3) - eq_(res[2], 0) - eq_(res[3], 4) - eq_(res[4], 0) + self.assertEqual(res[0] >> 5, 0) + self.assertEqual(res[0] & 0x1f, 0) + self.assertEqual(res[1], 3) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 4) + self.assertEqual(res[4], 0) class Test_loopback_reply(unittest.TestCase): @@ -726,10 +725,10 @@ class Test_loopback_reply(unittest.TestCase): pass def test_init(self): - eq_(self.md_lv, self.ins.md_lv) - eq_(self.version, self.ins.version) - eq_(self.transaction_id, self.ins.transaction_id) - eq_(self.tlvs, self.ins.tlvs) + self.assertEqual(self.md_lv, self.ins.md_lv) + self.assertEqual(self.version, self.ins.version) + self.assertEqual(self.transaction_id, self.ins.transaction_id) + self.assertEqual(self.tlvs, self.ins.tlvs) def test_parser(self): _res = cfm.loopback_reply.parser(self.buf) @@ -737,36 +736,36 @@ class Test_loopback_reply(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.md_lv, res.md_lv) - eq_(self.version, res.version) - eq_(self.transaction_id, res.transaction_id) - eq_(self.tlvs, res.tlvs) + self.assertEqual(self.md_lv, res.md_lv) + self.assertEqual(self.version, res.version) + self.assertEqual(self.transaction_id, res.transaction_id) + self.assertEqual(self.tlvs, res.tlvs) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.md_lv, res[0] >> 5) - eq_(self.version, res[0] & 0x1f) - eq_(self.opcode, res[1]) - eq_(self.flags, res[2]) - eq_(self.first_tlv_offset, res[3]) - eq_(self.transaction_id, res[4]) - eq_(self.end_tlv, res[5]) + self.assertEqual(self.md_lv, res[0] >> 5) + self.assertEqual(self.version, res[0] & 0x1f) + self.assertEqual(self.opcode, res[1]) + self.assertEqual(self.flags, res[2]) + self.assertEqual(self.first_tlv_offset, res[3]) + self.assertEqual(self.transaction_id, res[4]) + self.assertEqual(self.end_tlv, res[5]) def test_len(self): # 9 octet (If tlv does not exist) - eq_(9, len(self.ins)) + self.assertEqual(9, len(self.ins)) def test_default_args(self): ins = cfm.loopback_reply() buf = ins.serialize() res = struct.unpack_from(cfm.loopback_reply._PACK_STR, six.binary_type(buf)) - eq_(res[0] >> 5, 0) - eq_(res[0] & 0x1f, 0) - eq_(res[1], 2) - eq_(res[2], 0) - eq_(res[3], 4) - eq_(res[4], 0) + self.assertEqual(res[0] >> 5, 0) + self.assertEqual(res[0] & 0x1f, 0) + self.assertEqual(res[1], 2) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 4) + self.assertEqual(res[4], 0) class Test_link_trace_message(unittest.TestCase): @@ -813,14 +812,14 @@ class Test_link_trace_message(unittest.TestCase): pass def test_init(self): - eq_(self.md_lv, self.ins.md_lv) - eq_(self.version, self.ins.version) - eq_(self.use_fdb_only, self.ins.use_fdb_only) - eq_(self.transaction_id, self.ins.transaction_id) - eq_(self.ttl, self.ins.ttl) - eq_(self.ltm_orig_addr, self.ins.ltm_orig_addr) - eq_(self.ltm_targ_addr, self.ins.ltm_targ_addr) - eq_(self.tlvs, self.ins.tlvs) + self.assertEqual(self.md_lv, self.ins.md_lv) + self.assertEqual(self.version, self.ins.version) + self.assertEqual(self.use_fdb_only, self.ins.use_fdb_only) + self.assertEqual(self.transaction_id, self.ins.transaction_id) + self.assertEqual(self.ttl, self.ins.ttl) + self.assertEqual(self.ltm_orig_addr, self.ins.ltm_orig_addr) + self.assertEqual(self.ltm_targ_addr, self.ins.ltm_targ_addr) + self.assertEqual(self.tlvs, self.ins.tlvs) def test_parser(self): _res = cfm.link_trace_message.parser(self.buf) @@ -828,46 +827,46 @@ class Test_link_trace_message(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.md_lv, res.md_lv) - eq_(self.version, res.version) - eq_(self.use_fdb_only, res.use_fdb_only) - eq_(self.transaction_id, res.transaction_id) - eq_(self.ttl, res.ttl) - eq_(self.ltm_orig_addr, res.ltm_orig_addr) - eq_(self.ltm_targ_addr, res.ltm_targ_addr) - eq_(self.tlvs, res.tlvs) + self.assertEqual(self.md_lv, res.md_lv) + self.assertEqual(self.version, res.version) + self.assertEqual(self.use_fdb_only, res.use_fdb_only) + self.assertEqual(self.transaction_id, res.transaction_id) + self.assertEqual(self.ttl, res.ttl) + self.assertEqual(self.ltm_orig_addr, res.ltm_orig_addr) + self.assertEqual(self.ltm_targ_addr, res.ltm_targ_addr) + self.assertEqual(self.tlvs, res.tlvs) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.md_lv, res[0] >> 5) - eq_(self.version, res[0] & 0x1f) - eq_(self.opcode, res[1]) - eq_(self.use_fdb_only, res[2] >> 7) - eq_(self.first_tlv_offset, res[3]) - eq_(self.transaction_id, res[4]) - eq_(self.ttl, res[5]) - eq_(addrconv.mac.text_to_bin(self.ltm_orig_addr), res[6]) - eq_(addrconv.mac.text_to_bin(self.ltm_targ_addr), res[7]) - eq_(self.end_tlv, res[8]) + self.assertEqual(self.md_lv, res[0] >> 5) + self.assertEqual(self.version, res[0] & 0x1f) + self.assertEqual(self.opcode, res[1]) + self.assertEqual(self.use_fdb_only, res[2] >> 7) + self.assertEqual(self.first_tlv_offset, res[3]) + self.assertEqual(self.transaction_id, res[4]) + self.assertEqual(self.ttl, res[5]) + self.assertEqual(addrconv.mac.text_to_bin(self.ltm_orig_addr), res[6]) + self.assertEqual(addrconv.mac.text_to_bin(self.ltm_targ_addr), res[7]) + self.assertEqual(self.end_tlv, res[8]) def test_len(self): # 22 octet (If tlv does not exist) - eq_(22, len(self.ins)) + self.assertEqual(22, len(self.ins)) def test_default_args(self): ins = cfm.link_trace_message() buf = ins.serialize() res = struct.unpack_from(cfm.link_trace_message._PACK_STR, six.binary_type(buf)) - eq_(res[0] >> 5, 0) - eq_(res[0] & 0x1f, 0) - eq_(res[1], 5) - eq_(res[2] >> 7, 1) - eq_(res[3], 17) - eq_(res[4], 0) - eq_(res[5], 64) - eq_(res[6], addrconv.mac.text_to_bin('00:00:00:00:00:00')) - eq_(res[7], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0] >> 5, 0) + self.assertEqual(res[0] & 0x1f, 0) + self.assertEqual(res[1], 5) + self.assertEqual(res[2] >> 7, 1) + self.assertEqual(res[3], 17) + self.assertEqual(res[4], 0) + self.assertEqual(res[5], 64) + self.assertEqual(res[6], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[7], addrconv.mac.text_to_bin('00:00:00:00:00:00')) class Test_link_trace_reply(unittest.TestCase): @@ -917,15 +916,15 @@ class Test_link_trace_reply(unittest.TestCase): pass def test_init(self): - eq_(self.md_lv, self.ins.md_lv) - eq_(self.version, self.ins.version) - eq_(self.use_fdb_only, self.ins.use_fdb_only) - eq_(self.fwd_yes, self.ins.fwd_yes) - eq_(self.terminal_mep, self.ins.terminal_mep) - eq_(self.transaction_id, self.ins.transaction_id) - eq_(self.ttl, self.ins.ttl) - eq_(self.relay_action, self.ins.relay_action) - eq_(self.tlvs, self.ins.tlvs) + self.assertEqual(self.md_lv, self.ins.md_lv) + self.assertEqual(self.version, self.ins.version) + self.assertEqual(self.use_fdb_only, self.ins.use_fdb_only) + self.assertEqual(self.fwd_yes, self.ins.fwd_yes) + self.assertEqual(self.terminal_mep, self.ins.terminal_mep) + self.assertEqual(self.transaction_id, self.ins.transaction_id) + self.assertEqual(self.ttl, self.ins.ttl) + self.assertEqual(self.relay_action, self.ins.relay_action) + self.assertEqual(self.tlvs, self.ins.tlvs) def test_parser(self): _res = cfm.link_trace_reply.parser(self.buf) @@ -933,49 +932,49 @@ class Test_link_trace_reply(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.md_lv, res.md_lv) - eq_(self.version, res.version) - eq_(self.use_fdb_only, self.ins.use_fdb_only) - eq_(self.fwd_yes, self.ins.fwd_yes) - eq_(self.terminal_mep, self.ins.terminal_mep) - eq_(self.transaction_id, res.transaction_id) - eq_(self.ttl, res.ttl) - eq_(self.relay_action, res.relay_action) - eq_(self.tlvs, res.tlvs) + self.assertEqual(self.md_lv, res.md_lv) + self.assertEqual(self.version, res.version) + self.assertEqual(self.use_fdb_only, self.ins.use_fdb_only) + self.assertEqual(self.fwd_yes, self.ins.fwd_yes) + self.assertEqual(self.terminal_mep, self.ins.terminal_mep) + self.assertEqual(self.transaction_id, res.transaction_id) + self.assertEqual(self.ttl, res.ttl) + self.assertEqual(self.relay_action, res.relay_action) + self.assertEqual(self.tlvs, res.tlvs) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.md_lv, res[0] >> 5) - eq_(self.version, res[0] & 0x1f) - eq_(self.opcode, res[1]) - eq_(self.use_fdb_only, res[2] >> 7 & 0x01) - eq_(self.fwd_yes, res[2] >> 6 & 0x01) - eq_(self.terminal_mep, res[2] >> 5 & 0x01) - eq_(self.first_tlv_offset, res[3]) - eq_(self.transaction_id, res[4]) - eq_(self.ttl, res[5]) - eq_(self.relay_action, res[6]) - eq_(self.end_tlv, res[7]) + self.assertEqual(self.md_lv, res[0] >> 5) + self.assertEqual(self.version, res[0] & 0x1f) + self.assertEqual(self.opcode, res[1]) + self.assertEqual(self.use_fdb_only, res[2] >> 7 & 0x01) + self.assertEqual(self.fwd_yes, res[2] >> 6 & 0x01) + self.assertEqual(self.terminal_mep, res[2] >> 5 & 0x01) + self.assertEqual(self.first_tlv_offset, res[3]) + self.assertEqual(self.transaction_id, res[4]) + self.assertEqual(self.ttl, res[5]) + self.assertEqual(self.relay_action, res[6]) + self.assertEqual(self.end_tlv, res[7]) def test_len(self): # 11 octet (If tlv does not exist) - eq_(11, len(self.ins)) + self.assertEqual(11, len(self.ins)) def test_default_args(self): ins = cfm.link_trace_reply() buf = ins.serialize() res = struct.unpack_from(cfm.link_trace_reply._PACK_STR, six.binary_type(buf)) - eq_(res[0] >> 5, 0) - eq_(res[0] & 0x1f, 0) - eq_(res[1], 4) - eq_(res[2] >> 7, 1) - eq_(res[2] >> 6 & 0x01, 0) - eq_(res[2] >> 5 & 0x01, 1) - eq_(res[3], 6) - eq_(res[4], 0) - eq_(res[5], 64) - eq_(res[6], 1) + self.assertEqual(res[0] >> 5, 0) + self.assertEqual(res[0] & 0x1f, 0) + self.assertEqual(res[1], 4) + self.assertEqual(res[2] >> 7, 1) + self.assertEqual(res[2] >> 6 & 0x01, 0) + self.assertEqual(res[2] >> 5 & 0x01, 1) + self.assertEqual(res[3], 6) + self.assertEqual(res[4], 0) + self.assertEqual(res[5], 64) + self.assertEqual(res[6], 1) class Test_sender_id_tlv(unittest.TestCase): @@ -1018,14 +1017,14 @@ class Test_sender_id_tlv(unittest.TestCase): pass def test_init(self): - eq_(self.length, self.ins.length) - eq_(self.chassis_id_length, self.ins.chassis_id_length) - eq_(self.chassis_id_subtype, self.ins.chassis_id_subtype) - eq_(self.chassis_id, self.ins.chassis_id) - eq_(self.ma_domain_length, self.ins.ma_domain_length) - eq_(self.ma_domain, self.ins.ma_domain) - eq_(self.ma_length, self.ins.ma_length) - eq_(self.ma, self.ins.ma) + self.assertEqual(self.length, self.ins.length) + self.assertEqual(self.chassis_id_length, self.ins.chassis_id_length) + self.assertEqual(self.chassis_id_subtype, self.ins.chassis_id_subtype) + self.assertEqual(self.chassis_id, self.ins.chassis_id) + self.assertEqual(self.ma_domain_length, self.ins.ma_domain_length) + self.assertEqual(self.ma_domain, self.ins.ma_domain) + self.assertEqual(self.ma_length, self.ins.ma_length) + self.assertEqual(self.ma, self.ins.ma) def test_parser(self): _res = cfm.sender_id_tlv.parser(self.buf) @@ -1033,27 +1032,27 @@ class Test_sender_id_tlv(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.length, res.length) - eq_(self.chassis_id_length, res.chassis_id_length) - eq_(self.chassis_id_subtype, res.chassis_id_subtype) - eq_(self.chassis_id, res.chassis_id) - eq_(self.ma_domain_length, res.ma_domain_length) - eq_(self.ma_domain, res.ma_domain) - eq_(self.ma_length, res.ma_length) - eq_(self.ma, res.ma) + self.assertEqual(self.length, res.length) + self.assertEqual(self.chassis_id_length, res.chassis_id_length) + self.assertEqual(self.chassis_id_subtype, res.chassis_id_subtype) + self.assertEqual(self.chassis_id, res.chassis_id) + self.assertEqual(self.ma_domain_length, res.ma_domain_length) + self.assertEqual(self.ma_domain, res.ma_domain) + self.assertEqual(self.ma_length, res.ma_length) + self.assertEqual(self.ma, res.ma) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.chassis_id_length, res[2]) - eq_(self.chassis_id_subtype, res[3]) - eq_(self.chassis_id, res[4]) - eq_(self.ma_domain_length, res[5]) - eq_(self.ma_domain, res[6]) - eq_(self.ma_length, res[7]) - eq_(self.ma, res[8]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.chassis_id_length, res[2]) + self.assertEqual(self.chassis_id_subtype, res[3]) + self.assertEqual(self.chassis_id, res[4]) + self.assertEqual(self.ma_domain_length, res[5]) + self.assertEqual(self.ma_domain, res[6]) + self.assertEqual(self.ma_length, res[7]) + self.assertEqual(self.ma, res[8]) def test_serialize_semi_normal_ptn1(self): ins = cfm.sender_id_tlv( @@ -1064,14 +1063,14 @@ class Test_sender_id_tlv(unittest.TestCase): buf = ins.serialize() form = '!BHBB1sB2sB' res = struct.unpack_from(form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(7, res[1]) - eq_(self.chassis_id_length, res[2]) - eq_(self.chassis_id_subtype, res[3]) - eq_(self.chassis_id, res[4]) - eq_(self.ma_domain_length, res[5]) - eq_(self.ma_domain, res[6]) - eq_(0, res[7]) + self.assertEqual(self._type, res[0]) + self.assertEqual(7, res[1]) + self.assertEqual(self.chassis_id_length, res[2]) + self.assertEqual(self.chassis_id_subtype, res[3]) + self.assertEqual(self.chassis_id, res[4]) + self.assertEqual(self.ma_domain_length, res[5]) + self.assertEqual(self.ma_domain, res[6]) + self.assertEqual(0, res[7]) def test_serialize_semi_normal_ptn2(self): ins = cfm.sender_id_tlv( @@ -1081,13 +1080,13 @@ class Test_sender_id_tlv(unittest.TestCase): buf = ins.serialize() form = '!BHBB2sB3s' res = struct.unpack_from(form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(8, res[1]) - eq_(0, res[2]) - eq_(self.ma_domain_length, res[3]) - eq_(self.ma_domain, res[4]) - eq_(self.ma_length, res[5]) - eq_(self.ma, res[6]) + self.assertEqual(self._type, res[0]) + self.assertEqual(8, res[1]) + self.assertEqual(0, res[2]) + self.assertEqual(self.ma_domain_length, res[3]) + self.assertEqual(self.ma_domain, res[4]) + self.assertEqual(self.ma_length, res[5]) + self.assertEqual(self.ma, res[6]) def test_serialize_semi_normal_ptn3(self): ins = cfm.sender_id_tlv( @@ -1097,12 +1096,12 @@ class Test_sender_id_tlv(unittest.TestCase): buf = ins.serialize() form = '!BHBB1sB' res = struct.unpack_from(form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(4, res[1]) - eq_(self.chassis_id_length, res[2]) - eq_(self.chassis_id_subtype, res[3]) - eq_(self.chassis_id, res[4]) - eq_(0, res[5]) + self.assertEqual(self._type, res[0]) + self.assertEqual(4, res[1]) + self.assertEqual(self.chassis_id_length, res[2]) + self.assertEqual(self.chassis_id_subtype, res[3]) + self.assertEqual(self.chassis_id, res[4]) + self.assertEqual(0, res[5]) def test_serialize_semi_normal_ptn4(self): ins = cfm.sender_id_tlv( @@ -1111,12 +1110,12 @@ class Test_sender_id_tlv(unittest.TestCase): buf = ins.serialize() form = '!BHBB2sB' res = struct.unpack_from(form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(5, res[1]) - eq_(0, res[2]) - eq_(self.ma_domain_length, res[3]) - eq_(self.ma_domain, res[4]) - eq_(0, res[5]) + self.assertEqual(self._type, res[0]) + self.assertEqual(5, res[1]) + self.assertEqual(0, res[2]) + self.assertEqual(self.ma_domain_length, res[3]) + self.assertEqual(self.ma_domain, res[4]) + self.assertEqual(0, res[5]) def test_serialize_with_length_zero(self): ins = cfm.sender_id_tlv( @@ -1131,27 +1130,27 @@ class Test_sender_id_tlv(unittest.TestCase): ) buf = ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.chassis_id_length, res[2]) - eq_(self.chassis_id_subtype, res[3]) - eq_(self.chassis_id, res[4]) - eq_(self.ma_domain_length, res[5]) - eq_(self.ma_domain, res[6]) - eq_(self.ma_length, res[7]) - eq_(self.ma, res[8]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.chassis_id_length, res[2]) + self.assertEqual(self.chassis_id_subtype, res[3]) + self.assertEqual(self.chassis_id, res[4]) + self.assertEqual(self.ma_domain_length, res[5]) + self.assertEqual(self.ma_domain, res[6]) + self.assertEqual(self.ma_length, res[7]) + self.assertEqual(self.ma, res[8]) def test_len(self): # tlv_length = type_len + length_len + value_len - eq_(1 + 2 + 10, len(self.ins)) + self.assertEqual(1 + 2 + 10, len(self.ins)) def test_default_args(self): ins = cfm.sender_id_tlv() buf = ins.serialize() res = struct.unpack_from(cfm.sender_id_tlv._PACK_STR, six.binary_type(buf)) - eq_(res[0], cfm.CFM_SENDER_ID_TLV) - eq_(res[1], 1) - eq_(res[2], 0) + self.assertEqual(res[0], cfm.CFM_SENDER_ID_TLV) + self.assertEqual(res[1], 1) + self.assertEqual(res[2], 0) class Test_port_status_tlv(unittest.TestCase): @@ -1176,8 +1175,8 @@ class Test_port_status_tlv(unittest.TestCase): pass def test_init(self): - eq_(self.length, self.ins.length) - eq_(self.port_status, self.ins.port_status) + self.assertEqual(self.length, self.ins.length) + self.assertEqual(self.port_status, self.ins.port_status) def test_parser(self): _res = cfm.port_status_tlv.parser(self.buf) @@ -1185,27 +1184,27 @@ class Test_port_status_tlv(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.length, res.length) - eq_(self.port_status, res.port_status) + self.assertEqual(self.length, res.length) + self.assertEqual(self.port_status, res.port_status) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.port_status, res[2]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.port_status, res[2]) def test_len(self): # tlv_length = type_len + length_len + value_len - eq_(1 + 2 + 1, len(self.ins)) + self.assertEqual(1 + 2 + 1, len(self.ins)) def test_default_args(self): ins = cfm.port_status_tlv() buf = ins.serialize() res = struct.unpack_from(cfm.port_status_tlv._PACK_STR, six.binary_type(buf)) - eq_(res[0], cfm.CFM_PORT_STATUS_TLV) - eq_(res[1], 1) - eq_(res[2], 2) + self.assertEqual(res[0], cfm.CFM_PORT_STATUS_TLV) + self.assertEqual(res[1], 1) + self.assertEqual(res[2], 2) class Test_data_tlv(unittest.TestCase): @@ -1230,8 +1229,8 @@ class Test_data_tlv(unittest.TestCase): pass def test_init(self): - eq_(self.length, self.ins.length) - eq_(self.data_value, self.ins.data_value) + self.assertEqual(self.length, self.ins.length) + self.assertEqual(self.data_value, self.ins.data_value) def test_parser(self): _res = cfm.data_tlv.parser(self.buf) @@ -1239,15 +1238,15 @@ class Test_data_tlv(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.length, res.length) - eq_(self.data_value, res.data_value) + self.assertEqual(self.length, res.length) + self.assertEqual(self.data_value, res.data_value) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.data_value, res[2]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.data_value, res[2]) def test_serialize_with_length_zero(self): ins = cfm.data_tlv( @@ -1256,20 +1255,20 @@ class Test_data_tlv(unittest.TestCase): ) buf = ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.data_value, res[2]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.data_value, res[2]) def test_len(self): # tlv_length = type_len + length_len + value_len - eq_(1 + 2 + 3, len(self.ins)) + self.assertEqual(1 + 2 + 3, len(self.ins)) def test_default_args(self): ins = cfm.data_tlv() buf = ins.serialize() res = struct.unpack_from(cfm.data_tlv._PACK_STR, six.binary_type(buf)) - eq_(res[0], cfm.CFM_DATA_TLV) - eq_(res[1], 0) + self.assertEqual(res[0], cfm.CFM_DATA_TLV) + self.assertEqual(res[1], 0) class Test_interface_status_tlv(unittest.TestCase): @@ -1294,8 +1293,8 @@ class Test_interface_status_tlv(unittest.TestCase): pass def test_init(self): - eq_(self.length, self.ins.length) - eq_(self.interface_status, self.ins.interface_status) + self.assertEqual(self.length, self.ins.length) + self.assertEqual(self.interface_status, self.ins.interface_status) def test_parser(self): _res = cfm.interface_status_tlv.parser(self.buf) @@ -1303,27 +1302,27 @@ class Test_interface_status_tlv(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.length, res.length) - eq_(self.interface_status, res.interface_status) + self.assertEqual(self.length, res.length) + self.assertEqual(self.interface_status, res.interface_status) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.interface_status, res[2]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.interface_status, res[2]) def test_len(self): # tlv_length = type_len + length_len + value_len - eq_(1 + 2 + 1, len(self.ins)) + self.assertEqual(1 + 2 + 1, len(self.ins)) def test_default_args(self): ins = cfm.interface_status_tlv() buf = ins.serialize() res = struct.unpack_from(cfm.interface_status_tlv._PACK_STR, six.binary_type(buf)) - eq_(res[0], cfm.CFM_INTERFACE_STATUS_TLV) - eq_(res[1], 1) - eq_(res[2], 1) + self.assertEqual(res[0], cfm.CFM_INTERFACE_STATUS_TLV) + self.assertEqual(res[1], 1) + self.assertEqual(res[2], 1) class Test_ltm_egress_identifier_tlv(unittest.TestCase): @@ -1351,9 +1350,9 @@ class Test_ltm_egress_identifier_tlv(unittest.TestCase): pass def test_init(self): - eq_(self.length, self.ins.length) - eq_(self.egress_id_ui, self.ins.egress_id_ui) - eq_(self.egress_id_mac, self.ins.egress_id_mac) + self.assertEqual(self.length, self.ins.length) + self.assertEqual(self.egress_id_ui, self.ins.egress_id_ui) + self.assertEqual(self.egress_id_mac, self.ins.egress_id_mac) def test_parser(self): _res = cfm.ltm_egress_identifier_tlv.parser(self.buf) @@ -1361,17 +1360,17 @@ class Test_ltm_egress_identifier_tlv(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.length, res.length) - eq_(self.egress_id_ui, res.egress_id_ui) - eq_(self.egress_id_mac, res.egress_id_mac) + self.assertEqual(self.length, res.length) + self.assertEqual(self.egress_id_ui, res.egress_id_ui) + self.assertEqual(self.egress_id_mac, res.egress_id_mac) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.egress_id_ui, res[2]) - eq_(addrconv.mac.text_to_bin(self.egress_id_mac), res[3]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.egress_id_ui, res[2]) + self.assertEqual(addrconv.mac.text_to_bin(self.egress_id_mac), res[3]) def test_serialize_with_length_zero(self): ins = cfm.ltm_egress_identifier_tlv( @@ -1381,24 +1380,24 @@ class Test_ltm_egress_identifier_tlv(unittest.TestCase): ) buf = ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.egress_id_ui, res[2]) - eq_(addrconv.mac.text_to_bin(self.egress_id_mac), res[3]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.egress_id_ui, res[2]) + self.assertEqual(addrconv.mac.text_to_bin(self.egress_id_mac), res[3]) def test_len(self): # tlv_length = type_len + length_len + value_len - eq_(1 + 2 + 8, len(self.ins)) + self.assertEqual(1 + 2 + 8, len(self.ins)) def test_default_args(self): ins = cfm.ltm_egress_identifier_tlv() buf = ins.serialize() res = struct.unpack_from( cfm.ltm_egress_identifier_tlv._PACK_STR, six.binary_type(buf)) - eq_(res[0], cfm.CFM_LTM_EGRESS_IDENTIFIER_TLV) - eq_(res[1], 8) - eq_(res[2], 0) - eq_(res[3], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], cfm.CFM_LTM_EGRESS_IDENTIFIER_TLV) + self.assertEqual(res[1], 8) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], addrconv.mac.text_to_bin('00:00:00:00:00:00')) class Test_ltr_egress_identifier_tlv(unittest.TestCase): @@ -1430,11 +1429,11 @@ class Test_ltr_egress_identifier_tlv(unittest.TestCase): pass def test_init(self): - eq_(self.length, self.ins.length) - eq_(self.last_egress_id_ui, self.ins.last_egress_id_ui) - eq_(self.last_egress_id_mac, self.ins.last_egress_id_mac) - eq_(self.next_egress_id_ui, self.ins.next_egress_id_ui) - eq_(self.next_egress_id_mac, self.ins.next_egress_id_mac) + self.assertEqual(self.length, self.ins.length) + self.assertEqual(self.last_egress_id_ui, self.ins.last_egress_id_ui) + self.assertEqual(self.last_egress_id_mac, self.ins.last_egress_id_mac) + self.assertEqual(self.next_egress_id_ui, self.ins.next_egress_id_ui) + self.assertEqual(self.next_egress_id_mac, self.ins.next_egress_id_mac) def test_parser(self): _res = cfm.ltr_egress_identifier_tlv.parser(self.buf) @@ -1442,21 +1441,21 @@ class Test_ltr_egress_identifier_tlv(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.length, res.length) - eq_(self.last_egress_id_ui, res.last_egress_id_ui) - eq_(self.last_egress_id_mac, res.last_egress_id_mac) - eq_(self.next_egress_id_ui, res.next_egress_id_ui) - eq_(self.next_egress_id_mac, res.next_egress_id_mac) + self.assertEqual(self.length, res.length) + self.assertEqual(self.last_egress_id_ui, res.last_egress_id_ui) + self.assertEqual(self.last_egress_id_mac, res.last_egress_id_mac) + self.assertEqual(self.next_egress_id_ui, res.next_egress_id_ui) + self.assertEqual(self.next_egress_id_mac, res.next_egress_id_mac) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.last_egress_id_ui, res[2]) - eq_(addrconv.mac.text_to_bin(self.last_egress_id_mac), res[3]) - eq_(self.next_egress_id_ui, res[4]) - eq_(addrconv.mac.text_to_bin(self.next_egress_id_mac), res[5]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.last_egress_id_ui, res[2]) + self.assertEqual(addrconv.mac.text_to_bin(self.last_egress_id_mac), res[3]) + self.assertEqual(self.next_egress_id_ui, res[4]) + self.assertEqual(addrconv.mac.text_to_bin(self.next_egress_id_mac), res[5]) def test_serialize_with_length_zero(self): ins = cfm.ltr_egress_identifier_tlv(0, @@ -1467,28 +1466,28 @@ class Test_ltr_egress_identifier_tlv(unittest.TestCase): ) buf = ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.last_egress_id_ui, res[2]) - eq_(addrconv.mac.text_to_bin(self.last_egress_id_mac), res[3]) - eq_(self.next_egress_id_ui, res[4]) - eq_(addrconv.mac.text_to_bin(self.next_egress_id_mac), res[5]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.last_egress_id_ui, res[2]) + self.assertEqual(addrconv.mac.text_to_bin(self.last_egress_id_mac), res[3]) + self.assertEqual(self.next_egress_id_ui, res[4]) + self.assertEqual(addrconv.mac.text_to_bin(self.next_egress_id_mac), res[5]) def test_len(self): # tlv_length = type_len + length_len + value_len - eq_(1 + 2 + 16, len(self.ins)) + self.assertEqual(1 + 2 + 16, len(self.ins)) def test_default_args(self): ins = cfm.ltr_egress_identifier_tlv() buf = ins.serialize() res = struct.unpack_from(cfm.ltr_egress_identifier_tlv._PACK_STR, six.binary_type(buf)) - eq_(res[0], cfm.CFM_LTR_EGRESS_IDENTIFIER_TLV) - eq_(res[1], 16) - eq_(res[2], 0) - eq_(res[3], addrconv.mac.text_to_bin('00:00:00:00:00:00')) - eq_(res[4], 0) - eq_(res[5], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], cfm.CFM_LTR_EGRESS_IDENTIFIER_TLV) + self.assertEqual(res[1], 16) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[4], 0) + self.assertEqual(res[5], addrconv.mac.text_to_bin('00:00:00:00:00:00')) class Test_organization_specific_tlv(unittest.TestCase): @@ -1517,10 +1516,10 @@ class Test_organization_specific_tlv(unittest.TestCase): pass def test_init(self): - eq_(self.length, self.ins.length) - eq_(self.oui, self.ins.oui) - eq_(self.subtype, self.ins.subtype) - eq_(self.value, self.ins.value) + self.assertEqual(self.length, self.ins.length) + self.assertEqual(self.oui, self.ins.oui) + self.assertEqual(self.subtype, self.ins.subtype) + self.assertEqual(self.value, self.ins.value) def test_parser(self): _res = cfm.organization_specific_tlv.parser(self.buf) @@ -1528,19 +1527,19 @@ class Test_organization_specific_tlv(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.length, res.length) - eq_(self.oui, res.oui) - eq_(self.subtype, res.subtype) - eq_(self.value, res.value) + self.assertEqual(self.length, res.length) + self.assertEqual(self.oui, res.oui) + self.assertEqual(self.subtype, res.subtype) + self.assertEqual(self.value, res.value) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.oui, res[2]) - eq_(self.subtype, res[3]) - eq_(self.value, res[4]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.oui, res[2]) + self.assertEqual(self.subtype, res[3]) + self.assertEqual(self.value, res[4]) def test_serialize_with_zero(self): ins = cfm.organization_specific_tlv(0, @@ -1550,25 +1549,25 @@ class Test_organization_specific_tlv(unittest.TestCase): ) buf = ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.oui, res[2]) - eq_(self.subtype, res[3]) - eq_(self.value, res[4]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.oui, res[2]) + self.assertEqual(self.subtype, res[3]) + self.assertEqual(self.value, res[4]) def test_len(self): # tlv_length = type_len + length_len + value_len - eq_(1 + 2 + 10, len(self.ins)) + self.assertEqual(1 + 2 + 10, len(self.ins)) def test_default_args(self): ins = cfm.organization_specific_tlv() buf = ins.serialize() res = struct.unpack_from(cfm.organization_specific_tlv._PACK_STR, six.binary_type(buf)) - eq_(res[0], cfm.CFM_ORGANIZATION_SPECIFIC_TLV) - eq_(res[1], 4) - eq_(res[2], b"\x00\x00\x00") - eq_(res[3], 0) + self.assertEqual(res[0], cfm.CFM_ORGANIZATION_SPECIFIC_TLV) + self.assertEqual(res[1], 4) + self.assertEqual(res[2], b"\x00\x00\x00") + self.assertEqual(res[3], 0) class Test_reply_ingress_tlv(unittest.TestCase): @@ -1602,12 +1601,12 @@ class Test_reply_ingress_tlv(unittest.TestCase): pass def test_init(self): - eq_(self.length, self.ins.length) - eq_(self.action, self.ins.action) - eq_(self.mac_address, self.ins.mac_address) - eq_(self.port_id_length, self.ins.port_id_length) - eq_(self.port_id_subtype, self.ins.port_id_subtype) - eq_(self.port_id, self.ins.port_id) + self.assertEqual(self.length, self.ins.length) + self.assertEqual(self.action, self.ins.action) + self.assertEqual(self.mac_address, self.ins.mac_address) + self.assertEqual(self.port_id_length, self.ins.port_id_length) + self.assertEqual(self.port_id_subtype, self.ins.port_id_subtype) + self.assertEqual(self.port_id, self.ins.port_id) def test_parser(self): _res = cfm.reply_ingress_tlv.parser(self.buf) @@ -1615,23 +1614,23 @@ class Test_reply_ingress_tlv(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.length, res.length) - eq_(self.action, res.action) - eq_(self.mac_address, res.mac_address) - eq_(self.port_id_length, res.port_id_length) - eq_(self.port_id_subtype, res.port_id_subtype) - eq_(self.port_id, res.port_id) + self.assertEqual(self.length, res.length) + self.assertEqual(self.action, res.action) + self.assertEqual(self.mac_address, res.mac_address) + self.assertEqual(self.port_id_length, res.port_id_length) + self.assertEqual(self.port_id_subtype, res.port_id_subtype) + self.assertEqual(self.port_id, res.port_id) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.action, res[2]) - eq_(addrconv.mac.text_to_bin(self.mac_address), res[3]) - eq_(self.port_id_length, res[4]) - eq_(self.port_id_subtype, res[5]) - eq_(self.port_id, res[6]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.action, res[2]) + self.assertEqual(addrconv.mac.text_to_bin(self.mac_address), res[3]) + self.assertEqual(self.port_id_length, res[4]) + self.assertEqual(self.port_id_subtype, res[5]) + self.assertEqual(self.port_id, res[6]) def test_serialize_with_zero(self): ins = cfm.reply_ingress_tlv(0, @@ -1643,26 +1642,26 @@ class Test_reply_ingress_tlv(unittest.TestCase): ) buf = ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.action, res[2]) - eq_(addrconv.mac.text_to_bin(self.mac_address), res[3]) - eq_(self.port_id_length, res[4]) - eq_(self.port_id_subtype, res[5]) - eq_(self.port_id, res[6]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.action, res[2]) + self.assertEqual(addrconv.mac.text_to_bin(self.mac_address), res[3]) + self.assertEqual(self.port_id_length, res[4]) + self.assertEqual(self.port_id_subtype, res[5]) + self.assertEqual(self.port_id, res[6]) def test_len(self): # tlv_length = type_len + length_len + value_len - eq_(1 + 2 + 12, len(self.ins)) + self.assertEqual(1 + 2 + 12, len(self.ins)) def test_default_args(self): ins = cfm.reply_ingress_tlv() buf = ins.serialize() res = struct.unpack_from(cfm.reply_ingress_tlv._PACK_STR, six.binary_type(buf)) - eq_(res[0], cfm.CFM_REPLY_INGRESS_TLV) - eq_(res[1], 7) - eq_(res[2], 1) - eq_(res[3], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], cfm.CFM_REPLY_INGRESS_TLV) + self.assertEqual(res[1], 7) + self.assertEqual(res[2], 1) + self.assertEqual(res[3], addrconv.mac.text_to_bin('00:00:00:00:00:00')) class Test_reply_egress_tlv(unittest.TestCase): @@ -1697,12 +1696,12 @@ class Test_reply_egress_tlv(unittest.TestCase): pass def test_init(self): - eq_(self.length, self.ins.length) - eq_(self.action, self.ins.action) - eq_(self.mac_address, self.ins.mac_address) - eq_(self.port_id_length, self.ins.port_id_length) - eq_(self.port_id_subtype, self.ins.port_id_subtype) - eq_(self.port_id, self.ins.port_id) + self.assertEqual(self.length, self.ins.length) + self.assertEqual(self.action, self.ins.action) + self.assertEqual(self.mac_address, self.ins.mac_address) + self.assertEqual(self.port_id_length, self.ins.port_id_length) + self.assertEqual(self.port_id_subtype, self.ins.port_id_subtype) + self.assertEqual(self.port_id, self.ins.port_id) def test_parser(self): _res = cfm.reply_ingress_tlv.parser(self.buf) @@ -1710,23 +1709,23 @@ class Test_reply_egress_tlv(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.length, res.length) - eq_(self.action, res.action) - eq_(self.mac_address, res.mac_address) - eq_(self.port_id_length, res.port_id_length) - eq_(self.port_id_subtype, res.port_id_subtype) - eq_(self.port_id, res.port_id) + self.assertEqual(self.length, res.length) + self.assertEqual(self.action, res.action) + self.assertEqual(self.mac_address, res.mac_address) + self.assertEqual(self.port_id_length, res.port_id_length) + self.assertEqual(self.port_id_subtype, res.port_id_subtype) + self.assertEqual(self.port_id, res.port_id) def test_serialize(self): buf = self.ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.action, res[2]) - eq_(addrconv.mac.text_to_bin(self.mac_address), res[3]) - eq_(self.port_id_length, res[4]) - eq_(self.port_id_subtype, res[5]) - eq_(self.port_id, res[6]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.action, res[2]) + self.assertEqual(addrconv.mac.text_to_bin(self.mac_address), res[3]) + self.assertEqual(self.port_id_length, res[4]) + self.assertEqual(self.port_id_subtype, res[5]) + self.assertEqual(self.port_id, res[6]) def test_serialize_with_zero(self): ins = cfm.reply_egress_tlv(0, @@ -1738,24 +1737,24 @@ class Test_reply_egress_tlv(unittest.TestCase): ) buf = ins.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self._type, res[0]) - eq_(self.length, res[1]) - eq_(self.action, res[2]) - eq_(addrconv.mac.text_to_bin(self.mac_address), res[3]) - eq_(self.port_id_length, res[4]) - eq_(self.port_id_subtype, res[5]) - eq_(self.port_id, res[6]) + self.assertEqual(self._type, res[0]) + self.assertEqual(self.length, res[1]) + self.assertEqual(self.action, res[2]) + self.assertEqual(addrconv.mac.text_to_bin(self.mac_address), res[3]) + self.assertEqual(self.port_id_length, res[4]) + self.assertEqual(self.port_id_subtype, res[5]) + self.assertEqual(self.port_id, res[6]) def test_len(self): # tlv_length = type_len + length_len + value_len - eq_(1 + 2 + 12, len(self.ins)) + self.assertEqual(1 + 2 + 12, len(self.ins)) def test_default_args(self): ins = cfm.reply_egress_tlv() buf = ins.serialize() res = struct.unpack_from(cfm.reply_egress_tlv._PACK_STR, six.binary_type(buf)) - eq_(res[0], cfm.CFM_REPLY_EGRESS_TLV) - eq_(res[1], 7) - eq_(res[2], 1) - eq_(res[3], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], cfm.CFM_REPLY_EGRESS_TLV) + self.assertEqual(res[1], 7) + self.assertEqual(res[2], 1) + self.assertEqual(res[3], addrconv.mac.text_to_bin('00:00:00:00:00:00')) diff --git a/os_ken/tests/unit/packet/test_dhcp.py b/os_ken/tests/unit/packet/test_dhcp.py index e5d53bac..ce179e05 100644 --- a/os_ken/tests/unit/packet/test_dhcp.py +++ b/os_ken/tests/unit/packet/test_dhcp.py @@ -20,8 +20,6 @@ import struct import unittest import six -from nose.tools import eq_ -from nose.tools import ok_ from os_ken.lib import addrconv from os_ken.lib.packet import dhcp @@ -92,57 +90,57 @@ class Test_dhcp_offer(unittest.TestCase): pass def test_init(self): - eq_(self.op, self.dh.op) - eq_(self.htype, self.dh.htype) - eq_(self.hlen, self.dh.hlen) - eq_(self.hops, self.dh.hops) - eq_(self.xid, self.dh.xid) - eq_(self.secs, self.dh.secs) - eq_(self.flags, self.dh.flags) - eq_(self.ciaddr, self.dh.ciaddr) - eq_(self.yiaddr, self.dh.yiaddr) - eq_(self.siaddr, self.dh.siaddr) - eq_(self.giaddr, self.dh.giaddr) - eq_(self.chaddr, self.dh.chaddr) - eq_(self.sname, self.dh.sname) - eq_(self.boot_file, self.dh.boot_file) - eq_(str(self.options), str(self.dh.options)) + self.assertEqual(self.op, self.dh.op) + self.assertEqual(self.htype, self.dh.htype) + self.assertEqual(self.hlen, self.dh.hlen) + self.assertEqual(self.hops, self.dh.hops) + self.assertEqual(self.xid, self.dh.xid) + self.assertEqual(self.secs, self.dh.secs) + self.assertEqual(self.flags, self.dh.flags) + self.assertEqual(self.ciaddr, self.dh.ciaddr) + self.assertEqual(self.yiaddr, self.dh.yiaddr) + self.assertEqual(self.siaddr, self.dh.siaddr) + self.assertEqual(self.giaddr, self.dh.giaddr) + self.assertEqual(self.chaddr, self.dh.chaddr) + self.assertEqual(self.sname, self.dh.sname) + self.assertEqual(self.boot_file, self.dh.boot_file) + self.assertEqual(str(self.options), str(self.dh.options)) def test_parser(self): res, _, rest = dhcp.dhcp.parser(self.buf) - eq_(self.op, res.op) - eq_(self.htype, res.htype) - eq_(self.hlen, res.hlen) - eq_(self.hops, res.hops) - eq_(self.xid, res.xid) - eq_(self.secs, res.secs) - eq_(self.flags, res.flags) - eq_(self.ciaddr, res.ciaddr) - eq_(self.yiaddr, res.yiaddr) - eq_(self.siaddr, res.siaddr) - eq_(self.giaddr, res.giaddr) - eq_(self.chaddr, res.chaddr) + self.assertEqual(self.op, res.op) + self.assertEqual(self.htype, res.htype) + self.assertEqual(self.hlen, res.hlen) + self.assertEqual(self.hops, res.hops) + self.assertEqual(self.xid, res.xid) + self.assertEqual(self.secs, res.secs) + self.assertEqual(self.flags, res.flags) + self.assertEqual(self.ciaddr, res.ciaddr) + self.assertEqual(self.yiaddr, res.yiaddr) + self.assertEqual(self.siaddr, res.siaddr) + self.assertEqual(self.giaddr, res.giaddr) + self.assertEqual(self.chaddr, res.chaddr) # sname is 64 byte length. rest of data is filled by '\x00'. - eq_(self.sname.ljust(64, '\x00'), res.sname) + self.assertEqual(self.sname.ljust(64, '\x00'), res.sname) # boof_file is 128 byte length. rest of data is filled by '\x00'. - eq_(self.boot_file.ljust(128, '\x00'), res.boot_file) - eq_(str(self.options), str(res.options)) - eq_(b'', rest) + self.assertEqual(self.boot_file.ljust(128, '\x00'), res.boot_file) + self.assertEqual(str(self.options), str(res.options)) + self.assertEqual(b'', rest) def test_parser_corrupted(self): corrupt_buf = self.buf[:-4] pkt, _, rest = dhcp.dhcp.parser(corrupt_buf) - ok_(isinstance(pkt, dhcp.dhcp)) - ok_(isinstance(pkt.options, dhcp.options)) + self.assertTrue(isinstance(pkt, dhcp.dhcp)) + self.assertTrue(isinstance(pkt.options, dhcp.options)) for opt in pkt.options.option_list[:-1]: - ok_(isinstance(opt, dhcp.option)) - ok_(isinstance(pkt.options.option_list[-1], six.binary_type)) + self.assertTrue(isinstance(opt, dhcp.option)) + self.assertTrue(isinstance(pkt.options.option_list[-1], six.binary_type)) buf = pkt.serialize() - eq_(str(buf), str(corrupt_buf)) - eq_(b'', rest) + self.assertEqual(str(buf), str(corrupt_buf)) + self.assertEqual(b'', rest) def test_serialize(self): buf = self.dh.serialize() @@ -150,25 +148,25 @@ class Test_dhcp_offer(unittest.TestCase): res = struct.unpack_from(dhcp.dhcp._DHCP_PACK_STR, six.binary_type(buf)) - eq_(self.op, res[0]) - eq_(self.htype, res[1]) - eq_(self.hlen, res[2]) - eq_(self.hops, res[3]) - eq_(self.xid, res[4]) - eq_(self.secs, res[5]) - eq_(self.flags, res[6]) - eq_(self.ciaddr, addrconv.ipv4.bin_to_text(res[7])) - eq_(self.yiaddr, addrconv.ipv4.bin_to_text(res[8])) - eq_(self.siaddr, addrconv.ipv4.bin_to_text(res[9])) - eq_(self.giaddr, addrconv.ipv4.bin_to_text(res[10])) - eq_(self.chaddr, addrconv.mac.bin_to_text(res[11][:6])) + self.assertEqual(self.op, res[0]) + self.assertEqual(self.htype, res[1]) + self.assertEqual(self.hlen, res[2]) + self.assertEqual(self.hops, res[3]) + self.assertEqual(self.xid, res[4]) + self.assertEqual(self.secs, res[5]) + self.assertEqual(self.flags, res[6]) + self.assertEqual(self.ciaddr, addrconv.ipv4.bin_to_text(res[7])) + self.assertEqual(self.yiaddr, addrconv.ipv4.bin_to_text(res[8])) + self.assertEqual(self.siaddr, addrconv.ipv4.bin_to_text(res[9])) + self.assertEqual(self.giaddr, addrconv.ipv4.bin_to_text(res[10])) + self.assertEqual(self.chaddr, addrconv.mac.bin_to_text(res[11][:6])) # sname is 64 byte length. rest of data is filled by '\x00'. - eq_(self.sname.ljust(64, '\x00'), res[12].decode('ascii')) + self.assertEqual(self.sname.ljust(64, '\x00'), res[12].decode('ascii')) # boof_file is 128 byte length. rest of data is filled by '\x00'. - eq_(self.boot_file.ljust(128, '\x00'), res[13].decode('ascii')) + self.assertEqual(self.boot_file.ljust(128, '\x00'), res[13].decode('ascii')) options = dhcp.options.parser( buf[struct.calcsize(dhcp.dhcp._DHCP_PACK_STR):]) - eq_(str(self.options), str(options)) + self.assertEqual(str(self.options), str(options)) def test_to_string(self): option_values = ['tag', 'length', 'value'] @@ -209,10 +207,10 @@ class Test_dhcp_offer(unittest.TestCase): if k in dhcp_values]) dh_str = '%s(%s)' % (dhcp.dhcp.__name__, _dh_str) - eq_(str(self.dh), dh_str) - eq_(repr(self.dh), dh_str) + self.assertEqual(str(self.dh), dh_str) + self.assertEqual(repr(self.dh), dh_str) def test_json(self): jsondict = self.dh.to_jsondict() dh = dhcp.dhcp.from_jsondict(jsondict['dhcp']) - eq_(str(self.dh), str(dh)) + self.assertEqual(str(self.dh), str(dh)) diff --git a/os_ken/tests/unit/packet/test_ethernet.py b/os_ken/tests/unit/packet/test_ethernet.py index efda43e6..993de5d3 100644 --- a/os_ken/tests/unit/packet/test_ethernet.py +++ b/os_ken/tests/unit/packet/test_ethernet.py @@ -21,7 +21,6 @@ import six import struct import netaddr from struct import * -from nose.tools import * from os_ken.ofproto import ether, inet from os_ken.lib.packet.ethernet import ethernet from os_ken.lib.packet.packet import Packet @@ -58,18 +57,18 @@ class Test_ethernet(unittest.TestCase): return p def test_init(self): - eq_(self.dst, self.e.dst) - eq_(self.src, self.e.src) - eq_(self.ethertype, self.e.ethertype) + self.assertEqual(self.dst, self.e.dst) + self.assertEqual(self.src, self.e.src) + self.assertEqual(self.ethertype, self.e.ethertype) def test_parser(self): res, ptype, _ = self.e.parser(self.buf) LOG.debug((res, ptype)) - eq_(res.dst, self.dst) - eq_(res.src, self.src) - eq_(res.ethertype, self.ethertype) - eq_(ptype, arp) + self.assertEqual(res.dst, self.dst) + self.assertEqual(res.src, self.src) + self.assertEqual(res.ethertype, self.ethertype) + self.assertEqual(ptype, arp) def test_serialize(self): data = bytearray() @@ -79,25 +78,24 @@ class Test_ethernet(unittest.TestCase): fmt = ethernet._PACK_STR res = struct.unpack(fmt, buf) - eq_(res[0], addrconv.mac.text_to_bin(self.dst)) - eq_(res[1], addrconv.mac.text_to_bin(self.src)) - eq_(res[2], self.ethertype) + self.assertEqual(res[0], addrconv.mac.text_to_bin(self.dst)) + self.assertEqual(res[1], addrconv.mac.text_to_bin(self.src)) + self.assertEqual(res[2], self.ethertype) - @raises(Exception) def test_malformed_ethernet(self): m_short_buf = self.buf[1:ethernet._MIN_LEN] - ethernet.parser(m_short_buf) + self.assertRaises(Exception, ethernet.parser, m_short_buf) def test_default_args(self): e = ethernet() buf = e.serialize(bytearray(), None) res = struct.unpack(e._PACK_STR, six.binary_type(buf)) - eq_(res[0], addrconv.mac.text_to_bin('ff:ff:ff:ff:ff:ff')) - eq_(res[1], addrconv.mac.text_to_bin('00:00:00:00:00:00')) - eq_(res[2], ether.ETH_TYPE_IP) + self.assertEqual(res[0], addrconv.mac.text_to_bin('ff:ff:ff:ff:ff:ff')) + self.assertEqual(res[1], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[2], ether.ETH_TYPE_IP) def test_json(self): jsondict = self.e.to_jsondict() e = ethernet.from_jsondict(jsondict['ethernet']) - eq_(str(self.e), str(e)) + self.assertEqual(str(self.e), str(e)) diff --git a/os_ken/tests/unit/packet/test_geneve.py b/os_ken/tests/unit/packet/test_geneve.py index 8be23404..01502848 100644 --- a/os_ken/tests/unit/packet/test_geneve.py +++ b/os_ken/tests/unit/packet/test_geneve.py @@ -18,8 +18,6 @@ import os import sys import unittest -from nose.tools import eq_ -from nose.tools import ok_ from os_ken.lib import pcaplib from os_ken.lib.packet import geneve @@ -51,10 +49,10 @@ class Test_geneve(unittest.TestCase): # Checks if message can be parsed as expected. pkt = packet.Packet(buf) geneve_pkt = pkt.get_protocol(geneve.geneve) - ok_(isinstance(geneve_pkt, geneve.geneve), + self.assertTrue(isinstance(geneve_pkt, geneve.geneve), 'Failed to parse Geneve message: %s' % pkt) # Checks if message can be serialized as expected. pkt.serialize() - eq_(buf, pkt.data, + self.assertEqual(buf, pkt.data, "b'%s' != b'%s'" % (binary_str(buf), binary_str(pkt.data))) diff --git a/os_ken/tests/unit/packet/test_gre.py b/os_ken/tests/unit/packet/test_gre.py index 288fb0d1..5d3f7e17 100644 --- a/os_ken/tests/unit/packet/test_gre.py +++ b/os_ken/tests/unit/packet/test_gre.py @@ -18,8 +18,6 @@ import os import sys import unittest -from nose.tools import eq_ -from nose.tools import ok_ from os_ken.lib import pcaplib from os_ken.lib.packet import gre @@ -53,41 +51,41 @@ class Test_gre(unittest.TestCase): def test_key_setter(self): self.gre.key = self.key - eq_(self.gre._key, self.key) - eq_(self.gre._vsid, self.vsid) - eq_(self.gre._flow_id, self.flow_id) + self.assertEqual(self.gre._key, self.key) + self.assertEqual(self.gre._vsid, self.vsid) + self.assertEqual(self.gre._flow_id, self.flow_id) def test_key_setter_none(self): self.gre.key = None - eq_(self.gre._key, None) - eq_(self.gre._vsid, None) - eq_(self.gre._flow_id, None) + self.assertEqual(self.gre._key, None) + self.assertEqual(self.gre._vsid, None) + self.assertEqual(self.gre._flow_id, None) self.gre.key = self.key def test_vsid_setter(self): self.gre.vsid = self.vsid - eq_(self.gre._key, self.key) - eq_(self.gre._vsid, self.vsid) - eq_(self.gre._flow_id, self.flow_id) + self.assertEqual(self.gre._key, self.key) + self.assertEqual(self.gre._vsid, self.vsid) + self.assertEqual(self.gre._flow_id, self.flow_id) def test_flowid_setter(self): self.gre.flow_id = self.flow_id - eq_(self.gre._key, self.key) - eq_(self.gre._vsid, self.vsid) - eq_(self.gre._flow_id, self.flow_id) + self.assertEqual(self.gre._key, self.key) + self.assertEqual(self.gre._vsid, self.vsid) + self.assertEqual(self.gre._flow_id, self.flow_id) def test_nvgre_init(self): nvgre = gre.nvgre(version=self.version, vsid=self.vsid, flow_id=self.flow_id) - eq_(nvgre.version, self.version) - eq_(nvgre.protocol, self.nvgre_proto) - eq_(nvgre.checksum, None) - eq_(nvgre.seq_number, None) - eq_(nvgre._key, self.key) - eq_(nvgre._vsid, self.vsid) - eq_(nvgre._flow_id, self.flow_id) + self.assertEqual(nvgre.version, self.version) + self.assertEqual(nvgre.protocol, self.nvgre_proto) + self.assertEqual(nvgre.checksum, None) + self.assertEqual(nvgre.seq_number, None) + self.assertEqual(nvgre._key, self.key) + self.assertEqual(nvgre._vsid, self.vsid) + self.assertEqual(nvgre._flow_id, self.flow_id) def test_parser(self): files = [ @@ -103,11 +101,11 @@ class Test_gre(unittest.TestCase): # Checks if message can be parsed as expected. pkt = packet.Packet(buf) gre_pkt = pkt.get_protocol(gre.gre) - ok_(isinstance(gre_pkt, gre.gre), + self.assertTrue(isinstance(gre_pkt, gre.gre), 'Failed to parse Gre message: %s' % pkt) # Checks if message can be serialized as expected. pkt.serialize() - eq_(buf, pkt.data, + self.assertEqual(buf, pkt.data, "b'%s' != b'%s'" % (binary_str(buf), binary_str(pkt.data))) diff --git a/os_ken/tests/unit/packet/test_icmp.py b/os_ken/tests/unit/packet/test_icmp.py index 15822a11..4e72f78b 100644 --- a/os_ken/tests/unit/packet/test_icmp.py +++ b/os_ken/tests/unit/packet/test_icmp.py @@ -20,7 +20,6 @@ import six import struct import unittest -from nose.tools import eq_ from os_ken.lib.packet import icmp from os_ken.lib.packet import packet_utils @@ -111,10 +110,10 @@ class Test_icmp(unittest.TestCase): struct.pack_into('!H', self.buf, 2, self.csum_calc) def test_init(self): - eq_(self.type_, self.ic.type) - eq_(self.code, self.ic.code) - eq_(self.csum, self.ic.csum) - eq_(str(self.data), str(self.ic.data)) + self.assertEqual(self.type_, self.ic.type) + self.assertEqual(self.code, self.ic.code) + self.assertEqual(self.csum, self.ic.csum) + self.assertEqual(str(self.data), str(self.ic.data)) def test_init_with_echo(self): self.setUp_with_echo() @@ -135,10 +134,10 @@ class Test_icmp(unittest.TestCase): else: res = _res - eq_(self.type_, res.type) - eq_(self.code, res.code) - eq_(self.csum_calc, res.csum) - eq_(str(self.data), str(res.data)) + self.assertEqual(self.type_, res.type) + self.assertEqual(self.code, res.code) + self.assertEqual(self.csum_calc, res.csum) + self.assertEqual(str(self.data), str(res.data)) def test_parser_with_echo(self): self.setUp_with_echo() @@ -159,9 +158,9 @@ class Test_icmp(unittest.TestCase): res = struct.unpack_from(icmp.icmp._PACK_STR, six.binary_type(buf)) - eq_(self.type_, res[0]) - eq_(self.code, res[1]) - eq_(self.csum_calc, res[2]) + self.assertEqual(self.type_, res[0]) + self.assertEqual(self.code, res[1]) + self.assertEqual(self.csum_calc, res[2]) def test_serialize_with_echo(self): self.setUp_with_echo() @@ -171,7 +170,7 @@ class Test_icmp(unittest.TestCase): prev = None buf = self.ic.serialize(data, prev) echo = icmp.echo.parser(six.binary_type(buf), icmp.icmp._MIN_LEN) - eq_(repr(self.data), repr(echo)) + self.assertEqual(repr(self.data), repr(echo)) def test_serialize_with_dest_unreach(self): self.setUp_with_dest_unreach() @@ -181,7 +180,7 @@ class Test_icmp(unittest.TestCase): prev = None buf = self.ic.serialize(data, prev) unreach = icmp.dest_unreach.parser(six.binary_type(buf), icmp.icmp._MIN_LEN) - eq_(repr(self.data), repr(unreach)) + self.assertEqual(repr(self.data), repr(unreach)) def test_serialize_with_TimeExceeded(self): self.setUp_with_TimeExceeded() @@ -191,7 +190,7 @@ class Test_icmp(unittest.TestCase): prev = None buf = self.ic.serialize(data, prev) te = icmp.TimeExceeded.parser(six.binary_type(buf), icmp.icmp._MIN_LEN) - eq_(repr(self.data), repr(te)) + self.assertEqual(repr(self.data), repr(te)) def test_to_string(self): icmp_values = {'type': repr(self.type_), @@ -203,8 +202,8 @@ class Test_icmp(unittest.TestCase): if k in icmp_values]) ic_str = '%s(%s)' % (icmp.icmp.__name__, _ic_str) - eq_(str(self.ic), ic_str) - eq_(repr(self.ic), ic_str) + self.assertEqual(str(self.ic), ic_str) + self.assertEqual(repr(self.ic), ic_str) def test_to_string_with_echo(self): self.setUp_with_echo() @@ -223,23 +222,23 @@ class Test_icmp(unittest.TestCase): buf = ic.serialize(bytearray(), None) res = struct.unpack(icmp.icmp._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], 8) - eq_(res[1], 0) - eq_(buf[4:], b'\x00\x00\x00\x00') + self.assertEqual(res[0], 8) + self.assertEqual(res[1], 0) + self.assertEqual(buf[4:], b'\x00\x00\x00\x00') # with data ic = icmp.icmp(type_=icmp.ICMP_DEST_UNREACH, data=icmp.dest_unreach()) buf = ic.serialize(bytearray(), None) res = struct.unpack(icmp.icmp._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], 3) - eq_(res[1], 0) - eq_(buf[4:], b'\x00\x00\x00\x00') + self.assertEqual(res[0], 3) + self.assertEqual(res[1], 0) + self.assertEqual(buf[4:], b'\x00\x00\x00\x00') def test_json(self): jsondict = self.ic.to_jsondict() ic = icmp.icmp.from_jsondict(jsondict['icmp']) - eq_(str(self.ic), str(ic)) + self.assertEqual(str(self.ic), str(ic)) def test_json_with_echo(self): self.setUp_with_echo() @@ -271,9 +270,9 @@ class Test_echo(unittest.TestCase): self.buf += self.data def test_init(self): - eq_(self.id_, self.echo.id) - eq_(self.seq, self.echo.seq) - eq_(self.data, self.echo.data) + self.assertEqual(self.id_, self.echo.id) + self.assertEqual(self.seq, self.echo.seq) + self.assertEqual(self.data, self.echo.data) def test_parser(self): _res = icmp.echo.parser(self.buf, 0) @@ -281,24 +280,24 @@ class Test_echo(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.id_, res.id) - eq_(self.seq, res.seq) - eq_(self.data, res.data) + self.assertEqual(self.id_, res.id) + self.assertEqual(self.seq, res.seq) + self.assertEqual(self.data, res.data) def test_serialize(self): buf = self.echo.serialize() res = struct.unpack_from('!HH', six.binary_type(buf)) - eq_(self.id_, res[0]) - eq_(self.seq, res[1]) - eq_(self.data, buf[struct.calcsize('!HH'):]) + self.assertEqual(self.id_, res[0]) + self.assertEqual(self.seq, res[1]) + self.assertEqual(self.data, buf[struct.calcsize('!HH'):]) def test_default_args(self): ec = icmp.echo() buf = ec.serialize() res = struct.unpack(icmp.echo._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) class Test_dest_unreach(unittest.TestCase): @@ -313,9 +312,9 @@ class Test_dest_unreach(unittest.TestCase): self.buf += self.data def test_init(self): - eq_(self.data_len, self.dest_unreach.data_len) - eq_(self.mtu, self.dest_unreach.mtu) - eq_(self.data, self.dest_unreach.data) + self.assertEqual(self.data_len, self.dest_unreach.data_len) + self.assertEqual(self.mtu, self.dest_unreach.mtu) + self.assertEqual(self.data, self.dest_unreach.data) def test_parser(self): _res = icmp.dest_unreach.parser(self.buf, 0) @@ -323,24 +322,24 @@ class Test_dest_unreach(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.data_len, res.data_len) - eq_(self.mtu, res.mtu) - eq_(self.data, res.data) + self.assertEqual(self.data_len, res.data_len) + self.assertEqual(self.mtu, res.mtu) + self.assertEqual(self.data, res.data) def test_serialize(self): buf = self.dest_unreach.serialize() res = struct.unpack_from('!xBH', six.binary_type(buf)) - eq_(self.data_len, res[0]) - eq_(self.mtu, res[1]) - eq_(self.data, buf[struct.calcsize('!xBH'):]) + self.assertEqual(self.data_len, res[0]) + self.assertEqual(self.mtu, res[1]) + self.assertEqual(self.data, buf[struct.calcsize('!xBH'):]) def test_default_args(self): du = icmp.dest_unreach() buf = du.serialize() res = struct.unpack(icmp.dest_unreach._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) class Test_TimeExceeded(unittest.TestCase): @@ -354,8 +353,8 @@ class Test_TimeExceeded(unittest.TestCase): self.buf += self.data def test_init(self): - eq_(self.data_len, self.te.data_len) - eq_(self.data, self.te.data) + self.assertEqual(self.data_len, self.te.data_len) + self.assertEqual(self.data, self.te.data) def test_parser(self): _res = icmp.TimeExceeded.parser(self.buf, 0) @@ -363,18 +362,18 @@ class Test_TimeExceeded(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.data_len, res.data_len) - eq_(self.data, res.data) + self.assertEqual(self.data_len, res.data_len) + self.assertEqual(self.data, res.data) def test_serialize(self): buf = self.te.serialize() res = struct.unpack_from('!xBxx', six.binary_type(buf)) - eq_(self.data_len, res[0]) - eq_(self.data, buf[struct.calcsize('!xBxx'):]) + self.assertEqual(self.data_len, res[0]) + self.assertEqual(self.data, buf[struct.calcsize('!xBxx'):]) def test_default_args(self): te = icmp.TimeExceeded() buf = te.serialize() res = struct.unpack(icmp.TimeExceeded._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) + self.assertEqual(res[0], 0) diff --git a/os_ken/tests/unit/packet/test_icmpv6.py b/os_ken/tests/unit/packet/test_icmpv6.py index 22a0db11..e0ff44fa 100644 --- a/os_ken/tests/unit/packet/test_icmpv6.py +++ b/os_ken/tests/unit/packet/test_icmpv6.py @@ -21,7 +21,6 @@ import six import struct import inspect -from nose.tools import ok_, eq_, nottest, raises from os_ken.ofproto import ether, inet from os_ken.lib.packet.ethernet import ethernet from os_ken.lib.packet.packet import Packet @@ -59,18 +58,18 @@ class Test_icmpv6_header(unittest.TestCase): pass def test_init(self): - eq_(self.type_, self.icmp.type_) - eq_(self.code, self.icmp.code) - eq_(0, self.icmp.csum) + self.assertEqual(self.type_, self.icmp.type_) + self.assertEqual(self.code, self.icmp.code) + self.assertEqual(0, self.icmp.csum) def test_parser(self): msg, n, _ = self.icmp.parser(self.buf) - eq_(msg.type_, self.type_) - eq_(msg.code, self.code) - eq_(msg.csum, self.csum) - eq_(msg.data, b'') - eq_(n, None) + self.assertEqual(msg.type_, self.type_) + self.assertEqual(msg.code, self.code) + self.assertEqual(msg.csum, self.csum) + self.assertEqual(msg.data, b'') + self.assertEqual(n, None) def test_serialize(self): src_ipv6 = 'fe80::200:ff:fe00:ef' @@ -80,14 +79,13 @@ class Test_icmpv6_header(unittest.TestCase): buf = self.icmp.serialize(bytearray(), prev) (type_, code, csum) = struct.unpack(self.icmp._PACK_STR, six.binary_type(buf)) - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, self.csum) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, self.csum) - @raises(struct.error) def test_malformed_icmpv6(self): m_short_buf = self.buf[1:self.icmp._MIN_LEN] - self.icmp.parser(m_short_buf) + self.assertRaises(struct.error, self.icmp.parser, m_short_buf) def test_default_args(self): prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -96,14 +94,14 @@ class Test_icmpv6_header(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) def test_json(self): jsondict = self.icmp.to_jsondict() icmp = icmpv6.icmpv6.from_jsondict(jsondict['icmpv6']) - eq_(str(self.icmp), str(icmp)) + self.assertEqual(str(self.icmp), str(icmp)) class Test_icmpv6_echo_request(unittest.TestCase): @@ -123,21 +121,21 @@ class Test_icmpv6_echo_request(unittest.TestCase): def test_init(self): echo = icmpv6.echo(0, 0) - eq_(echo.id, 0) - eq_(echo.seq, 0) - eq_(echo.data, None) + self.assertEqual(echo.id, 0) + self.assertEqual(echo.seq, 0) + self.assertEqual(echo.data, None) def _test_parser(self, data=None): buf = self.buf + (data or b'') msg, n, _ = icmpv6.icmpv6.parser(buf) - eq_(msg.type_, self.type_) - eq_(msg.code, self.code) - eq_(msg.csum, self.csum) - eq_(msg.data.id, self.id_) - eq_(msg.data.seq, self.seq) - eq_(msg.data.data, data) - eq_(n, None) + self.assertEqual(msg.type_, self.type_) + self.assertEqual(msg.code, self.code) + self.assertEqual(msg.csum, self.csum) + self.assertEqual(msg.data.id, self.id_) + self.assertEqual(msg.data.seq, self.seq) + self.assertEqual(msg.data.data, data) + self.assertEqual(n, None) def test_parser_without_data(self): self._test_parser() @@ -161,12 +159,12 @@ class Test_icmpv6_echo_request(unittest.TestCase): data = buf[(icmp._MIN_LEN + echo._MIN_LEN):] data = data if len(data) != 0 else None - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, echo_csum) - eq_(id_, self.id_) - eq_(seq, self.seq) - eq_(data, echo_data) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, echo_csum) + self.assertEqual(id_, self.id_) + self.assertEqual(seq, self.seq) + self.assertEqual(data, echo_data) def test_serialize_without_data(self): self._test_serialize() @@ -195,8 +193,8 @@ class Test_icmpv6_echo_request(unittest.TestCase): if k in icmp_values]) ic_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _ic_str) - eq_(str(ic), ic_str) - eq_(repr(ic), ic_str) + self.assertEqual(str(ic), ic_str) + self.assertEqual(repr(ic), ic_str) def test_default_args(self): prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -206,21 +204,21 @@ class Test_icmpv6_echo_request(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ICMPV6_ECHO_REQUEST) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ICMPV6_ECHO_REQUEST) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.echo._PACK_STR, six.binary_type(buf[4:])) - eq_(res[0], 0) - eq_(res[1], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) def test_json(self): ec = icmpv6.echo(self.id_, self.seq, self.data) ic1 = icmpv6.icmpv6(self.type_, self.code, self.csum, ec) jsondict = ic1.to_jsondict() ic2 = icmpv6.icmpv6.from_jsondict(jsondict['icmpv6']) - eq_(str(ic1), str(ic2)) + self.assertEqual(str(ic1), str(ic2)) class Test_icmpv6_echo_reply(Test_icmpv6_echo_request): @@ -237,14 +235,14 @@ class Test_icmpv6_echo_reply(Test_icmpv6_echo_request): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ICMPV6_ECHO_REPLY) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ICMPV6_ECHO_REPLY) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.echo._PACK_STR, six.binary_type(buf[4:])) - eq_(res[0], 0) - eq_(res[1], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) class Test_icmpv6_neighbor_solicit(unittest.TestCase): @@ -271,26 +269,26 @@ class Test_icmpv6_neighbor_solicit(unittest.TestCase): def test_init(self): nd = icmpv6.nd_neighbor(self.res, self.dst) - eq_(nd.res, self.res) - eq_(nd.dst, self.dst) - eq_(nd.option, None) + self.assertEqual(nd.res, self.res) + self.assertEqual(nd.dst, self.dst) + self.assertEqual(nd.option, None) def _test_parser(self, data=None): buf = self.buf + (data or b'') msg, n, _ = icmpv6.icmpv6.parser(buf) - eq_(msg.type_, self.type_) - eq_(msg.code, self.code) - eq_(msg.csum, self.csum) - eq_(msg.data.res, self.res) - eq_(addrconv.ipv6.text_to_bin(msg.data.dst), + self.assertEqual(msg.type_, self.type_) + self.assertEqual(msg.code, self.code) + self.assertEqual(msg.csum, self.csum) + self.assertEqual(msg.data.res, self.res) + self.assertEqual(addrconv.ipv6.text_to_bin(msg.data.dst), addrconv.ipv6.text_to_bin(self.dst)) - eq_(n, None) + self.assertEqual(n, None) if data: nd = msg.data.option - eq_(nd.length, self.nd_length) - eq_(nd.hw_src, self.nd_hw_src) - eq_(nd.data, None) + self.assertEqual(nd.length, self.nd_length) + self.assertEqual(nd.hw_src, self.nd_hw_src) + self.assertEqual(nd.data, None) def test_parser_without_data(self): self._test_parser() @@ -310,12 +308,12 @@ class Test_icmpv6_neighbor_solicit(unittest.TestCase): (res, dst) = struct.unpack_from(nd._PACK_STR, buf, icmp._MIN_LEN) data = buf[(icmp._MIN_LEN + nd._MIN_LEN):] - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, nd_csum) - eq_(res >> 29, self.res) - eq_(dst, addrconv.ipv6.text_to_bin(self.dst)) - eq_(data, b'') + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, nd_csum) + self.assertEqual(res >> 29, self.res) + self.assertEqual(dst, addrconv.ipv6.text_to_bin(self.dst)) + self.assertEqual(data, b'') def test_serialize_with_data(self): nd_opt = icmpv6.nd_option_sla(self.nd_length, self.nd_hw_src) @@ -332,14 +330,14 @@ class Test_icmpv6_neighbor_solicit(unittest.TestCase): nd_opt._PACK_STR, buf, icmp._MIN_LEN + nd._MIN_LEN) data = buf[(icmp._MIN_LEN + nd._MIN_LEN + 8):] - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, nd_csum) - eq_(res >> 29, self.res) - eq_(dst, addrconv.ipv6.text_to_bin(self.dst)) - eq_(nd_type, self.nd_type) - eq_(nd_length, self.nd_length) - eq_(nd_hw_src, addrconv.mac.text_to_bin(self.nd_hw_src)) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, nd_csum) + self.assertEqual(res >> 29, self.res) + self.assertEqual(dst, addrconv.ipv6.text_to_bin(self.dst)) + self.assertEqual(nd_type, self.nd_type) + self.assertEqual(nd_length, self.nd_length) + self.assertEqual(nd_hw_src, addrconv.mac.text_to_bin(self.nd_hw_src)) def test_to_string(self): nd_opt = icmpv6.nd_option_sla(self.nd_length, self.nd_hw_src) @@ -371,8 +369,8 @@ class Test_icmpv6_neighbor_solicit(unittest.TestCase): if k in icmp_values]) ic_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _ic_str) - eq_(str(ic), ic_str) - eq_(repr(ic), ic_str) + self.assertEqual(str(ic), ic_str) + self.assertEqual(repr(ic), ic_str) def test_default_args(self): prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -382,14 +380,14 @@ class Test_icmpv6_neighbor_solicit(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_NEIGHBOR_SOLICIT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_NEIGHBOR_SOLICIT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_neighbor._PACK_STR, six.binary_type(buf[4:])) - eq_(res[0], 0) - eq_(res[1], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], addrconv.ipv6.text_to_bin('::')) # with nd_option_sla prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -401,22 +399,22 @@ class Test_icmpv6_neighbor_solicit(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_NEIGHBOR_SOLICIT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_NEIGHBOR_SOLICIT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_neighbor._PACK_STR, six.binary_type(buf[4:24])) - eq_(res[0], 0) - eq_(res[1], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], addrconv.ipv6.text_to_bin('::')) res = struct.unpack(icmpv6.nd_option_sla._PACK_STR, six.binary_type(buf[24:])) - eq_(res[0], icmpv6.ND_OPTION_SLA) - eq_(res[1], len(icmpv6.nd_option_sla()) // 8) - eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], icmpv6.ND_OPTION_SLA) + self.assertEqual(res[1], len(icmpv6.nd_option_sla()) // 8) + self.assertEqual(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) def test_json(self): nd_opt = icmpv6.nd_option_sla(self.nd_length, self.nd_hw_src) @@ -424,7 +422,7 @@ class Test_icmpv6_neighbor_solicit(unittest.TestCase): ic1 = icmpv6.icmpv6(self.type_, self.code, self.csum, nd) jsondict = ic1.to_jsondict() ic2 = icmpv6.icmpv6.from_jsondict(jsondict['icmpv6']) - eq_(str(ic1), str(ic2)) + self.assertEqual(str(ic1), str(ic2)) class Test_icmpv6_neighbor_advert(Test_icmpv6_neighbor_solicit): @@ -457,14 +455,14 @@ class Test_icmpv6_neighbor_advert(Test_icmpv6_neighbor_solicit): nd_opt._PACK_STR, buf, icmp._MIN_LEN + nd._MIN_LEN) data = buf[(icmp._MIN_LEN + nd._MIN_LEN + 8):] - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, nd_csum) - eq_(res >> 29, self.res) - eq_(dst, addrconv.ipv6.text_to_bin(self.dst)) - eq_(nd_type, self.nd_type) - eq_(nd_length, self.nd_length) - eq_(nd_hw_src, addrconv.mac.text_to_bin(self.nd_hw_src)) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, nd_csum) + self.assertEqual(res >> 29, self.res) + self.assertEqual(dst, addrconv.ipv6.text_to_bin(self.dst)) + self.assertEqual(nd_type, self.nd_type) + self.assertEqual(nd_length, self.nd_length) + self.assertEqual(nd_hw_src, addrconv.mac.text_to_bin(self.nd_hw_src)) def test_to_string(self): nd_opt = icmpv6.nd_option_tla(self.nd_length, self.nd_hw_src) @@ -496,8 +494,8 @@ class Test_icmpv6_neighbor_advert(Test_icmpv6_neighbor_solicit): if k in icmp_values]) ic_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _ic_str) - eq_(str(ic), ic_str) - eq_(repr(ic), ic_str) + self.assertEqual(str(ic), ic_str) + self.assertEqual(repr(ic), ic_str) def test_default_args(self): prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -507,14 +505,14 @@ class Test_icmpv6_neighbor_advert(Test_icmpv6_neighbor_solicit): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_NEIGHBOR_ADVERT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_NEIGHBOR_ADVERT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_neighbor._PACK_STR, six.binary_type(buf[4:])) - eq_(res[0], 0) - eq_(res[1], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], addrconv.ipv6.text_to_bin('::')) # with nd_option_tla prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -526,22 +524,22 @@ class Test_icmpv6_neighbor_advert(Test_icmpv6_neighbor_solicit): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_NEIGHBOR_ADVERT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_NEIGHBOR_ADVERT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_neighbor._PACK_STR, six.binary_type(buf[4:24])) - eq_(res[0], 0) - eq_(res[1], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], addrconv.ipv6.text_to_bin('::')) res = struct.unpack(icmpv6.nd_option_tla._PACK_STR, six.binary_type(buf[24:])) - eq_(res[0], icmpv6.ND_OPTION_TLA) - eq_(res[1], len(icmpv6.nd_option_tla()) // 8) - eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], icmpv6.ND_OPTION_TLA) + self.assertEqual(res[1], len(icmpv6.nd_option_tla()) // 8) + self.assertEqual(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) class Test_icmpv6_router_solicit(unittest.TestCase): @@ -565,24 +563,24 @@ class Test_icmpv6_router_solicit(unittest.TestCase): def test_init(self): rs = icmpv6.nd_router_solicit(self.res) - eq_(rs.res, self.res) - eq_(rs.option, None) + self.assertEqual(rs.res, self.res) + self.assertEqual(rs.option, None) def _test_parser(self, data=None): buf = self.buf + (data or b'') msg, n, _ = icmpv6.icmpv6.parser(buf) - eq_(msg.type_, self.type_) - eq_(msg.code, self.code) - eq_(msg.csum, self.csum) + self.assertEqual(msg.type_, self.type_) + self.assertEqual(msg.code, self.code) + self.assertEqual(msg.csum, self.csum) if data is not None: - eq_(msg.data.res, self.res) - eq_(n, None) + self.assertEqual(msg.data.res, self.res) + self.assertEqual(n, None) if data: rs = msg.data.option - eq_(rs.length, self.nd_length) - eq_(rs.hw_src, self.nd_hw_src) - eq_(rs.data, None) + self.assertEqual(rs.length, self.nd_length) + self.assertEqual(rs.hw_src, self.nd_hw_src) + self.assertEqual(rs.data, None) def test_parser_without_data(self): self._test_parser() @@ -602,11 +600,11 @@ class Test_icmpv6_router_solicit(unittest.TestCase): res = struct.unpack_from(rs._PACK_STR, buf, icmp._MIN_LEN) data = buf[(icmp._MIN_LEN + rs._MIN_LEN):] - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, rs_csum) - eq_(res[0], self.res) - eq_(data, b'') + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, rs_csum) + self.assertEqual(res[0], self.res) + self.assertEqual(data, b'') def test_serialize_with_data(self): nd_opt = icmpv6.nd_option_sla(self.nd_length, self.nd_hw_src) @@ -623,13 +621,13 @@ class Test_icmpv6_router_solicit(unittest.TestCase): nd_opt._PACK_STR, buf, icmp._MIN_LEN + rs._MIN_LEN) data = buf[(icmp._MIN_LEN + rs._MIN_LEN + 8):] - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, rs_csum) - eq_(res[0], self.res) - eq_(nd_type, self.nd_type) - eq_(nd_length, self.nd_length) - eq_(nd_hw_src, addrconv.mac.text_to_bin(self.nd_hw_src)) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, rs_csum) + self.assertEqual(res[0], self.res) + self.assertEqual(nd_type, self.nd_type) + self.assertEqual(nd_length, self.nd_length) + self.assertEqual(nd_hw_src, addrconv.mac.text_to_bin(self.nd_hw_src)) def test_to_string(self): nd_opt = icmpv6.nd_option_sla(self.nd_length, self.nd_hw_src) @@ -660,8 +658,8 @@ class Test_icmpv6_router_solicit(unittest.TestCase): if k in icmp_values]) ic_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _ic_str) - eq_(str(ic), ic_str) - eq_(repr(ic), ic_str) + self.assertEqual(str(ic), ic_str) + self.assertEqual(repr(ic), ic_str) def test_default_args(self): prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -671,14 +669,14 @@ class Test_icmpv6_router_solicit(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_ROUTER_SOLICIT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_ROUTER_SOLICIT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_router_solicit._PACK_STR, six.binary_type(buf[4:])) - eq_(res[0], 0) + self.assertEqual(res[0], 0) # with nd_option_sla prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -690,21 +688,21 @@ class Test_icmpv6_router_solicit(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_ROUTER_SOLICIT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_ROUTER_SOLICIT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_router_solicit._PACK_STR, six.binary_type(buf[4:8])) - eq_(res[0], 0) + self.assertEqual(res[0], 0) res = struct.unpack(icmpv6.nd_option_sla._PACK_STR, six.binary_type(buf[8:])) - eq_(res[0], icmpv6.ND_OPTION_SLA) - eq_(res[1], len(icmpv6.nd_option_sla()) // 8) - eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], icmpv6.ND_OPTION_SLA) + self.assertEqual(res[1], len(icmpv6.nd_option_sla()) // 8) + self.assertEqual(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) def test_json(self): nd_opt = icmpv6.nd_option_sla(self.nd_length, self.nd_hw_src) @@ -712,7 +710,7 @@ class Test_icmpv6_router_solicit(unittest.TestCase): ic1 = icmpv6.icmpv6(self.type_, self.code, self.csum, rs) jsondict = ic1.to_jsondict() ic2 = icmpv6.icmpv6.from_jsondict(jsondict['icmpv6']) - eq_(str(ic1), str(ic2)) + self.assertEqual(str(ic1), str(ic2)) class Test_icmpv6_router_advert(unittest.TestCase): @@ -731,18 +729,18 @@ class Test_icmpv6_router_advert(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_ROUTER_ADVERT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_ROUTER_ADVERT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_router_advert._PACK_STR, six.binary_type(buf[4:])) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) # with nd_option_sla prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -754,25 +752,25 @@ class Test_icmpv6_router_advert(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_ROUTER_ADVERT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_ROUTER_ADVERT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_router_advert._PACK_STR, six.binary_type(buf[4:16])) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) res = struct.unpack(icmpv6.nd_option_sla._PACK_STR, six.binary_type(buf[16:])) - eq_(res[0], icmpv6.ND_OPTION_SLA) - eq_(res[1], len(icmpv6.nd_option_sla()) // 8) - eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], icmpv6.ND_OPTION_SLA) + self.assertEqual(res[1], len(icmpv6.nd_option_sla()) // 8) + self.assertEqual(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) # with nd_option_pi prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -784,30 +782,30 @@ class Test_icmpv6_router_advert(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_ROUTER_ADVERT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_ROUTER_ADVERT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_router_advert._PACK_STR, six.binary_type(buf[4:16])) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) res = struct.unpack(icmpv6.nd_option_pi._PACK_STR, six.binary_type(buf[16:])) - eq_(res[0], icmpv6.ND_OPTION_PI) - eq_(res[1], 4) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 0) - eq_(res[5], 0) - eq_(res[6], 0) - eq_(res[7], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], icmpv6.ND_OPTION_PI) + self.assertEqual(res[1], 4) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], 0) + self.assertEqual(res[7], addrconv.ipv6.text_to_bin('::')) # with nd_option_sla and nd_option_pi prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -819,37 +817,37 @@ class Test_icmpv6_router_advert(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_ROUTER_ADVERT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_ROUTER_ADVERT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_router_advert._PACK_STR, six.binary_type(buf[4:16])) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) res = struct.unpack(icmpv6.nd_option_sla._PACK_STR, six.binary_type(buf[16:24])) - eq_(res[0], icmpv6.ND_OPTION_SLA) - eq_(res[1], len(icmpv6.nd_option_sla()) // 8) - eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], icmpv6.ND_OPTION_SLA) + self.assertEqual(res[1], len(icmpv6.nd_option_sla()) // 8) + self.assertEqual(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) res = struct.unpack(icmpv6.nd_option_pi._PACK_STR, six.binary_type(buf[24:])) - eq_(res[0], icmpv6.ND_OPTION_PI) - eq_(res[1], len(icmpv6.nd_option_pi()) // 8) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 0) - eq_(res[5], 0) - eq_(res[6], 0) - eq_(res[7], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], icmpv6.ND_OPTION_PI) + self.assertEqual(res[1], len(icmpv6.nd_option_pi()) // 8) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], 0) + self.assertEqual(res[7], addrconv.ipv6.text_to_bin('::')) def test_json(self): ic1 = icmpv6.icmpv6( @@ -858,7 +856,7 @@ class Test_icmpv6_router_advert(unittest.TestCase): options=[icmpv6.nd_option_sla(), icmpv6.nd_option_pi()])) jsondict = ic1.to_jsondict() ic2 = icmpv6.icmpv6.from_jsondict(jsondict['icmpv6']) - eq_(str(ic1), str(ic2)) + self.assertEqual(str(ic1), str(ic2)) class Test_icmpv6_nd_option_la(unittest.TestCase): @@ -874,9 +872,9 @@ class Test_icmpv6_nd_option_la(unittest.TestCase): buf = la.serialize() res = struct.unpack(icmpv6.nd_option_sla._PACK_STR, six.binary_type(buf)) - eq_(res[0], icmpv6.ND_OPTION_SLA) - eq_(res[1], len(icmpv6.nd_option_sla()) // 8) - eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], icmpv6.ND_OPTION_SLA) + self.assertEqual(res[1], len(icmpv6.nd_option_sla()) // 8) + self.assertEqual(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) # with nd_neighbor prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -888,22 +886,22 @@ class Test_icmpv6_nd_option_la(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_NEIGHBOR_ADVERT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_NEIGHBOR_ADVERT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_neighbor._PACK_STR, six.binary_type(buf[4:24])) - eq_(res[0], 0) - eq_(res[1], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], addrconv.ipv6.text_to_bin('::')) res = struct.unpack(icmpv6.nd_option_tla._PACK_STR, six.binary_type(buf[24:])) - eq_(res[0], icmpv6.ND_OPTION_TLA) - eq_(res[1], len(icmpv6.nd_option_tla()) // 8) - eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], icmpv6.ND_OPTION_TLA) + self.assertEqual(res[1], len(icmpv6.nd_option_tla()) // 8) + self.assertEqual(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) # with nd_router_solicit prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -915,21 +913,21 @@ class Test_icmpv6_nd_option_la(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_ROUTER_SOLICIT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_ROUTER_SOLICIT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_router_solicit._PACK_STR, six.binary_type(buf[4:8])) - eq_(res[0], 0) + self.assertEqual(res[0], 0) res = struct.unpack(icmpv6.nd_option_sla._PACK_STR, six.binary_type(buf[8:])) - eq_(res[0], icmpv6.ND_OPTION_SLA) - eq_(res[1], len(icmpv6.nd_option_sla()) // 8) - eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) + self.assertEqual(res[0], icmpv6.ND_OPTION_SLA) + self.assertEqual(res[1], len(icmpv6.nd_option_sla()) // 8) + self.assertEqual(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00')) class Test_icmpv6_nd_option_pi(unittest.TestCase): @@ -945,14 +943,14 @@ class Test_icmpv6_nd_option_pi(unittest.TestCase): buf = pi.serialize() res = struct.unpack(icmpv6.nd_option_pi._PACK_STR, six.binary_type(buf)) - eq_(res[0], icmpv6.ND_OPTION_PI) - eq_(res[1], len(icmpv6.nd_option_pi()) // 8) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 0) - eq_(res[5], 0) - eq_(res[6], 0) - eq_(res[7], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], icmpv6.ND_OPTION_PI) + self.assertEqual(res[1], len(icmpv6.nd_option_pi()) // 8) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], 0) + self.assertEqual(res[7], addrconv.ipv6.text_to_bin('::')) # with nd_router_advert prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -964,30 +962,30 @@ class Test_icmpv6_nd_option_pi(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.ND_ROUTER_ADVERT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.ND_ROUTER_ADVERT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.nd_router_advert._PACK_STR, six.binary_type(buf[4:16])) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) res = struct.unpack(icmpv6.nd_option_pi._PACK_STR, six.binary_type(buf[16:])) - eq_(res[0], icmpv6.ND_OPTION_PI) - eq_(res[1], 4) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 0) - eq_(res[5], 0) - eq_(res[6], 0) - eq_(res[7], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], icmpv6.ND_OPTION_PI) + self.assertEqual(res[1], 4) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], 0) + self.assertEqual(res[7], addrconv.ipv6.text_to_bin('::')) class Test_icmpv6_membership_query(unittest.TestCase): @@ -1008,18 +1006,18 @@ class Test_icmpv6_membership_query(unittest.TestCase): def test_init(self): mld = icmpv6.mld(self.maxresp, self.address) - eq_(mld.maxresp, self.maxresp) - eq_(mld.address, self.address) + self.assertEqual(mld.maxresp, self.maxresp) + self.assertEqual(mld.address, self.address) def test_parser(self): msg, n, _ = icmpv6.icmpv6.parser(self.buf) - eq_(msg.type_, self.type_) - eq_(msg.code, self.code) - eq_(msg.csum, self.csum) - eq_(msg.data.maxresp, self.maxresp) - eq_(msg.data.address, self.address) - eq_(n, None) + self.assertEqual(msg.type_, self.type_) + self.assertEqual(msg.code, self.code) + self.assertEqual(msg.csum, self.csum) + self.assertEqual(msg.data.maxresp, self.maxresp) + self.assertEqual(msg.data.address, self.address) + self.assertEqual(n, None) def test_serialize(self): src_ipv6 = '3ffe:507:0:1:200:86ff:fe05:80da' @@ -1035,11 +1033,11 @@ class Test_icmpv6_membership_query(unittest.TestCase): (maxresp, address) = struct.unpack_from( mld._PACK_STR, buf, icmp._MIN_LEN) - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, mld_csum) - eq_(maxresp, self.maxresp) - eq_(address, addrconv.ipv6.text_to_bin(self.address)) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, mld_csum) + self.assertEqual(maxresp, self.maxresp) + self.assertEqual(address, addrconv.ipv6.text_to_bin(self.address)) def test_to_string(self): ml = icmpv6.mld(self.maxresp, self.address) @@ -1061,8 +1059,8 @@ class Test_icmpv6_membership_query(unittest.TestCase): if k in icmp_values]) ic_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _ic_str) - eq_(str(ic), ic_str) - eq_(repr(ic), ic_str) + self.assertEqual(str(ic), ic_str) + self.assertEqual(repr(ic), ic_str) def test_default_args(self): prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -1072,14 +1070,14 @@ class Test_icmpv6_membership_query(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.MLD_LISTENER_QUERY) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.MLD_LISTENER_QUERY) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.mld._PACK_STR, six.binary_type(buf[4:])) - eq_(res[0], 0) - eq_(res[1], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], addrconv.ipv6.text_to_bin('::')) def test_json(self): ic1 = icmpv6.icmpv6( @@ -1087,7 +1085,7 @@ class Test_icmpv6_membership_query(unittest.TestCase): data=icmpv6.mld()) jsondict = ic1.to_jsondict() ic2 = icmpv6.icmpv6.from_jsondict(jsondict['icmpv6']) - eq_(str(ic1), str(ic2)) + self.assertEqual(str(ic1), str(ic2)) class Test_icmpv6_membership_report(Test_icmpv6_membership_query): @@ -1106,7 +1104,7 @@ class Test_icmpv6_membership_report(Test_icmpv6_membership_query): data=icmpv6.mld()) jsondict = ic1.to_jsondict() ic2 = icmpv6.icmpv6.from_jsondict(jsondict['icmpv6']) - eq_(str(ic1), str(ic2)) + self.assertEqual(str(ic1), str(ic2)) class Test_icmpv6_membership_done(Test_icmpv6_membership_query): @@ -1125,7 +1123,7 @@ class Test_icmpv6_membership_done(Test_icmpv6_membership_query): data=icmpv6.mld()) jsondict = ic1.to_jsondict() ic2 = icmpv6.icmpv6.from_jsondict(jsondict['icmpv6']) - eq_(str(ic1), str(ic2)) + self.assertEqual(str(ic1), str(ic2)) class Test_mldv2_query(unittest.TestCase): @@ -1176,13 +1174,13 @@ class Test_mldv2_query(unittest.TestCase): return p def test_init(self): - eq_(self.mld.maxresp, self.maxresp) - eq_(self.mld.address, self.address) - eq_(self.mld.s_flg, self.s_flg) - eq_(self.mld.qrv, self.qrv) - eq_(self.mld.qqic, self.qqic) - eq_(self.mld.num, self.num) - eq_(self.mld.srcs, self.srcs) + self.assertEqual(self.mld.maxresp, self.maxresp) + self.assertEqual(self.mld.address, self.address) + self.assertEqual(self.mld.s_flg, self.s_flg) + self.assertEqual(self.mld.qrv, self.qrv) + self.assertEqual(self.mld.qqic, self.qqic) + self.assertEqual(self.mld.num, self.num) + self.assertEqual(self.mld.srcs, self.srcs) def test_init_with_srcs(self): self.setUp_with_srcs() @@ -1191,17 +1189,17 @@ class Test_mldv2_query(unittest.TestCase): def test_parser(self): msg, n, _ = icmpv6.icmpv6.parser(self.buf) - eq_(msg.type_, self.type_) - eq_(msg.code, self.code) - eq_(msg.csum, self.csum) - eq_(msg.data.maxresp, self.maxresp) - eq_(msg.data.address, self.address) - eq_(msg.data.s_flg, self.s_flg) - eq_(msg.data.qrv, self.qrv) - eq_(msg.data.qqic, self.qqic) - eq_(msg.data.num, self.num) - eq_(msg.data.srcs, self.srcs) - eq_(n, None) + self.assertEqual(msg.type_, self.type_) + self.assertEqual(msg.code, self.code) + self.assertEqual(msg.csum, self.csum) + self.assertEqual(msg.data.maxresp, self.maxresp) + self.assertEqual(msg.data.address, self.address) + self.assertEqual(msg.data.s_flg, self.s_flg) + self.assertEqual(msg.data.qrv, self.qrv) + self.assertEqual(msg.data.qqic, self.qqic) + self.assertEqual(msg.data.num, self.num) + self.assertEqual(msg.data.srcs, self.srcs) + self.assertEqual(n, None) def test_parser_with_srcs(self): self.setUp_with_srcs() @@ -1221,17 +1219,17 @@ class Test_mldv2_query(unittest.TestCase): (maxresp, address, s_qrv, qqic, num) = struct.unpack_from( self.mld._PACK_STR, six.binary_type(buf), icmp._MIN_LEN) - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, mld_csum) - eq_(maxresp, self.maxresp) - eq_(address, addrconv.ipv6.text_to_bin(self.address)) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, mld_csum) + self.assertEqual(maxresp, self.maxresp) + self.assertEqual(address, addrconv.ipv6.text_to_bin(self.address)) s_flg = (s_qrv >> 3) & 0b1 qrv = s_qrv & 0b111 - eq_(s_flg, self.s_flg) - eq_(qrv, self.qrv) - eq_(qqic, self.qqic) - eq_(num, self.num) + self.assertEqual(s_flg, self.s_flg) + self.assertEqual(qrv, self.qrv) + self.assertEqual(qqic, self.qqic) + self.assertEqual(num, self.num) def test_serialize_with_srcs(self): self.setUp_with_srcs() @@ -1250,19 +1248,19 @@ class Test_mldv2_query(unittest.TestCase): (addr1, addr2) = struct.unpack_from( '!16s16s', six.binary_type(buf), icmp._MIN_LEN + self.mld._MIN_LEN) - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, mld_csum) - eq_(maxresp, self.maxresp) - eq_(address, addrconv.ipv6.text_to_bin(self.address)) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, mld_csum) + self.assertEqual(maxresp, self.maxresp) + self.assertEqual(address, addrconv.ipv6.text_to_bin(self.address)) s_flg = (s_qrv >> 3) & 0b1 qrv = s_qrv & 0b111 - eq_(s_flg, self.s_flg) - eq_(qrv, self.qrv) - eq_(qqic, self.qqic) - eq_(num, self.num) - eq_(addr1, addrconv.ipv6.text_to_bin(self.srcs[0])) - eq_(addr2, addrconv.ipv6.text_to_bin(self.srcs[1])) + self.assertEqual(s_flg, self.s_flg) + self.assertEqual(qrv, self.qrv) + self.assertEqual(qqic, self.qqic) + self.assertEqual(num, self.num) + self.assertEqual(addr1, addrconv.ipv6.text_to_bin(self.srcs[0])) + self.assertEqual(addr2, addrconv.ipv6.text_to_bin(self.srcs[1])) def _build_mldv2_query(self): e = ethernet(ethertype=ether.ETH_TYPE_IPV6) @@ -1276,23 +1274,23 @@ class Test_mldv2_query(unittest.TestCase): p = self._build_mldv2_query() e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_IPV6) + self.assertTrue(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_IPV6) i = self.find_protocol(p, "ipv6") - ok_(i) - eq_(i.nxt, inet.IPPROTO_ICMPV6) + self.assertTrue(i) + self.assertEqual(i.nxt, inet.IPPROTO_ICMPV6) ic = self.find_protocol(p, "icmpv6") - ok_(ic) - eq_(ic.type_, icmpv6.MLD_LISTENER_QUERY) + self.assertTrue(ic) + self.assertEqual(ic.type_, icmpv6.MLD_LISTENER_QUERY) - eq_(ic.data.maxresp, self.maxresp) - eq_(ic.data.address, self.address) - eq_(ic.data.s_flg, self.s_flg) - eq_(ic.data.qrv, self.qrv) - eq_(ic.data.num, self.num) - eq_(ic.data.srcs, self.srcs) + self.assertEqual(ic.data.maxresp, self.maxresp) + self.assertEqual(ic.data.address, self.address) + self.assertEqual(ic.data.s_flg, self.s_flg) + self.assertEqual(ic.data.qrv, self.qrv) + self.assertEqual(ic.data.num, self.num) + self.assertEqual(ic.data.srcs, self.srcs) def test_build_mldv2_query_with_srcs(self): self.setUp_with_srcs() @@ -1322,14 +1320,13 @@ class Test_mldv2_query(unittest.TestCase): if k in icmp_values]) ic_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _ic_str) - eq_(str(ic), ic_str) - eq_(repr(ic), ic_str) + self.assertEqual(str(ic), ic_str) + self.assertEqual(repr(ic), ic_str) def test_to_string_with_srcs(self): self.setUp_with_srcs() self.test_to_string() - @raises(AssertionError) def test_num_larger_than_srcs(self): self.srcs = ['ff80::1', 'ff80::2', 'ff80::3'] self.num = len(self.srcs) + 1 @@ -1342,9 +1339,8 @@ class Test_mldv2_query(unittest.TestCase): self.mld = icmpv6.mldv2_query( self.maxresp, self.address, self.s_flg, self.qrv, self.qqic, self.num, self.srcs) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) - @raises(AssertionError) def test_num_smaller_than_srcs(self): self.srcs = ['ff80::1', 'ff80::2', 'ff80::3'] self.num = len(self.srcs) - 1 @@ -1357,7 +1353,7 @@ class Test_mldv2_query(unittest.TestCase): self.mld = icmpv6.mldv2_query( self.maxresp, self.address, self.s_flg, self.qrv, self.qqic, self.num, self.srcs) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) def test_default_args(self): prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -1367,17 +1363,17 @@ class Test_mldv2_query(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.MLD_LISTENER_QUERY) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.MLD_LISTENER_QUERY) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.mldv2_query._PACK_STR, six.binary_type(buf[4:])) - eq_(res[0], 0) - eq_(res[1], addrconv.ipv6.text_to_bin('::')) - eq_(res[2], 2) - eq_(res[3], 0) - eq_(res[4], 0) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[2], 2) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 0) # srcs without num srcs = ['ff80::1', 'ff80::2', 'ff80::3'] @@ -1386,23 +1382,23 @@ class Test_mldv2_query(unittest.TestCase): res = struct.unpack_from( icmpv6.mldv2_query._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], addrconv.ipv6.text_to_bin('::')) - eq_(res[2], 2) - eq_(res[3], 0) - eq_(res[4], len(srcs)) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[2], 2) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], len(srcs)) (src1, src2, src3) = struct.unpack_from( '16s16s16s', six.binary_type(buf), icmpv6.mldv2_query._MIN_LEN) - eq_(src1, addrconv.ipv6.text_to_bin(srcs[0])) - eq_(src2, addrconv.ipv6.text_to_bin(srcs[1])) - eq_(src3, addrconv.ipv6.text_to_bin(srcs[2])) + self.assertEqual(src1, addrconv.ipv6.text_to_bin(srcs[0])) + self.assertEqual(src2, addrconv.ipv6.text_to_bin(srcs[1])) + self.assertEqual(src3, addrconv.ipv6.text_to_bin(srcs[2])) def test_json(self): jsondict = self.mld.to_jsondict() mld = icmpv6.mldv2_query.from_jsondict(jsondict['mldv2_query']) - eq_(str(self.mld), str(mld)) + self.assertEqual(str(self.mld), str(mld)) def test_json_with_srcs(self): self.setUp_with_srcs() @@ -1471,8 +1467,8 @@ class Test_mldv2_report(unittest.TestCase): return p def test_init(self): - eq_(self.mld.record_num, self.record_num) - eq_(self.mld.records, self.records) + self.assertEqual(self.mld.record_num, self.record_num) + self.assertEqual(self.mld.records, self.records) def test_init_with_records(self): self.setUp_with_records() @@ -1481,11 +1477,11 @@ class Test_mldv2_report(unittest.TestCase): def test_parser(self): msg, n, _ = icmpv6.icmpv6.parser(self.buf) - eq_(msg.type_, self.type_) - eq_(msg.code, self.code) - eq_(msg.csum, self.csum) - eq_(msg.data.record_num, self.record_num) - eq_(repr(msg.data.records), repr(self.records)) + self.assertEqual(msg.type_, self.type_) + self.assertEqual(msg.code, self.code) + self.assertEqual(msg.csum, self.csum) + self.assertEqual(msg.data.record_num, self.record_num) + self.assertEqual(repr(msg.data.records), repr(self.records)) def test_parser_with_records(self): self.setUp_with_records() @@ -1505,10 +1501,10 @@ class Test_mldv2_report(unittest.TestCase): (record_num, ) = struct.unpack_from( self.mld._PACK_STR, six.binary_type(buf), icmp._MIN_LEN) - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, mld_csum) - eq_(record_num, self.record_num) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, mld_csum) + self.assertEqual(record_num, self.record_num) def test_serialize_with_records(self): self.setUp_with_records() @@ -1533,14 +1529,14 @@ class Test_mldv2_report(unittest.TestCase): offset += len(rec3) rec4 = icmpv6.mldv2_report_group.parser(buf[offset:]) - eq_(type_, self.type_) - eq_(code, self.code) - eq_(csum, mld_csum) - eq_(record_num, self.record_num) - eq_(repr(rec1), repr(self.record1)) - eq_(repr(rec2), repr(self.record2)) - eq_(repr(rec3), repr(self.record3)) - eq_(repr(rec4), repr(self.record4)) + self.assertEqual(type_, self.type_) + self.assertEqual(code, self.code) + self.assertEqual(csum, mld_csum) + self.assertEqual(record_num, self.record_num) + self.assertEqual(repr(rec1), repr(self.record1)) + self.assertEqual(repr(rec2), repr(self.record2)) + self.assertEqual(repr(rec3), repr(self.record3)) + self.assertEqual(repr(rec4), repr(self.record4)) def _build_mldv2_report(self): e = ethernet(ethertype=ether.ETH_TYPE_IPV6) @@ -1554,19 +1550,19 @@ class Test_mldv2_report(unittest.TestCase): p = self._build_mldv2_report() e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_IPV6) + self.assertTrue(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_IPV6) i = self.find_protocol(p, "ipv6") - ok_(i) - eq_(i.nxt, inet.IPPROTO_ICMPV6) + self.assertTrue(i) + self.assertEqual(i.nxt, inet.IPPROTO_ICMPV6) ic = self.find_protocol(p, "icmpv6") - ok_(ic) - eq_(ic.type_, icmpv6.MLDV2_LISTENER_REPORT) + self.assertTrue(ic) + self.assertEqual(ic.type_, icmpv6.MLDV2_LISTENER_REPORT) - eq_(ic.data.record_num, self.record_num) - eq_(ic.data.records, self.records) + self.assertEqual(ic.data.record_num, self.record_num) + self.assertEqual(ic.data.records, self.records) def test_build_mldv2_report_with_records(self): self.setUp_with_records() @@ -1591,14 +1587,13 @@ class Test_mldv2_report(unittest.TestCase): if k in icmp_values]) ic_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _ic_str) - eq_(str(ic), ic_str) - eq_(repr(ic), ic_str) + self.assertEqual(str(ic), ic_str) + self.assertEqual(repr(ic), ic_str) def test_to_string_with_records(self): self.setUp_with_records() self.test_to_string() - @raises(AssertionError) def test_record_num_larger_than_records(self): self.record1 = icmpv6.mldv2_report_group( icmpv6.MODE_IS_INCLUDE, 0, 0, 'ff00::1') @@ -1620,9 +1615,8 @@ class Test_mldv2_report(unittest.TestCase): self.buf += self.record3.serialize() self.buf += self.record4.serialize() self.mld = icmpv6.mldv2_report(self.record_num, self.records) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) - @raises(AssertionError) def test_record_num_smaller_than_records(self): self.record1 = icmpv6.mldv2_report_group( icmpv6.MODE_IS_INCLUDE, 0, 0, 'ff00::1') @@ -1644,7 +1638,7 @@ class Test_mldv2_report(unittest.TestCase): self.buf += self.record3.serialize() self.buf += self.record4.serialize() self.mld = icmpv6.mldv2_report(self.record_num, self.records) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) def test_default_args(self): prev = ipv6(nxt=inet.IPPROTO_ICMPV6) @@ -1654,13 +1648,13 @@ class Test_mldv2_report(unittest.TestCase): buf = ic.serialize(bytearray(), prev) res = struct.unpack(icmpv6.icmpv6._PACK_STR, six.binary_type(buf[:4])) - eq_(res[0], icmpv6.MLDV2_LISTENER_REPORT) - eq_(res[1], 0) - eq_(res[2], icmpv6_csum(prev, buf)) + self.assertEqual(res[0], icmpv6.MLDV2_LISTENER_REPORT) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], icmpv6_csum(prev, buf)) res = struct.unpack(icmpv6.mldv2_report._PACK_STR, six.binary_type(buf[4:])) - eq_(res[0], 0) + self.assertEqual(res[0], 0) # records without record_num record1 = icmpv6.mldv2_report_group( @@ -1674,26 +1668,26 @@ class Test_mldv2_report(unittest.TestCase): res = struct.unpack_from( icmpv6.mldv2_report._PACK_STR, six.binary_type(buf)) - eq_(res[0], len(records)) + self.assertEqual(res[0], len(records)) res = struct.unpack_from( icmpv6.mldv2_report_group._PACK_STR, six.binary_type(buf), icmpv6.mldv2_report._MIN_LEN) - eq_(res[0], icmpv6.MODE_IS_INCLUDE) - eq_(res[1], 0) - eq_(res[2], 0) - eq_(res[3], addrconv.ipv6.text_to_bin('ff00::1')) + self.assertEqual(res[0], icmpv6.MODE_IS_INCLUDE) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], addrconv.ipv6.text_to_bin('ff00::1')) res = struct.unpack_from( icmpv6.mldv2_report_group._PACK_STR, six.binary_type(buf), icmpv6.mldv2_report._MIN_LEN + icmpv6.mldv2_report_group._MIN_LEN) - eq_(res[0], icmpv6.MODE_IS_INCLUDE) - eq_(res[1], 0) - eq_(res[2], 2) - eq_(res[3], addrconv.ipv6.text_to_bin('ff00::2')) + self.assertEqual(res[0], icmpv6.MODE_IS_INCLUDE) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 2) + self.assertEqual(res[3], addrconv.ipv6.text_to_bin('ff00::2')) res = struct.unpack_from( '16s16s', six.binary_type(buf), @@ -1701,13 +1695,13 @@ class Test_mldv2_report(unittest.TestCase): icmpv6.mldv2_report_group._MIN_LEN + icmpv6.mldv2_report_group._MIN_LEN) - eq_(res[0], addrconv.ipv6.text_to_bin('fe80::1')) - eq_(res[1], addrconv.ipv6.text_to_bin('fe80::2')) + self.assertEqual(res[0], addrconv.ipv6.text_to_bin('fe80::1')) + self.assertEqual(res[1], addrconv.ipv6.text_to_bin('fe80::2')) def test_json(self): jsondict = self.mld.to_jsondict() mld = icmpv6.mldv2_report.from_jsondict(jsondict['mldv2_report']) - eq_(str(self.mld), str(mld)) + self.assertEqual(str(self.mld), str(mld)) def test_json_with_records(self): self.setUp_with_records() @@ -1780,12 +1774,12 @@ class Test_mldv2_report_group(unittest.TestCase): pass def test_init(self): - eq_(self.mld.type_, self.type_) - eq_(self.mld.aux_len, self.aux_len) - eq_(self.mld.num, self.num) - eq_(self.mld.address, self.address) - eq_(self.mld.srcs, self.srcs) - eq_(self.mld.aux, self.aux) + self.assertEqual(self.mld.type_, self.type_) + self.assertEqual(self.mld.aux_len, self.aux_len) + self.assertEqual(self.mld.num, self.num) + self.assertEqual(self.mld.address, self.address) + self.assertEqual(self.mld.srcs, self.srcs) + self.assertEqual(self.mld.aux, self.aux) def test_init_with_srcs(self): self.setUp_with_srcs() @@ -1806,12 +1800,12 @@ class Test_mldv2_report_group(unittest.TestCase): else: res = _res - eq_(res.type_, self.type_) - eq_(res.aux_len, self.aux_len) - eq_(res.num, self.num) - eq_(res.address, self.address) - eq_(res.srcs, self.srcs) - eq_(res.aux, self.aux) + self.assertEqual(res.type_, self.type_) + self.assertEqual(res.aux_len, self.aux_len) + self.assertEqual(res.num, self.num) + self.assertEqual(res.address, self.address) + self.assertEqual(res.srcs, self.srcs) + self.assertEqual(res.aux, self.aux) def test_parser_with_srcs(self): self.setUp_with_srcs() @@ -1830,10 +1824,10 @@ class Test_mldv2_report_group(unittest.TestCase): res = struct.unpack_from( icmpv6.mldv2_report_group._PACK_STR, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.aux_len) - eq_(res[2], self.num) - eq_(res[3], addrconv.ipv6.text_to_bin(self.address)) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.aux_len) + self.assertEqual(res[2], self.num) + self.assertEqual(res[3], addrconv.ipv6.text_to_bin(self.address)) def test_serialize_with_srcs(self): self.setUp_with_srcs() @@ -1842,13 +1836,13 @@ class Test_mldv2_report_group(unittest.TestCase): icmpv6.mldv2_report_group._PACK_STR, six.binary_type(buf)) (src1, src2, src3) = struct.unpack_from( '16s16s16s', six.binary_type(buf), icmpv6.mldv2_report_group._MIN_LEN) - eq_(res[0], self.type_) - eq_(res[1], self.aux_len) - eq_(res[2], self.num) - eq_(res[3], addrconv.ipv6.text_to_bin(self.address)) - eq_(src1, addrconv.ipv6.text_to_bin(self.srcs[0])) - eq_(src2, addrconv.ipv6.text_to_bin(self.srcs[1])) - eq_(src3, addrconv.ipv6.text_to_bin(self.srcs[2])) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.aux_len) + self.assertEqual(res[2], self.num) + self.assertEqual(res[3], addrconv.ipv6.text_to_bin(self.address)) + self.assertEqual(src1, addrconv.ipv6.text_to_bin(self.srcs[0])) + self.assertEqual(src2, addrconv.ipv6.text_to_bin(self.srcs[1])) + self.assertEqual(src3, addrconv.ipv6.text_to_bin(self.srcs[2])) def test_serialize_with_aux(self): self.setUp_with_aux() @@ -1858,11 +1852,11 @@ class Test_mldv2_report_group(unittest.TestCase): (aux, ) = struct.unpack_from( '%ds' % (self.aux_len * 4), six.binary_type(buf), icmpv6.mldv2_report_group._MIN_LEN) - eq_(res[0], self.type_) - eq_(res[1], self.aux_len) - eq_(res[2], self.num) - eq_(res[3], addrconv.ipv6.text_to_bin(self.address)) - eq_(aux, self.aux) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.aux_len) + self.assertEqual(res[2], self.num) + self.assertEqual(res[3], addrconv.ipv6.text_to_bin(self.address)) + self.assertEqual(aux, self.aux) def test_serialize_with_srcs_and_aux(self): self.setUp_with_srcs_and_aux() @@ -1874,14 +1868,14 @@ class Test_mldv2_report_group(unittest.TestCase): (aux, ) = struct.unpack_from( '%ds' % (self.aux_len * 4), six.binary_type(buf), icmpv6.mldv2_report_group._MIN_LEN + 16 * 3) - eq_(res[0], self.type_) - eq_(res[1], self.aux_len) - eq_(res[2], self.num) - eq_(res[3], addrconv.ipv6.text_to_bin(self.address)) - eq_(src1, addrconv.ipv6.text_to_bin(self.srcs[0])) - eq_(src2, addrconv.ipv6.text_to_bin(self.srcs[1])) - eq_(src3, addrconv.ipv6.text_to_bin(self.srcs[2])) - eq_(aux, self.aux) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.aux_len) + self.assertEqual(res[2], self.num) + self.assertEqual(res[3], addrconv.ipv6.text_to_bin(self.address)) + self.assertEqual(src1, addrconv.ipv6.text_to_bin(self.srcs[0])) + self.assertEqual(src2, addrconv.ipv6.text_to_bin(self.srcs[1])) + self.assertEqual(src3, addrconv.ipv6.text_to_bin(self.srcs[2])) + self.assertEqual(aux, self.aux) def test_to_string(self): igmp_values = {'type_': repr(self.type_), @@ -1895,8 +1889,8 @@ class Test_mldv2_report_group(unittest.TestCase): if k in igmp_values]) g_str = '%s(%s)' % (icmpv6.mldv2_report_group.__name__, _g_str) - eq_(str(self.mld), g_str) - eq_(repr(self.mld), g_str) + self.assertEqual(str(self.mld), g_str) + self.assertEqual(repr(self.mld), g_str) def test_to_string_with_srcs(self): self.setUp_with_srcs() @@ -1911,21 +1905,20 @@ class Test_mldv2_report_group(unittest.TestCase): self.test_to_string() def test_len(self): - eq_(len(self.mld), 20) + self.assertEqual(len(self.mld), 20) def test_len_with_srcs(self): self.setUp_with_srcs() - eq_(len(self.mld), 68) + self.assertEqual(len(self.mld), 68) def test_len_with_aux(self): self.setUp_with_aux() - eq_(len(self.mld), 28) + self.assertEqual(len(self.mld), 28) def test_len_with_srcs_and_aux(self): self.setUp_with_srcs_and_aux() - eq_(len(self.mld), 76) + self.assertEqual(len(self.mld), 76) - @raises(AssertionError) def test_num_larger_than_srcs(self): self.srcs = ['fe80::1', 'fe80::2', 'fe80::3'] self.num = len(self.srcs) + 1 @@ -1937,9 +1930,8 @@ class Test_mldv2_report_group(unittest.TestCase): self.mld = icmpv6.mldv2_report_group( self.type_, self.aux_len, self.num, self.address, self.srcs, self.aux) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) - @raises(AssertionError) def test_num_smaller_than_srcs(self): self.srcs = ['fe80::1', 'fe80::2', 'fe80::3'] self.num = len(self.srcs) - 1 @@ -1951,9 +1943,8 @@ class Test_mldv2_report_group(unittest.TestCase): self.mld = icmpv6.mldv2_report_group( self.type_, self.aux_len, self.num, self.address, self.srcs, self.aux) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) - @raises(struct.error) def test_aux_len_larger_than_aux(self): self.aux = b'\x01\x02\x03\x04\x05\x06\x07\x08' self.aux_len = len(self.aux) // 4 + 1 @@ -1964,9 +1955,8 @@ class Test_mldv2_report_group(unittest.TestCase): self.mld = icmpv6.mldv2_report_group( self.type_, self.aux_len, self.num, self.address, self.srcs, self.aux) - self.test_parser() + self.assertRaises(struct.error, self.test_parser) - @raises(AssertionError) def test_aux_len_smaller_than_aux(self): self.aux = b'\x01\x02\x03\x04\x05\x06\x07\x08' self.aux_len = len(self.aux) // 4 - 1 @@ -1977,7 +1967,7 @@ class Test_mldv2_report_group(unittest.TestCase): self.mld = icmpv6.mldv2_report_group( self.type_, self.aux_len, self.num, self.address, self.srcs, self.aux) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) def test_default_args(self): rep = icmpv6.mldv2_report_group() @@ -1985,10 +1975,10 @@ class Test_mldv2_report_group(unittest.TestCase): res = struct.unpack_from( icmpv6.mldv2_report_group._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], 0) - eq_(res[3], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], addrconv.ipv6.text_to_bin('::')) # srcs without num srcs = ['fe80::1', 'fe80::2', 'fe80::3'] @@ -1998,17 +1988,17 @@ class Test_mldv2_report_group(unittest.TestCase): res = struct.unpack_from( icmpv6.mldv2_report_group._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], len(srcs)) - eq_(res[3], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], len(srcs)) + self.assertEqual(res[3], addrconv.ipv6.text_to_bin('::')) (src1, src2, src3) = struct.unpack_from( '16s16s16s', six.binary_type(buf), icmpv6.mldv2_report_group._MIN_LEN) - eq_(src1, addrconv.ipv6.text_to_bin(srcs[0])) - eq_(src2, addrconv.ipv6.text_to_bin(srcs[1])) - eq_(src3, addrconv.ipv6.text_to_bin(srcs[2])) + self.assertEqual(src1, addrconv.ipv6.text_to_bin(srcs[0])) + self.assertEqual(src2, addrconv.ipv6.text_to_bin(srcs[1])) + self.assertEqual(src3, addrconv.ipv6.text_to_bin(srcs[2])) # aux without aux_len rep = icmpv6.mldv2_report_group(aux=b'\x01\x02\x03') @@ -2016,17 +2006,17 @@ class Test_mldv2_report_group(unittest.TestCase): res = struct.unpack_from( icmpv6.mldv2_report_group._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], 1) - eq_(res[2], 0) - eq_(res[3], addrconv.ipv6.text_to_bin('::')) - eq_(buf[icmpv6.mldv2_report_group._MIN_LEN:], b'\x01\x02\x03\x00') + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 1) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], addrconv.ipv6.text_to_bin('::')) + self.assertEqual(buf[icmpv6.mldv2_report_group._MIN_LEN:], b'\x01\x02\x03\x00') def test_json(self): jsondict = self.mld.to_jsondict() mld = icmpv6.mldv2_report_group.from_jsondict( jsondict['mldv2_report_group']) - eq_(str(self.mld), str(mld)) + self.assertEqual(str(self.mld), str(mld)) def test_json_with_srcs(self): self.setUp_with_srcs() diff --git a/os_ken/tests/unit/packet/test_igmp.py b/os_ken/tests/unit/packet/test_igmp.py index 76549b96..90286d7c 100644 --- a/os_ken/tests/unit/packet/test_igmp.py +++ b/os_ken/tests/unit/packet/test_igmp.py @@ -21,7 +21,6 @@ import logging import six from struct import pack, unpack_from, pack_into -from nose.tools import ok_, eq_, raises from os_ken.ofproto import ether from os_ken.ofproto import inet from os_ken.lib.packet.ethernet import ethernet @@ -66,10 +65,10 @@ class Test_igmp(unittest.TestCase): return p def test_init(self): - eq_(self.msgtype, self.g.msgtype) - eq_(self.maxresp, self.g.maxresp) - eq_(self.csum, self.g.csum) - eq_(self.address, self.g.address) + self.assertEqual(self.msgtype, self.g.msgtype) + self.assertEqual(self.maxresp, self.g.maxresp) + self.assertEqual(self.csum, self.g.csum) + self.assertEqual(self.address, self.g.address) def test_parser(self): _res = self.g.parser(self.buf) @@ -78,10 +77,10 @@ class Test_igmp(unittest.TestCase): else: res = _res - eq_(res.msgtype, self.msgtype) - eq_(res.maxresp, self.maxresp) - eq_(res.csum, self.csum) - eq_(res.address, self.address) + self.assertEqual(res.msgtype, self.msgtype) + self.assertEqual(res.maxresp, self.maxresp) + self.assertEqual(res.csum, self.csum) + self.assertEqual(res.address, self.address) def test_serialize(self): data = bytearray() @@ -90,10 +89,10 @@ class Test_igmp(unittest.TestCase): res = unpack_from(igmp._PACK_STR, six.binary_type(buf)) - eq_(res[0], self.msgtype) - eq_(res[1], self.maxresp) - eq_(res[2], checksum(self.buf)) - eq_(res[3], addrconv.ipv4.text_to_bin(self.address)) + self.assertEqual(res[0], self.msgtype) + self.assertEqual(res[1], self.maxresp) + self.assertEqual(res[2], checksum(self.buf)) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin(self.address)) def _build_igmp(self): dl_dst = '11:22:33:44:55:66' @@ -120,20 +119,20 @@ class Test_igmp(unittest.TestCase): p = self._build_igmp() e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_IP) + self.assertIsNotNone(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_IP) i = self.find_protocol(p, "ipv4") - ok_(i) - eq_(i.proto, inet.IPPROTO_IGMP) + self.assertTrue(i) + self.assertEqual(i.proto, inet.IPPROTO_IGMP) g = self.find_protocol(p, "igmp") - ok_(g) + self.assertTrue(g) - eq_(g.msgtype, self.msgtype) - eq_(g.maxresp, self.maxresp) - eq_(g.csum, checksum(self.buf)) - eq_(g.address, self.address) + self.assertEqual(g.msgtype, self.msgtype) + self.assertEqual(g.maxresp, self.maxresp) + self.assertEqual(g.csum, checksum(self.buf)) + self.assertEqual(g.address, self.address) def test_to_string(self): igmp_values = {'msgtype': repr(self.msgtype), @@ -145,27 +144,26 @@ class Test_igmp(unittest.TestCase): if k in igmp_values]) g_str = '%s(%s)' % (igmp.__name__, _g_str) - eq_(str(self.g), g_str) - eq_(repr(self.g), g_str) + self.assertEqual(str(self.g), g_str) + self.assertEqual(repr(self.g), g_str) - @raises(Exception) def test_malformed_igmp(self): m_short_buf = self.buf[1:igmp._MIN_LEN] - igmp.parser(m_short_buf) + self.assertRaises(Exception, igmp.parser, m_short_buf) def test_default_args(self): ig = igmp() buf = ig.serialize(bytearray(), None) res = unpack_from(igmp._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0x11) - eq_(res[1], 0) - eq_(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) + self.assertEqual(res[0], 0x11) + self.assertEqual(res[1], 0) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) def test_json(self): jsondict = self.g.to_jsondict() g = igmp.from_jsondict(jsondict['igmp']) - eq_(str(self.g), str(g)) + self.assertEqual(str(self.g), str(g)) class Test_igmpv3_query(unittest.TestCase): @@ -216,15 +214,15 @@ class Test_igmpv3_query(unittest.TestCase): return p def test_init(self): - eq_(self.msgtype, self.g.msgtype) - eq_(self.maxresp, self.g.maxresp) - eq_(self.csum, self.g.csum) - eq_(self.address, self.g.address) - eq_(self.s_flg, self.g.s_flg) - eq_(self.qrv, self.g.qrv) - eq_(self.qqic, self.g.qqic) - eq_(self.num, self.g.num) - eq_(self.srcs, self.g.srcs) + self.assertEqual(self.msgtype, self.g.msgtype) + self.assertEqual(self.maxresp, self.g.maxresp) + self.assertEqual(self.csum, self.g.csum) + self.assertEqual(self.address, self.g.address) + self.assertEqual(self.s_flg, self.g.s_flg) + self.assertEqual(self.qrv, self.g.qrv) + self.assertEqual(self.qqic, self.g.qqic) + self.assertEqual(self.num, self.g.num) + self.assertEqual(self.srcs, self.g.srcs) def test_init_with_srcs(self): self.setUp_with_srcs() @@ -237,15 +235,15 @@ class Test_igmpv3_query(unittest.TestCase): else: res = _res - eq_(res.msgtype, self.msgtype) - eq_(res.maxresp, self.maxresp) - eq_(res.csum, self.csum) - eq_(res.address, self.address) - eq_(res.s_flg, self.s_flg) - eq_(res.qrv, self.qrv) - eq_(res.qqic, self.qqic) - eq_(res.num, self.num) - eq_(res.srcs, self.srcs) + self.assertEqual(res.msgtype, self.msgtype) + self.assertEqual(res.maxresp, self.maxresp) + self.assertEqual(res.csum, self.csum) + self.assertEqual(res.address, self.address) + self.assertEqual(res.s_flg, self.s_flg) + self.assertEqual(res.qrv, self.qrv) + self.assertEqual(res.qqic, self.qqic) + self.assertEqual(res.num, self.num) + self.assertEqual(res.srcs, self.srcs) def test_parser_with_srcs(self): self.setUp_with_srcs() @@ -258,13 +256,13 @@ class Test_igmpv3_query(unittest.TestCase): res = unpack_from(igmpv3_query._PACK_STR, six.binary_type(buf)) - eq_(res[0], self.msgtype) - eq_(res[1], self.maxresp) - eq_(res[2], checksum(self.buf)) - eq_(res[3], addrconv.ipv4.text_to_bin(self.address)) - eq_(res[4], self.s_qrv) - eq_(res[5], self.qqic) - eq_(res[6], self.num) + self.assertEqual(res[0], self.msgtype) + self.assertEqual(res[1], self.maxresp) + self.assertEqual(res[2], checksum(self.buf)) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin(self.address)) + self.assertEqual(res[4], self.s_qrv) + self.assertEqual(res[5], self.qqic) + self.assertEqual(res[6], self.num) def test_serialize_with_srcs(self): self.setUp_with_srcs() @@ -276,16 +274,16 @@ class Test_igmpv3_query(unittest.TestCase): (src1, src2, src3) = unpack_from('4s4s4s', six.binary_type(buf), igmpv3_query._MIN_LEN) - eq_(res[0], self.msgtype) - eq_(res[1], self.maxresp) - eq_(res[2], checksum(self.buf)) - eq_(res[3], addrconv.ipv4.text_to_bin(self.address)) - eq_(res[4], self.s_qrv) - eq_(res[5], self.qqic) - eq_(res[6], self.num) - eq_(src1, addrconv.ipv4.text_to_bin(self.srcs[0])) - eq_(src2, addrconv.ipv4.text_to_bin(self.srcs[1])) - eq_(src3, addrconv.ipv4.text_to_bin(self.srcs[2])) + self.assertEqual(res[0], self.msgtype) + self.assertEqual(res[1], self.maxresp) + self.assertEqual(res[2], checksum(self.buf)) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin(self.address)) + self.assertEqual(res[4], self.s_qrv) + self.assertEqual(res[5], self.qqic) + self.assertEqual(res[6], self.num) + self.assertEqual(src1, addrconv.ipv4.text_to_bin(self.srcs[0])) + self.assertEqual(src2, addrconv.ipv4.text_to_bin(self.srcs[1])) + self.assertEqual(src3, addrconv.ipv4.text_to_bin(self.srcs[2])) def _build_igmp(self): dl_dst = '11:22:33:44:55:66' @@ -312,25 +310,25 @@ class Test_igmpv3_query(unittest.TestCase): p = self._build_igmp() e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_IP) + self.assertTrue(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_IP) i = self.find_protocol(p, "ipv4") - ok_(i) - eq_(i.proto, inet.IPPROTO_IGMP) + self.assertTrue(i) + self.assertEqual(i.proto, inet.IPPROTO_IGMP) g = self.find_protocol(p, "igmpv3_query") - ok_(g) + self.assertTrue(g) - eq_(g.msgtype, self.msgtype) - eq_(g.maxresp, self.maxresp) - eq_(g.csum, checksum(self.buf)) - eq_(g.address, self.address) - eq_(g.s_flg, self.s_flg) - eq_(g.qrv, self.qrv) - eq_(g.qqic, self.qqic) - eq_(g.num, self.num) - eq_(g.srcs, self.srcs) + self.assertEqual(g.msgtype, self.msgtype) + self.assertEqual(g.maxresp, self.maxresp) + self.assertEqual(g.csum, checksum(self.buf)) + self.assertEqual(g.address, self.address) + self.assertEqual(g.s_flg, self.s_flg) + self.assertEqual(g.qrv, self.qrv) + self.assertEqual(g.qqic, self.qqic) + self.assertEqual(g.num, self.num) + self.assertEqual(g.srcs, self.srcs) def test_build_igmp_with_srcs(self): self.setUp_with_srcs() @@ -351,14 +349,13 @@ class Test_igmpv3_query(unittest.TestCase): if k in igmp_values]) g_str = '%s(%s)' % (igmpv3_query.__name__, _g_str) - eq_(str(self.g), g_str) - eq_(repr(self.g), g_str) + self.assertEqual(str(self.g), g_str) + self.assertEqual(repr(self.g), g_str) def test_to_string_with_srcs(self): self.setUp_with_srcs() self.test_to_string() - @raises(Exception) def test_num_larger_than_srcs(self): self.srcs = ['192.168.1.1', '192.168.1.2', '192.168.1.3'] self.num = len(self.srcs) + 1 @@ -371,9 +368,8 @@ class Test_igmpv3_query(unittest.TestCase): self.g = igmpv3_query( self.msgtype, self.maxresp, self.csum, self.address, self.s_flg, self.qrv, self.qqic, self.num, self.srcs) - self.test_parser() + self.assertRaises(Exception, self.test_parser) - @raises(Exception) def test_num_smaller_than_srcs(self): self.srcs = ['192.168.1.1', '192.168.1.2', '192.168.1.3'] self.num = len(self.srcs) - 1 @@ -386,7 +382,7 @@ class Test_igmpv3_query(unittest.TestCase): self.g = igmpv3_query( self.msgtype, self.maxresp, self.csum, self.address, self.s_flg, self.qrv, self.qqic, self.num, self.srcs) - self.test_parser() + self.assertRaises(Exception, self.test_parser) def test_default_args(self): prev = ipv4(proto=inet.IPPROTO_IGMP) @@ -397,13 +393,13 @@ class Test_igmpv3_query(unittest.TestCase): buf = bytearray(buf) pack_into('!H', buf, 2, 0) - eq_(res[0], IGMP_TYPE_QUERY) - eq_(res[1], 100) - eq_(res[2], checksum(buf)) - eq_(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) - eq_(res[4], 2) - eq_(res[5], 0) - eq_(res[6], 0) + self.assertEqual(res[0], IGMP_TYPE_QUERY) + self.assertEqual(res[1], 100) + self.assertEqual(res[2], checksum(buf)) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) + self.assertEqual(res[4], 2) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], 0) # srcs without num prev = ipv4(proto=inet.IPPROTO_IGMP) @@ -415,24 +411,24 @@ class Test_igmpv3_query(unittest.TestCase): buf = bytearray(buf) pack_into('!H', buf, 2, 0) - eq_(res[0], IGMP_TYPE_QUERY) - eq_(res[1], 100) - eq_(res[2], checksum(buf)) - eq_(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) - eq_(res[4], 2) - eq_(res[5], 0) - eq_(res[6], len(srcs)) + self.assertEqual(res[0], IGMP_TYPE_QUERY) + self.assertEqual(res[1], 100) + self.assertEqual(res[2], checksum(buf)) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) + self.assertEqual(res[4], 2) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], len(srcs)) res = unpack_from('4s4s4s', six.binary_type(buf), igmpv3_query._MIN_LEN) - eq_(res[0], addrconv.ipv4.text_to_bin(srcs[0])) - eq_(res[1], addrconv.ipv4.text_to_bin(srcs[1])) - eq_(res[2], addrconv.ipv4.text_to_bin(srcs[2])) + self.assertEqual(res[0], addrconv.ipv4.text_to_bin(srcs[0])) + self.assertEqual(res[1], addrconv.ipv4.text_to_bin(srcs[1])) + self.assertEqual(res[2], addrconv.ipv4.text_to_bin(srcs[2])) def test_json(self): jsondict = self.g.to_jsondict() g = igmpv3_query.from_jsondict(jsondict['igmpv3_query']) - eq_(str(self.g), str(g)) + self.assertEqual(str(self.g), str(g)) def test_json_with_srcs(self): self.setUp_with_srcs() @@ -487,10 +483,10 @@ class Test_igmpv3_report(unittest.TestCase): return p def test_init(self): - eq_(self.msgtype, self.g.msgtype) - eq_(self.csum, self.g.csum) - eq_(self.record_num, self.g.record_num) - eq_(self.records, self.g.records) + self.assertEqual(self.msgtype, self.g.msgtype) + self.assertEqual(self.csum, self.g.csum) + self.assertEqual(self.record_num, self.g.record_num) + self.assertEqual(self.records, self.g.records) def test_init_with_records(self): self.setUp_with_records() @@ -503,10 +499,10 @@ class Test_igmpv3_report(unittest.TestCase): else: res = _res - eq_(res.msgtype, self.msgtype) - eq_(res.csum, self.csum) - eq_(res.record_num, self.record_num) - eq_(repr(res.records), repr(self.records)) + self.assertEqual(res.msgtype, self.msgtype) + self.assertEqual(res.csum, self.csum) + self.assertEqual(res.record_num, self.record_num) + self.assertEqual(repr(res.records), repr(self.records)) def test_parser_with_records(self): self.setUp_with_records() @@ -519,9 +515,9 @@ class Test_igmpv3_report(unittest.TestCase): res = unpack_from(igmpv3_report._PACK_STR, six.binary_type(buf)) - eq_(res[0], self.msgtype) - eq_(res[1], checksum(self.buf)) - eq_(res[2], self.record_num) + self.assertEqual(res[0], self.msgtype) + self.assertEqual(res[1], checksum(self.buf)) + self.assertEqual(res[2], self.record_num) def test_serialize_with_records(self): self.setUp_with_records() @@ -539,13 +535,13 @@ class Test_igmpv3_report(unittest.TestCase): offset += len(rec3) rec4 = igmpv3_report_group.parser(buf[offset:]) - eq_(res[0], self.msgtype) - eq_(res[1], checksum(self.buf)) - eq_(res[2], self.record_num) - eq_(repr(rec1), repr(self.record1)) - eq_(repr(rec2), repr(self.record2)) - eq_(repr(rec3), repr(self.record3)) - eq_(repr(rec4), repr(self.record4)) + self.assertEqual(res[0], self.msgtype) + self.assertEqual(res[1], checksum(self.buf)) + self.assertEqual(res[2], self.record_num) + self.assertEqual(repr(rec1), repr(self.record1)) + self.assertEqual(repr(rec2), repr(self.record2)) + self.assertEqual(repr(rec3), repr(self.record3)) + self.assertEqual(repr(rec4), repr(self.record4)) def _build_igmp(self): dl_dst = '11:22:33:44:55:66' @@ -572,20 +568,20 @@ class Test_igmpv3_report(unittest.TestCase): p = self._build_igmp() e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_IP) + self.assertTrue(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_IP) i = self.find_protocol(p, "ipv4") - ok_(i) - eq_(i.proto, inet.IPPROTO_IGMP) + self.assertTrue(i) + self.assertEqual(i.proto, inet.IPPROTO_IGMP) g = self.find_protocol(p, "igmpv3_report") - ok_(g) + self.assertTrue(g) - eq_(g.msgtype, self.msgtype) - eq_(g.csum, checksum(self.buf)) - eq_(g.record_num, self.record_num) - eq_(g.records, self.records) + self.assertEqual(g.msgtype, self.msgtype) + self.assertEqual(g.csum, checksum(self.buf)) + self.assertEqual(g.record_num, self.record_num) + self.assertEqual(g.records, self.records) def test_build_igmp_with_records(self): self.setUp_with_records() @@ -601,14 +597,13 @@ class Test_igmpv3_report(unittest.TestCase): if k in igmp_values]) g_str = '%s(%s)' % (igmpv3_report.__name__, _g_str) - eq_(str(self.g), g_str) - eq_(repr(self.g), g_str) + self.assertEqual(str(self.g), g_str) + self.assertEqual(repr(self.g), g_str) def test_to_string_with_records(self): self.setUp_with_records() self.test_to_string() - @raises(Exception) def test_record_num_larger_than_records(self): self.record1 = igmpv3_report_group( MODE_IS_INCLUDE, 0, 0, '225.0.0.1') @@ -631,9 +626,8 @@ class Test_igmpv3_report(unittest.TestCase): self.buf += self.record4.serialize() self.g = igmpv3_report( self.msgtype, self.csum, self.record_num, self.records) - self.test_parser() + self.assertRaises(Exception, self.test_parser) - @raises(Exception) def test_record_num_smaller_than_records(self): self.record1 = igmpv3_report_group( MODE_IS_INCLUDE, 0, 0, '225.0.0.1') @@ -656,7 +650,7 @@ class Test_igmpv3_report(unittest.TestCase): self.buf += self.record4.serialize() self.g = igmpv3_report( self.msgtype, self.csum, self.record_num, self.records) - self.test_parser() + self.assertRaises(Exception, self.test_parser) def test_default_args(self): prev = ipv4(proto=inet.IPPROTO_IGMP) @@ -667,9 +661,9 @@ class Test_igmpv3_report(unittest.TestCase): buf = bytearray(buf) pack_into('!H', buf, 2, 0) - eq_(res[0], IGMP_TYPE_REPORT_V3) - eq_(res[1], checksum(buf)) - eq_(res[2], 0) + self.assertEqual(res[0], IGMP_TYPE_REPORT_V3) + self.assertEqual(res[1], checksum(buf)) + self.assertEqual(res[2], 0) # records without record_num prev = ipv4(proto=inet.IPPROTO_IGMP) @@ -691,14 +685,14 @@ class Test_igmpv3_report(unittest.TestCase): buf = bytearray(buf) pack_into('!H', buf, 2, 0) - eq_(res[0], IGMP_TYPE_REPORT_V3) - eq_(res[1], checksum(buf)) - eq_(res[2], len(records)) + self.assertEqual(res[0], IGMP_TYPE_REPORT_V3) + self.assertEqual(res[1], checksum(buf)) + self.assertEqual(res[2], len(records)) def test_json(self): jsondict = self.g.to_jsondict() g = igmpv3_report.from_jsondict(jsondict['igmpv3_report']) - eq_(str(self.g), str(g)) + self.assertEqual(str(self.g), str(g)) def test_json_with_records(self): self.setUp_with_records() @@ -767,12 +761,12 @@ class Test_igmpv3_report_group(unittest.TestCase): pass def test_init(self): - eq_(self.type_, self.g.type_) - eq_(self.aux_len, self.g.aux_len) - eq_(self.num, self.g.num) - eq_(self.address, self.g.address) - eq_(self.srcs, self.g.srcs) - eq_(self.aux, self.g.aux) + self.assertEqual(self.type_, self.g.type_) + self.assertEqual(self.aux_len, self.g.aux_len) + self.assertEqual(self.num, self.g.num) + self.assertEqual(self.address, self.g.address) + self.assertEqual(self.srcs, self.g.srcs) + self.assertEqual(self.aux, self.g.aux) def test_init_with_srcs(self): self.setUp_with_srcs() @@ -793,12 +787,12 @@ class Test_igmpv3_report_group(unittest.TestCase): else: res = _res - eq_(res.type_, self.type_) - eq_(res.aux_len, self.aux_len) - eq_(res.num, self.num) - eq_(res.address, self.address) - eq_(res.srcs, self.srcs) - eq_(res.aux, self.aux) + self.assertEqual(res.type_, self.type_) + self.assertEqual(res.aux_len, self.aux_len) + self.assertEqual(res.num, self.num) + self.assertEqual(res.address, self.address) + self.assertEqual(res.srcs, self.srcs) + self.assertEqual(res.aux, self.aux) def test_parser_with_srcs(self): self.setUp_with_srcs() @@ -816,10 +810,10 @@ class Test_igmpv3_report_group(unittest.TestCase): buf = self.g.serialize() res = unpack_from(igmpv3_report_group._PACK_STR, six.binary_type(buf)) - eq_(res[0], self.type_) - eq_(res[1], self.aux_len) - eq_(res[2], self.num) - eq_(res[3], addrconv.ipv4.text_to_bin(self.address)) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.aux_len) + self.assertEqual(res[2], self.num) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin(self.address)) def test_serialize_with_srcs(self): self.setUp_with_srcs() @@ -827,13 +821,13 @@ class Test_igmpv3_report_group(unittest.TestCase): res = unpack_from(igmpv3_report_group._PACK_STR, six.binary_type(buf)) (src1, src2, src3) = unpack_from('4s4s4s', six.binary_type(buf), igmpv3_report_group._MIN_LEN) - eq_(res[0], self.type_) - eq_(res[1], self.aux_len) - eq_(res[2], self.num) - eq_(res[3], addrconv.ipv4.text_to_bin(self.address)) - eq_(src1, addrconv.ipv4.text_to_bin(self.srcs[0])) - eq_(src2, addrconv.ipv4.text_to_bin(self.srcs[1])) - eq_(src3, addrconv.ipv4.text_to_bin(self.srcs[2])) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.aux_len) + self.assertEqual(res[2], self.num) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin(self.address)) + self.assertEqual(src1, addrconv.ipv4.text_to_bin(self.srcs[0])) + self.assertEqual(src2, addrconv.ipv4.text_to_bin(self.srcs[1])) + self.assertEqual(src3, addrconv.ipv4.text_to_bin(self.srcs[2])) def test_serialize_with_aux(self): self.setUp_with_aux() @@ -841,11 +835,11 @@ class Test_igmpv3_report_group(unittest.TestCase): res = unpack_from(igmpv3_report_group._PACK_STR, six.binary_type(buf)) (aux, ) = unpack_from('%ds' % (self.aux_len * 4), six.binary_type(buf), igmpv3_report_group._MIN_LEN) - eq_(res[0], self.type_) - eq_(res[1], self.aux_len) - eq_(res[2], self.num) - eq_(res[3], addrconv.ipv4.text_to_bin(self.address)) - eq_(aux, self.aux) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.aux_len) + self.assertEqual(res[2], self.num) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin(self.address)) + self.assertEqual(aux, self.aux) def test_serialize_with_srcs_and_aux(self): self.setUp_with_srcs_and_aux() @@ -855,14 +849,14 @@ class Test_igmpv3_report_group(unittest.TestCase): igmpv3_report_group._MIN_LEN) (aux, ) = unpack_from('%ds' % (self.aux_len * 4), six.binary_type(buf), igmpv3_report_group._MIN_LEN + 12) - eq_(res[0], self.type_) - eq_(res[1], self.aux_len) - eq_(res[2], self.num) - eq_(res[3], addrconv.ipv4.text_to_bin(self.address)) - eq_(src1, addrconv.ipv4.text_to_bin(self.srcs[0])) - eq_(src2, addrconv.ipv4.text_to_bin(self.srcs[1])) - eq_(src3, addrconv.ipv4.text_to_bin(self.srcs[2])) - eq_(aux, self.aux) + self.assertEqual(res[0], self.type_) + self.assertEqual(res[1], self.aux_len) + self.assertEqual(res[2], self.num) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin(self.address)) + self.assertEqual(src1, addrconv.ipv4.text_to_bin(self.srcs[0])) + self.assertEqual(src2, addrconv.ipv4.text_to_bin(self.srcs[1])) + self.assertEqual(src3, addrconv.ipv4.text_to_bin(self.srcs[2])) + self.assertEqual(aux, self.aux) def test_to_string(self): igmp_values = {'type_': repr(self.type_), @@ -876,8 +870,8 @@ class Test_igmpv3_report_group(unittest.TestCase): if k in igmp_values]) g_str = '%s(%s)' % (igmpv3_report_group.__name__, _g_str) - eq_(str(self.g), g_str) - eq_(repr(self.g), g_str) + self.assertEqual(str(self.g), g_str) + self.assertEqual(repr(self.g), g_str) def test_to_string_with_srcs(self): self.setUp_with_srcs() @@ -892,21 +886,20 @@ class Test_igmpv3_report_group(unittest.TestCase): self.test_to_string() def test_len(self): - eq_(len(self.g), 8) + self.assertEqual(len(self.g), 8) def test_len_with_srcs(self): self.setUp_with_srcs() - eq_(len(self.g), 20) + self.assertEqual(len(self.g), 20) def test_len_with_aux(self): self.setUp_with_aux() - eq_(len(self.g), 16) + self.assertEqual(len(self.g), 16) def test_len_with_srcs_and_aux(self): self.setUp_with_srcs_and_aux() - eq_(len(self.g), 28) + self.assertEqual(len(self.g), 28) - @raises def test_num_larger_than_srcs(self): self.srcs = ['192.168.1.1', '192.168.1.2', '192.168.1.3'] self.num = len(self.srcs) + 1 @@ -918,9 +911,8 @@ class Test_igmpv3_report_group(unittest.TestCase): self.g = igmpv3_report_group( self.type_, self.aux_len, self.num, self.address, self.srcs, self.aux) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) - @raises def test_num_smaller_than_srcs(self): self.srcs = ['192.168.1.1', '192.168.1.2', '192.168.1.3'] self.num = len(self.srcs) - 1 @@ -932,9 +924,8 @@ class Test_igmpv3_report_group(unittest.TestCase): self.g = igmpv3_report_group( self.type_, self.aux_len, self.num, self.address, self.srcs, self.aux) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) - @raises def test_aux_len_larger_than_aux(self): self.aux = b'\x01\x02\x03\x04\x05\x00\x00\x00' self.aux_len = len(self.aux) // 4 + 1 @@ -945,9 +936,8 @@ class Test_igmpv3_report_group(unittest.TestCase): self.g = igmpv3_report_group( self.type_, self.aux_len, self.num, self.address, self.srcs, self.aux) - self.test_parser() + self.assertRaises(Exception, self.test_parser) - @raises def test_aux_len_smaller_than_aux(self): self.aux = b'\x01\x02\x03\x04\x05\x00\x00\x00' self.aux_len = len(self.aux) // 4 - 1 @@ -958,17 +948,17 @@ class Test_igmpv3_report_group(unittest.TestCase): self.g = igmpv3_report_group( self.type_, self.aux_len, self.num, self.address, self.srcs, self.aux) - self.test_parser() + self.assertRaises(AssertionError, self.test_parser) def test_default_args(self): rep = igmpv3_report_group() buf = rep.serialize() res = unpack_from(igmpv3_report_group._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], 0) - eq_(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) # srcs without num srcs = ['192.168.1.1', '192.168.1.2', '192.168.1.3'] @@ -976,17 +966,17 @@ class Test_igmpv3_report_group(unittest.TestCase): buf = rep.serialize() res = unpack_from(igmpv3_report_group._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], 0) - eq_(res[2], len(srcs)) - eq_(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], len(srcs)) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) res = unpack_from('4s4s4s', six.binary_type(buf), igmpv3_report_group._MIN_LEN) - eq_(res[0], addrconv.ipv4.text_to_bin(srcs[0])) - eq_(res[1], addrconv.ipv4.text_to_bin(srcs[1])) - eq_(res[2], addrconv.ipv4.text_to_bin(srcs[2])) + self.assertEqual(res[0], addrconv.ipv4.text_to_bin(srcs[0])) + self.assertEqual(res[1], addrconv.ipv4.text_to_bin(srcs[1])) + self.assertEqual(res[2], addrconv.ipv4.text_to_bin(srcs[2])) # aux without aux_len aux = b'abcde' @@ -994,8 +984,8 @@ class Test_igmpv3_report_group(unittest.TestCase): buf = rep.serialize() res = unpack_from(igmpv3_report_group._PACK_STR, six.binary_type(buf)) - eq_(res[0], 0) - eq_(res[1], 2) - eq_(res[2], 0) - eq_(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) - eq_(buf[igmpv3_report_group._MIN_LEN:], b'abcde\x00\x00\x00') + self.assertEqual(res[0], 0) + self.assertEqual(res[1], 2) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], addrconv.ipv4.text_to_bin('0.0.0.0')) + self.assertEqual(buf[igmpv3_report_group._MIN_LEN:], b'abcde\x00\x00\x00') diff --git a/os_ken/tests/unit/packet/test_ipv4.py b/os_ken/tests/unit/packet/test_ipv4.py index 2e0e0778..61ae388b 100644 --- a/os_ken/tests/unit/packet/test_ipv4.py +++ b/os_ken/tests/unit/packet/test_ipv4.py @@ -20,7 +20,6 @@ import logging import six import struct from struct import * -from nose.tools import * from os_ken.ofproto import ether, inet from os_ken.lib.packet import packet_utils from os_ken.lib.packet.ethernet import ethernet @@ -74,64 +73,63 @@ class Test_ipv4(unittest.TestCase): pass def test_init(self): - eq_(self.version, self.ip.version) - eq_(self.header_length, self.ip.header_length) - eq_(self.tos, self.ip.tos) - eq_(self.total_length, self.ip.total_length) - eq_(self.identification, self.ip.identification) - eq_(self.flags, self.ip.flags) - eq_(self.offset, self.ip.offset) - eq_(self.ttl, self.ip.ttl) - eq_(self.proto, self.ip.proto) - eq_(self.csum, self.ip.csum) - eq_(self.src, self.ip.src) - eq_(self.dst, self.ip.dst) - eq_(self.length, len(self.ip)) - eq_(self.option, self.ip.option) + self.assertEqual(self.version, self.ip.version) + self.assertEqual(self.header_length, self.ip.header_length) + self.assertEqual(self.tos, self.ip.tos) + self.assertEqual(self.total_length, self.ip.total_length) + self.assertEqual(self.identification, self.ip.identification) + self.assertEqual(self.flags, self.ip.flags) + self.assertEqual(self.offset, self.ip.offset) + self.assertEqual(self.ttl, self.ip.ttl) + self.assertEqual(self.proto, self.ip.proto) + self.assertEqual(self.csum, self.ip.csum) + self.assertEqual(self.src, self.ip.src) + self.assertEqual(self.dst, self.ip.dst) + self.assertEqual(self.length, len(self.ip)) + self.assertEqual(self.option, self.ip.option) def test_parser(self): res, ptype, _ = self.ip.parser(self.buf) - eq_(res.version, self.version) - eq_(res.header_length, self.header_length) - eq_(res.tos, self.tos) - eq_(res.total_length, self.total_length) - eq_(res.identification, self.identification) - eq_(res.flags, self.flags) - eq_(res.offset, self.offset) - eq_(res.ttl, self.ttl) - eq_(res.proto, self.proto) - eq_(res.csum, self.csum) - eq_(res.src, self.src) - eq_(res.dst, self.dst) - eq_(ptype, tcp) + self.assertEqual(res.version, self.version) + self.assertEqual(res.header_length, self.header_length) + self.assertEqual(res.tos, self.tos) + self.assertEqual(res.total_length, self.total_length) + self.assertEqual(res.identification, self.identification) + self.assertEqual(res.flags, self.flags) + self.assertEqual(res.offset, self.offset) + self.assertEqual(res.ttl, self.ttl) + self.assertEqual(res.proto, self.proto) + self.assertEqual(res.csum, self.csum) + self.assertEqual(res.src, self.src) + self.assertEqual(res.dst, self.dst) + self.assertEqual(ptype, tcp) def test_serialize(self): buf = self.ip.serialize(bytearray(), None) res = struct.unpack_from(ipv4._PACK_STR, six.binary_type(buf)) option = buf[ipv4._MIN_LEN:ipv4._MIN_LEN + len(self.option)] - eq_(res[0], self.ver_hlen) - eq_(res[1], self.tos) - eq_(res[2], self.total_length) - eq_(res[3], self.identification) - eq_(res[4], self.flg_off) - eq_(res[5], self.ttl) - eq_(res[6], self.proto) - eq_(res[8], addrconv.ipv4.text_to_bin(self.src)) - eq_(res[9], addrconv.ipv4.text_to_bin(self.dst)) - eq_(option, self.option) + self.assertEqual(res[0], self.ver_hlen) + self.assertEqual(res[1], self.tos) + self.assertEqual(res[2], self.total_length) + self.assertEqual(res[3], self.identification) + self.assertEqual(res[4], self.flg_off) + self.assertEqual(res[5], self.ttl) + self.assertEqual(res[6], self.proto) + self.assertEqual(res[8], addrconv.ipv4.text_to_bin(self.src)) + self.assertEqual(res[9], addrconv.ipv4.text_to_bin(self.dst)) + self.assertEqual(option, self.option) # checksum csum = packet_utils.checksum(buf) - eq_(csum, 0) + self.assertEqual(csum, 0) - @raises(Exception) def test_malformed_ipv4(self): m_short_buf = self.buf[1:ipv4._MIN_LEN] - ipv4.parser(m_short_buf) + self.assertRaises(Exception, ipv4.parser, m_short_buf) def test_json(self): jsondict = self.ip.to_jsondict() ip = ipv4.from_jsondict(jsondict['ipv4']) - eq_(str(self.ip), str(ip)) + self.assertEqual(str(self.ip), str(ip)) diff --git a/os_ken/tests/unit/packet/test_ipv6.py b/os_ken/tests/unit/packet/test_ipv6.py index 7ace853f..03432613 100644 --- a/os_ken/tests/unit/packet/test_ipv6.py +++ b/os_ken/tests/unit/packet/test_ipv6.py @@ -20,7 +20,6 @@ import inspect import six import struct -from nose.tools import * from os_ken.lib import addrconv from os_ken.lib import ip from os_ken.lib.packet import ipv6 @@ -228,15 +227,15 @@ class Test_ipv6(unittest.TestCase): pass def test_init(self): - eq_(self.version, self.ip.version) - eq_(self.traffic_class, self.ip.traffic_class) - eq_(self.flow_label, self.ip.flow_label) - eq_(self.payload_length, self.ip.payload_length) - eq_(self.nxt, self.ip.nxt) - eq_(self.hop_limit, self.ip.hop_limit) - eq_(self.src, self.ip.src) - eq_(self.dst, self.ip.dst) - eq_(str(self.ext_hdrs), str(self.ip.ext_hdrs)) + self.assertEqual(self.version, self.ip.version) + self.assertEqual(self.traffic_class, self.ip.traffic_class) + self.assertEqual(self.flow_label, self.ip.flow_label) + self.assertEqual(self.payload_length, self.ip.payload_length) + self.assertEqual(self.nxt, self.ip.nxt) + self.assertEqual(self.hop_limit, self.ip.hop_limit) + self.assertEqual(self.src, self.ip.src) + self.assertEqual(self.dst, self.ip.dst) + self.assertEqual(str(self.ext_hdrs), str(self.ip.ext_hdrs)) def test_init_with_hop_opts(self): self.setUp_with_hop_opts() @@ -269,15 +268,15 @@ class Test_ipv6(unittest.TestCase): else: res = _res - eq_(self.version, res.version) - eq_(self.traffic_class, res.traffic_class) - eq_(self.flow_label, res.flow_label) - eq_(self.payload_length, res.payload_length) - eq_(self.nxt, res.nxt) - eq_(self.hop_limit, res.hop_limit) - eq_(self.src, res.src) - eq_(self.dst, res.dst) - eq_(str(self.ext_hdrs), str(res.ext_hdrs)) + self.assertEqual(self.version, res.version) + self.assertEqual(self.traffic_class, res.traffic_class) + self.assertEqual(self.flow_label, res.flow_label) + self.assertEqual(self.payload_length, res.payload_length) + self.assertEqual(self.nxt, res.nxt) + self.assertEqual(self.hop_limit, res.hop_limit) + self.assertEqual(self.src, res.src) + self.assertEqual(self.dst, res.dst) + self.assertEqual(str(self.ext_hdrs), str(res.ext_hdrs)) def test_parser_with_hop_opts(self): self.setUp_with_hop_opts() @@ -310,12 +309,12 @@ class Test_ipv6(unittest.TestCase): res = struct.unpack_from(ipv6.ipv6._PACK_STR, six.binary_type(buf)) - eq_(self.v_tc_flow, res[0]) - eq_(self.payload_length, res[1]) - eq_(self.nxt, res[2]) - eq_(self.hop_limit, res[3]) - eq_(self.src, addrconv.ipv6.bin_to_text(res[4])) - eq_(self.dst, addrconv.ipv6.bin_to_text(res[5])) + self.assertEqual(self.v_tc_flow, res[0]) + self.assertEqual(self.payload_length, res[1]) + self.assertEqual(self.nxt, res[2]) + self.assertEqual(self.hop_limit, res[3]) + self.assertEqual(self.src, addrconv.ipv6.bin_to_text(res[4])) + self.assertEqual(self.dst, addrconv.ipv6.bin_to_text(res[5])) def test_serialize_with_hop_opts(self): self.setUp_with_hop_opts() @@ -325,7 +324,7 @@ class Test_ipv6(unittest.TestCase): prev = None buf = self.ip.serialize(data, prev) hop_opts = ipv6.hop_opts.parser(six.binary_type(buf[ipv6.ipv6._MIN_LEN:])) - eq_(repr(self.hop_opts), repr(hop_opts)) + self.assertEqual(repr(self.hop_opts), repr(hop_opts)) def test_serialize_with_dst_opts(self): self.setUp_with_dst_opts() @@ -335,7 +334,7 @@ class Test_ipv6(unittest.TestCase): prev = None buf = self.ip.serialize(data, prev) dst_opts = ipv6.dst_opts.parser(six.binary_type(buf[ipv6.ipv6._MIN_LEN:])) - eq_(repr(self.dst_opts), repr(dst_opts)) + self.assertEqual(repr(self.dst_opts), repr(dst_opts)) def test_serialize_with_routing_type3(self): self.setUp_with_routing_type3() @@ -345,7 +344,7 @@ class Test_ipv6(unittest.TestCase): prev = None buf = self.ip.serialize(data, prev) routing = ipv6.routing.parser(six.binary_type(buf[ipv6.ipv6._MIN_LEN:])) - eq_(repr(self.routing), repr(routing)) + self.assertEqual(repr(self.routing), repr(routing)) def test_serialize_with_fragment(self): self.setUp_with_fragment() @@ -355,7 +354,7 @@ class Test_ipv6(unittest.TestCase): prev = None buf = self.ip.serialize(data, prev) fragment = ipv6.fragment.parser(six.binary_type(buf[ipv6.ipv6._MIN_LEN:])) - eq_(repr(self.fragment), repr(fragment)) + self.assertEqual(repr(self.fragment), repr(fragment)) def test_serialize_with_auth(self): self.setUp_with_auth() @@ -365,7 +364,7 @@ class Test_ipv6(unittest.TestCase): prev = None buf = self.ip.serialize(data, prev) auth = ipv6.auth.parser(six.binary_type(buf[ipv6.ipv6._MIN_LEN:])) - eq_(repr(self.auth), repr(auth)) + self.assertEqual(repr(self.auth), repr(auth)) def test_serialize_with_multi_headers(self): self.setUp_with_multi_headers() @@ -378,8 +377,8 @@ class Test_ipv6(unittest.TestCase): hop_opts = ipv6.hop_opts.parser(six.binary_type(buf[offset:])) offset += len(hop_opts) auth = ipv6.auth.parser(six.binary_type(buf[offset:])) - eq_(repr(self.hop_opts), repr(hop_opts)) - eq_(repr(self.auth), repr(auth)) + self.assertEqual(repr(self.hop_opts), repr(hop_opts)) + self.assertEqual(repr(self.auth), repr(auth)) def test_to_string(self): ipv6_values = {'version': self.version, @@ -396,8 +395,8 @@ class Test_ipv6(unittest.TestCase): if k in ipv6_values]) ipv6_str = '%s(%s)' % (ipv6.ipv6.__name__, _ipv6_str) - eq_(str(self.ip), ipv6_str) - eq_(repr(self.ip), ipv6_str) + self.assertEqual(str(self.ip), ipv6_str) + self.assertEqual(repr(self.ip), ipv6_str) def test_to_string_with_hop_opts(self): self.setUp_with_hop_opts() @@ -420,43 +419,43 @@ class Test_ipv6(unittest.TestCase): self.test_to_string() def test_len(self): - eq_(len(self.ip), 40) + self.assertEqual(len(self.ip), 40) def test_len_with_hop_opts(self): self.setUp_with_hop_opts() - eq_(len(self.ip), 40 + len(self.hop_opts)) + self.assertEqual(len(self.ip), 40 + len(self.hop_opts)) def test_len_with_dst_opts(self): self.setUp_with_dst_opts() - eq_(len(self.ip), 40 + len(self.dst_opts)) + self.assertEqual(len(self.ip), 40 + len(self.dst_opts)) def test_len_with_routing_type3(self): self.setUp_with_routing_type3() - eq_(len(self.ip), 40 + len(self.routing)) + self.assertEqual(len(self.ip), 40 + len(self.routing)) def test_len_with_fragment(self): self.setUp_with_fragment() - eq_(len(self.ip), 40 + len(self.fragment)) + self.assertEqual(len(self.ip), 40 + len(self.fragment)) def test_len_with_auth(self): self.setUp_with_auth() - eq_(len(self.ip), 40 + len(self.auth)) + self.assertEqual(len(self.ip), 40 + len(self.auth)) def test_len_with_multi_headers(self): self.setUp_with_multi_headers() - eq_(len(self.ip), 40 + len(self.hop_opts) + len(self.auth)) + self.assertEqual(len(self.ip), 40 + len(self.hop_opts) + len(self.auth)) def test_default_args(self): ip = ipv6.ipv6() buf = ip.serialize(bytearray(), None) res = struct.unpack(ipv6.ipv6._PACK_STR, six.binary_type(buf)) - eq_(res[0], 6 << 28) - eq_(res[1], 0) - eq_(res[2], 6) - eq_(res[3], 255) - eq_(res[4], addrconv.ipv6.text_to_bin('10::10')) - eq_(res[5], addrconv.ipv6.text_to_bin('20::20')) + self.assertEqual(res[0], 6 << 28) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 6) + self.assertEqual(res[3], 255) + self.assertEqual(res[4], addrconv.ipv6.text_to_bin('10::10')) + self.assertEqual(res[5], addrconv.ipv6.text_to_bin('20::20')) # with extension header ip = ipv6.ipv6( @@ -467,18 +466,18 @@ class Test_ipv6(unittest.TestCase): buf = ip.serialize(bytearray(), None) res = struct.unpack(ipv6.ipv6._PACK_STR + '8s', six.binary_type(buf)) - eq_(res[0], 6 << 28) - eq_(res[1], 8) - eq_(res[2], 0) - eq_(res[3], 255) - eq_(res[4], addrconv.ipv6.text_to_bin('10::10')) - eq_(res[5], addrconv.ipv6.text_to_bin('20::20')) - eq_(res[6], b'\x3a\x00\x05\x02\x00\x00\x01\x00') + self.assertEqual(res[0], 6 << 28) + self.assertEqual(res[1], 8) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 255) + self.assertEqual(res[4], addrconv.ipv6.text_to_bin('10::10')) + self.assertEqual(res[5], addrconv.ipv6.text_to_bin('20::20')) + self.assertEqual(res[6], b'\x3a\x00\x05\x02\x00\x00\x01\x00') def test_json(self): jsondict = self.ip.to_jsondict() ip = ipv6.ipv6.from_jsondict(jsondict['ipv6']) - eq_(str(self.ip), str(ip)) + self.assertEqual(str(self.ip), str(ip)) def test_json_with_hop_opts(self): self.setUp_with_hop_opts() @@ -528,13 +527,12 @@ class Test_hop_opts(unittest.TestCase): pass def test_init(self): - eq_(self.nxt, self.hop.nxt) - eq_(self.size, self.hop.size) - eq_(self.data, self.hop.data) + self.assertEqual(self.nxt, self.hop.nxt) + self.assertEqual(self.size, self.hop.size) + self.assertEqual(self.data, self.hop.data) - @raises(Exception) def test_invalid_size(self): - ipv6.hop_opts(self.nxt, 1, self.data) + self.assertRaises(Exception, ipv6.hop_opts, self.nxt, 1, self.data) def test_parser(self): _res = ipv6.hop_opts.parser(self.buf) @@ -542,15 +540,15 @@ class Test_hop_opts(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.nxt, res.nxt) - eq_(self.size, res.size) - eq_(str(self.data), str(res.data)) + self.assertEqual(self.nxt, res.nxt) + self.assertEqual(self.size, res.size) + self.assertEqual(str(self.data), str(res.data)) def test_serialize(self): buf = self.hop.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.nxt, res[0]) - eq_(self.size, res[1]) + self.assertEqual(self.nxt, res[0]) + self.assertEqual(self.size, res[1]) offset = struct.calcsize(self.form) opt1 = ipv6.option.parser(six.binary_type(buf[offset:])) offset += len(opt1) @@ -559,31 +557,31 @@ class Test_hop_opts(unittest.TestCase): opt3 = ipv6.option.parser(six.binary_type(buf[offset:])) offset += len(opt3) opt4 = ipv6.option.parser(six.binary_type(buf[offset:])) - eq_(5, opt1.type_) - eq_(2, opt1.len_) - eq_(b'\x00\x00', opt1.data) - eq_(1, opt2.type_) - eq_(0, opt2.len_) - eq_(None, opt2.data) - eq_(0xc2, opt3.type_) - eq_(4, opt3.len_) - eq_(b'\x00\x01\x00\x00', opt3.data) - eq_(1, opt4.type_) - eq_(0, opt4.len_) - eq_(None, opt4.data) + self.assertEqual(5, opt1.type_) + self.assertEqual(2, opt1.len_) + self.assertEqual(b'\x00\x00', opt1.data) + self.assertEqual(1, opt2.type_) + self.assertEqual(0, opt2.len_) + self.assertEqual(None, opt2.data) + self.assertEqual(0xc2, opt3.type_) + self.assertEqual(4, opt3.len_) + self.assertEqual(b'\x00\x01\x00\x00', opt3.data) + self.assertEqual(1, opt4.type_) + self.assertEqual(0, opt4.len_) + self.assertEqual(None, opt4.data) def test_len(self): - eq_(16, len(self.hop)) + self.assertEqual(16, len(self.hop)) def test_default_args(self): hdr = ipv6.hop_opts() buf = hdr.serialize() res = struct.unpack('!BB', six.binary_type(buf[:2])) - eq_(res[0], 6) - eq_(res[1], 0) + self.assertEqual(res[0], 6) + self.assertEqual(res[1], 0) opt = ipv6.option(type_=1, len_=4, data=b'\x00\x00\x00\x00') - eq_(six.binary_type(buf[2:]), opt.serialize()) + self.assertEqual(six.binary_type(buf[2:]), opt.serialize()) class Test_dst_opts(unittest.TestCase): @@ -609,13 +607,12 @@ class Test_dst_opts(unittest.TestCase): pass def test_init(self): - eq_(self.nxt, self.dst.nxt) - eq_(self.size, self.dst.size) - eq_(self.data, self.dst.data) + self.assertEqual(self.nxt, self.dst.nxt) + self.assertEqual(self.size, self.dst.size) + self.assertEqual(self.data, self.dst.data) - @raises(Exception) def test_invalid_size(self): - ipv6.dst_opts(self.nxt, 1, self.data) + self.assertRaises(Exception, ipv6.dst_opts, self.nxt, 1, self.data) def test_parser(self): _res = ipv6.dst_opts.parser(self.buf) @@ -623,15 +620,15 @@ class Test_dst_opts(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.nxt, res.nxt) - eq_(self.size, res.size) - eq_(str(self.data), str(res.data)) + self.assertEqual(self.nxt, res.nxt) + self.assertEqual(self.size, res.size) + self.assertEqual(str(self.data), str(res.data)) def test_serialize(self): buf = self.dst.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.nxt, res[0]) - eq_(self.size, res[1]) + self.assertEqual(self.nxt, res[0]) + self.assertEqual(self.size, res[1]) offset = struct.calcsize(self.form) opt1 = ipv6.option.parser(six.binary_type(buf[offset:])) offset += len(opt1) @@ -640,31 +637,31 @@ class Test_dst_opts(unittest.TestCase): opt3 = ipv6.option.parser(six.binary_type(buf[offset:])) offset += len(opt3) opt4 = ipv6.option.parser(six.binary_type(buf[offset:])) - eq_(5, opt1.type_) - eq_(2, opt1.len_) - eq_(b'\x00\x00', opt1.data) - eq_(1, opt2.type_) - eq_(0, opt2.len_) - eq_(None, opt2.data) - eq_(0xc2, opt3.type_) - eq_(4, opt3.len_) - eq_(b'\x00\x01\x00\x00', opt3.data) - eq_(1, opt4.type_) - eq_(0, opt4.len_) - eq_(None, opt4.data) + self.assertEqual(5, opt1.type_) + self.assertEqual(2, opt1.len_) + self.assertEqual(b'\x00\x00', opt1.data) + self.assertEqual(1, opt2.type_) + self.assertEqual(0, opt2.len_) + self.assertEqual(None, opt2.data) + self.assertEqual(0xc2, opt3.type_) + self.assertEqual(4, opt3.len_) + self.assertEqual(b'\x00\x01\x00\x00', opt3.data) + self.assertEqual(1, opt4.type_) + self.assertEqual(0, opt4.len_) + self.assertEqual(None, opt4.data) def test_len(self): - eq_(16, len(self.dst)) + self.assertEqual(16, len(self.dst)) def test_default_args(self): hdr = ipv6.dst_opts() buf = hdr.serialize() res = struct.unpack('!BB', six.binary_type(buf[:2])) - eq_(res[0], 6) - eq_(res[1], 0) + self.assertEqual(res[0], 6) + self.assertEqual(res[1], 0) opt = ipv6.option(type_=1, len_=4, data=b'\x00\x00\x00\x00') - eq_(six.binary_type(buf[2:]), opt.serialize()) + self.assertEqual(six.binary_type(buf[2:]), opt.serialize()) class Test_option(unittest.TestCase): @@ -681,9 +678,9 @@ class Test_option(unittest.TestCase): pass def test_init(self): - eq_(self.type_, self.opt.type_) - eq_(self.len_, self.opt.len_) - eq_(self.data, self.opt.data) + self.assertEqual(self.type_, self.opt.type_) + self.assertEqual(self.len_, self.opt.len_) + self.assertEqual(self.data, self.opt.data) def test_parser(self): _res = ipv6.option.parser(self.buf) @@ -691,19 +688,19 @@ class Test_option(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.type_, res.type_) - eq_(self.len_, res.len_) - eq_(self.data, res.data) + self.assertEqual(self.type_, res.type_) + self.assertEqual(self.len_, res.len_) + self.assertEqual(self.data, res.data) def test_serialize(self): buf = self.opt.serialize() res = struct.unpack_from(self.form, buf) - eq_(self.type_, res[0]) - eq_(self.len_, res[1]) - eq_(self.data, res[2]) + self.assertEqual(self.type_, res[0]) + self.assertEqual(self.len_, res[1]) + self.assertEqual(self.data, res[2]) def test_len(self): - eq_(len(self.opt), 2 + self.len_) + self.assertEqual(len(self.opt), 2 + self.len_) class Test_option_pad1(Test_option): @@ -719,14 +716,14 @@ class Test_option_pad1(Test_option): def test_serialize(self): buf = self.opt.serialize() res = struct.unpack_from(self.form, buf) - eq_(self.type_, res[0]) + self.assertEqual(self.type_, res[0]) def test_default_args(self): opt = ipv6.option() buf = opt.serialize() res = struct.unpack('!B', buf) - eq_(res[0], 0) + self.assertEqual(res[0], 0) class Test_option_padN(Test_option): @@ -742,8 +739,8 @@ class Test_option_padN(Test_option): def test_serialize(self): buf = self.opt.serialize() res = struct.unpack_from(self.form, buf) - eq_(self.type_, res[0]) - eq_(self.len_, res[1]) + self.assertEqual(self.type_, res[0]) + self.assertEqual(self.len_, res[1]) class Test_routing(unittest.TestCase): @@ -780,16 +777,16 @@ class Test_routing(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.nxt, res.nxt) - eq_(self.size, res.size) - eq_(self.type_, res.type_) - eq_(self.seg, res.seg) - eq_(self.cmpi, res.cmpi) - eq_(self.cmpe, res.cmpe) - eq_(self.pad, res._pad) - eq_(self.adrs[0], res.adrs[0]) - eq_(self.adrs[1], res.adrs[1]) - eq_(self.adrs[2], res.adrs[2]) + self.assertEqual(self.nxt, res.nxt) + self.assertEqual(self.size, res.size) + self.assertEqual(self.type_, res.type_) + self.assertEqual(self.seg, res.seg) + self.assertEqual(self.cmpi, res.cmpi) + self.assertEqual(self.cmpe, res.cmpe) + self.assertEqual(self.pad, res._pad) + self.assertEqual(self.adrs[0], res.adrs[0]) + self.assertEqual(self.adrs[1], res.adrs[1]) + self.assertEqual(self.adrs[2], res.adrs[2]) def test_not_implemented_type(self): not_implemented_buf = struct.pack( @@ -833,16 +830,16 @@ class Test_routing_type3(unittest.TestCase): addrconv.ipv6.text_to_bin(self.adrs[2])) def test_init(self): - eq_(self.nxt, self.routing.nxt) - eq_(self.size, self.routing.size) - eq_(self.type_, self.routing.type_) - eq_(self.seg, self.routing.seg) - eq_(self.cmpi, self.routing.cmpi) - eq_(self.cmpe, self.routing.cmpe) - eq_(self.pad, self.routing._pad) - eq_(self.adrs[0], self.routing.adrs[0]) - eq_(self.adrs[1], self.routing.adrs[1]) - eq_(self.adrs[2], self.routing.adrs[2]) + self.assertEqual(self.nxt, self.routing.nxt) + self.assertEqual(self.size, self.routing.size) + self.assertEqual(self.type_, self.routing.type_) + self.assertEqual(self.seg, self.routing.seg) + self.assertEqual(self.cmpi, self.routing.cmpi) + self.assertEqual(self.cmpe, self.routing.cmpe) + self.assertEqual(self.pad, self.routing._pad) + self.assertEqual(self.adrs[0], self.routing.adrs[0]) + self.assertEqual(self.adrs[1], self.routing.adrs[1]) + self.assertEqual(self.adrs[2], self.routing.adrs[2]) def test_parser(self): _res = ipv6.routing.parser(self.buf) @@ -850,30 +847,30 @@ class Test_routing_type3(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.nxt, res.nxt) - eq_(self.size, res.size) - eq_(self.type_, res.type_) - eq_(self.seg, res.seg) - eq_(self.cmpi, res.cmpi) - eq_(self.cmpe, res.cmpe) - eq_(self.pad, res._pad) - eq_(self.adrs[0], res.adrs[0]) - eq_(self.adrs[1], res.adrs[1]) - eq_(self.adrs[2], res.adrs[2]) + self.assertEqual(self.nxt, res.nxt) + self.assertEqual(self.size, res.size) + self.assertEqual(self.type_, res.type_) + self.assertEqual(self.seg, res.seg) + self.assertEqual(self.cmpi, res.cmpi) + self.assertEqual(self.cmpe, res.cmpe) + self.assertEqual(self.pad, res._pad) + self.assertEqual(self.adrs[0], res.adrs[0]) + self.assertEqual(self.adrs[1], res.adrs[1]) + self.assertEqual(self.adrs[2], res.adrs[2]) def test_serialize(self): buf = self.routing.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.nxt, res[0]) - eq_(self.size, res[1]) - eq_(self.type_, res[2]) - eq_(self.seg, res[3]) - eq_(self.cmpi, res[4] >> 4) - eq_(self.cmpe, res[4] & 0xf) - eq_(self.pad, res[5]) - eq_(addrconv.ipv6.text_to_bin(self.adrs[0]), res[6]) - eq_(addrconv.ipv6.text_to_bin(self.adrs[1]), res[7]) - eq_(addrconv.ipv6.text_to_bin(self.adrs[2]), res[8]) + self.assertEqual(self.nxt, res[0]) + self.assertEqual(self.size, res[1]) + self.assertEqual(self.type_, res[2]) + self.assertEqual(self.seg, res[3]) + self.assertEqual(self.cmpi, res[4] >> 4) + self.assertEqual(self.cmpe, res[4] & 0xf) + self.assertEqual(self.pad, res[5]) + self.assertEqual(addrconv.ipv6.text_to_bin(self.adrs[0]), res[6]) + self.assertEqual(addrconv.ipv6.text_to_bin(self.adrs[1]), res[7]) + self.assertEqual(addrconv.ipv6.text_to_bin(self.adrs[2]), res[8]) def test_parser_with_adrs_zero(self): nxt = 0 @@ -894,13 +891,13 @@ class Test_routing_type3(unittest.TestCase): res = _res[0] else: res = _res - eq_(nxt, res.nxt) - eq_(size, res.size) - eq_(type_, res.type_) - eq_(seg, res.seg) - eq_(cmpi, res.cmpi) - eq_(cmpe, res.cmpe) - eq_(pad, res._pad) + self.assertEqual(nxt, res.nxt) + self.assertEqual(size, res.size) + self.assertEqual(type_, res.type_) + self.assertEqual(seg, res.seg) + self.assertEqual(cmpi, res.cmpi) + self.assertEqual(cmpe, res.cmpe) + self.assertEqual(pad, res._pad) def test_serialize_with_adrs_zero(self): nxt = 0 @@ -918,13 +915,13 @@ class Test_routing_type3(unittest.TestCase): buf = routing.serialize() form = '!BBBBBB2x' res = struct.unpack_from(form, six.binary_type(buf)) - eq_(nxt, res[0]) - eq_(size, res[1]) - eq_(type_, res[2]) - eq_(seg, res[3]) - eq_(cmpi, res[4] >> 4) - eq_(cmpe, res[4] & 0xf) - eq_(pad, res[5]) + self.assertEqual(nxt, res[0]) + self.assertEqual(size, res[1]) + self.assertEqual(type_, res[2]) + self.assertEqual(seg, res[3]) + self.assertEqual(cmpi, res[4] >> 4) + self.assertEqual(cmpe, res[4] & 0xf) + self.assertEqual(pad, res[5]) def test_parser_with_compression(self): pass @@ -952,16 +949,16 @@ class Test_routing_type3(unittest.TestCase): res = _res[0] else: res = _res - eq_(nxt, res.nxt) - eq_(size, res.size) - eq_(type_, res.type_) - eq_(seg, res.seg) - eq_(cmpi, res.cmpi) - eq_(cmpe, res.cmpe) - eq_(pad, res._pad) - eq_("::4567:89ab:cdef:1", res.adrs[0]) - eq_("::4567:89ab:cdef:2", res.adrs[1]) - eq_("::205.239.0.3", res.adrs[2]) + self.assertEqual(nxt, res.nxt) + self.assertEqual(size, res.size) + self.assertEqual(type_, res.type_) + self.assertEqual(seg, res.seg) + self.assertEqual(cmpi, res.cmpi) + self.assertEqual(cmpe, res.cmpe) + self.assertEqual(pad, res._pad) + self.assertEqual("::4567:89ab:cdef:1", res.adrs[0]) + self.assertEqual("::4567:89ab:cdef:2", res.adrs[1]) + self.assertEqual("::205.239.0.3", res.adrs[2]) def test_serialize_with_compression(self): nxt = 0 @@ -982,19 +979,19 @@ class Test_routing_type3(unittest.TestCase): buf = routing.serialize() form = '!BBBBBB2x8s8s8s' res = struct.unpack_from(form, six.binary_type(buf)) - eq_(nxt, res[0]) - eq_(size, res[1]) - eq_(type_, res[2]) - eq_(seg, res[3]) - eq_(cmpi, res[4] >> 4) - eq_(cmpe, res[4] & 0xf) - eq_(pad, res[5]) - eq_(addrconv.ipv6.text_to_bin(adrs[0])[slice_i], res[6]) - eq_(addrconv.ipv6.text_to_bin(adrs[1])[slice_i], res[7]) - eq_(addrconv.ipv6.text_to_bin(adrs[2])[slice_e], res[8]) + self.assertEqual(nxt, res[0]) + self.assertEqual(size, res[1]) + self.assertEqual(type_, res[2]) + self.assertEqual(seg, res[3]) + self.assertEqual(cmpi, res[4] >> 4) + self.assertEqual(cmpe, res[4] & 0xf) + self.assertEqual(pad, res[5]) + self.assertEqual(addrconv.ipv6.text_to_bin(adrs[0])[slice_i], res[6]) + self.assertEqual(addrconv.ipv6.text_to_bin(adrs[1])[slice_i], res[7]) + self.assertEqual(addrconv.ipv6.text_to_bin(adrs[2])[slice_e], res[8]) def test_len(self): - eq_((6 + 1) * 8, len(self.routing)) + self.assertEqual((6 + 1) * 8, len(self.routing)) def test_default_args(self): hdr = ipv6.routing_type3() @@ -1003,12 +1000,12 @@ class Test_routing_type3(unittest.TestCase): res = struct.unpack_from(ipv6.routing_type3._PACK_STR, six.binary_type(buf)) LOG.info(res) - eq_(res[0], 6) - eq_(res[1], 0) - eq_(res[2], 3) - eq_(res[3], 0) - eq_(res[4], (0 << 4) | 0) - eq_(res[5], 0) + self.assertEqual(res[0], 6) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 3) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], (0 << 4) | 0) + self.assertEqual(res[5], 0) class Test_fragment(unittest.TestCase): @@ -1026,10 +1023,10 @@ class Test_fragment(unittest.TestCase): self.buf = struct.pack(self.form, self.nxt, self.off_m, self.id_) def test_init(self): - eq_(self.nxt, self.fragment.nxt) - eq_(self.offset, self.fragment.offset) - eq_(self.more, self.fragment.more) - eq_(self.id_, self.fragment.id_) + self.assertEqual(self.nxt, self.fragment.nxt) + self.assertEqual(self.offset, self.fragment.offset) + self.assertEqual(self.more, self.fragment.more) + self.assertEqual(self.id_, self.fragment.id_) def test_parser(self): _res = ipv6.fragment.parser(self.buf) @@ -1037,29 +1034,29 @@ class Test_fragment(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.nxt, res.nxt) - eq_(self.offset, res.offset) - eq_(self.more, res.more) - eq_(self.id_, res.id_) + self.assertEqual(self.nxt, res.nxt) + self.assertEqual(self.offset, res.offset) + self.assertEqual(self.more, res.more) + self.assertEqual(self.id_, res.id_) def test_serialize(self): buf = self.fragment.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.nxt, res[0]) - eq_(self.off_m, res[1]) - eq_(self.id_, res[2]) + self.assertEqual(self.nxt, res[0]) + self.assertEqual(self.off_m, res[1]) + self.assertEqual(self.id_, res[2]) def test_len(self): - eq_(8, len(self.fragment)) + self.assertEqual(8, len(self.fragment)) def test_default_args(self): hdr = ipv6.fragment() buf = hdr.serialize() res = struct.unpack_from(ipv6.fragment._PACK_STR, buf) - eq_(res[0], 6) - eq_(res[1], 0) - eq_(res[2], 0) + self.assertEqual(res[0], 6) + self.assertEqual(res[1], 0) + self.assertEqual(res[2], 0) class Test_auth(unittest.TestCase): @@ -1077,11 +1074,11 @@ class Test_auth(unittest.TestCase): self.seq, self.data) def test_init(self): - eq_(self.nxt, self.auth.nxt) - eq_(self.size, self.auth.size) - eq_(self.spi, self.auth.spi) - eq_(self.seq, self.auth.seq) - eq_(self.data, self.auth.data) + self.assertEqual(self.nxt, self.auth.nxt) + self.assertEqual(self.size, self.auth.size) + self.assertEqual(self.spi, self.auth.spi) + self.assertEqual(self.seq, self.auth.seq) + self.assertEqual(self.data, self.auth.data) def test_parser(self): _res = ipv6.auth.parser(self.buf) @@ -1089,30 +1086,30 @@ class Test_auth(unittest.TestCase): res = _res[0] else: res = _res - eq_(self.nxt, res.nxt) - eq_(self.size, res.size) - eq_(self.spi, res.spi) - eq_(self.seq, res.seq) - eq_(self.data, res.data) + self.assertEqual(self.nxt, res.nxt) + self.assertEqual(self.size, res.size) + self.assertEqual(self.spi, res.spi) + self.assertEqual(self.seq, res.seq) + self.assertEqual(self.data, res.data) def test_serialize(self): buf = self.auth.serialize() res = struct.unpack_from(self.form, six.binary_type(buf)) - eq_(self.nxt, res[0]) - eq_(self.size, res[1]) - eq_(self.spi, res[2]) - eq_(self.seq, res[3]) - eq_(self.data, res[4]) + self.assertEqual(self.nxt, res[0]) + self.assertEqual(self.size, res[1]) + self.assertEqual(self.spi, res[2]) + self.assertEqual(self.seq, res[3]) + self.assertEqual(self.data, res[4]) def test_len(self): - eq_((4 + 2) * 4, len(self.auth)) + self.assertEqual((4 + 2) * 4, len(self.auth)) def test_len_re(self): size = 5 auth = ipv6.auth( 0, size, 256, 1, b'\x21\xd3\xa9\x5c\x5f\xfd\x4d\x18\x46\x22\xb9\xf8\xf8\xf8\xf8\xf8') - eq_((size + 2) * 4, len(auth)) + self.assertEqual((size + 2) * 4, len(auth)) def test_default_args(self): hdr = ipv6.auth() @@ -1121,8 +1118,8 @@ class Test_auth(unittest.TestCase): res = struct.unpack_from(ipv6.auth._PACK_STR, six.binary_type(buf)) LOG.info(res) - eq_(res[0], 6) - eq_(res[1], 2) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(buf[ipv6.auth._MIN_LEN:], b'\x00\x00\x00\x00') + self.assertEqual(res[0], 6) + self.assertEqual(res[1], 2) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(buf[ipv6.auth._MIN_LEN:], b'\x00\x00\x00\x00') diff --git a/os_ken/tests/unit/packet/test_llc.py b/os_ken/tests/unit/packet/test_llc.py index 6c6a29fc..d1e72058 100644 --- a/os_ken/tests/unit/packet/test_llc.py +++ b/os_ken/tests/unit/packet/test_llc.py @@ -18,7 +18,6 @@ import unittest import logging -from nose.tools import eq_ from os_ken.lib.packet import llc @@ -31,7 +30,7 @@ class Test_ControlFormatI(unittest.TestCase): def test_json(self): jsondict = self.msg.to_jsondict() msg = llc.llc.from_jsondict(jsondict['llc']) - eq_(str(self.msg), str(msg)) + self.assertEqual(str(self.msg), str(msg)) class Test_ControlFormatS(Test_ControlFormatI): diff --git a/os_ken/tests/unit/packet/test_lldp.py b/os_ken/tests/unit/packet/test_lldp.py index 2d17de7a..35b05553 100644 --- a/os_ken/tests/unit/packet/test_lldp.py +++ b/os_ken/tests/unit/packet/test_lldp.py @@ -20,7 +20,6 @@ import logging import six import struct import inspect -from nose.tools import ok_, eq_, nottest from os_ken.ofproto import ether from os_ken.lib.packet import packet @@ -48,42 +47,42 @@ class TestLLDPMandatoryTLV(unittest.TestCase): def test_get_tlv_type(self): buf = b'\x02\x07\x04\x00\x04\x96\x1f\xa7\x26' - eq_(lldp.LLDPBasicTLV.get_type(buf), lldp.LLDP_TLV_CHASSIS_ID) + self.assertEqual(lldp.LLDPBasicTLV.get_type(buf), lldp.LLDP_TLV_CHASSIS_ID) def test_parse_without_ethernet(self): buf = self.data[ethernet.ethernet._MIN_LEN:] (lldp_pkt, cls, rest_buf) = lldp.lldp.parser(buf) - eq_(len(rest_buf), 0) + self.assertEqual(len(rest_buf), 0) tlvs = lldp_pkt.tlvs - eq_(tlvs[0].tlv_type, lldp.LLDP_TLV_CHASSIS_ID) - eq_(tlvs[0].len, 7) - eq_(tlvs[0].subtype, lldp.ChassisID.SUB_MAC_ADDRESS) - eq_(tlvs[0].chassis_id, b'\x00\x04\x96\x1f\xa7\x26') - eq_(tlvs[1].tlv_type, lldp.LLDP_TLV_PORT_ID) - eq_(tlvs[1].len, 4) - eq_(tlvs[1].subtype, lldp.PortID.SUB_INTERFACE_NAME) - eq_(tlvs[1].port_id, b'1/3') - eq_(tlvs[2].tlv_type, lldp.LLDP_TLV_TTL) - eq_(tlvs[2].len, 2) - eq_(tlvs[2].ttl, 120) - eq_(tlvs[3].tlv_type, lldp.LLDP_TLV_END) + self.assertEqual(tlvs[0].tlv_type, lldp.LLDP_TLV_CHASSIS_ID) + self.assertEqual(tlvs[0].len, 7) + self.assertEqual(tlvs[0].subtype, lldp.ChassisID.SUB_MAC_ADDRESS) + self.assertEqual(tlvs[0].chassis_id, b'\x00\x04\x96\x1f\xa7\x26') + self.assertEqual(tlvs[1].tlv_type, lldp.LLDP_TLV_PORT_ID) + self.assertEqual(tlvs[1].len, 4) + self.assertEqual(tlvs[1].subtype, lldp.PortID.SUB_INTERFACE_NAME) + self.assertEqual(tlvs[1].port_id, b'1/3') + self.assertEqual(tlvs[2].tlv_type, lldp.LLDP_TLV_TTL) + self.assertEqual(tlvs[2].len, 2) + self.assertEqual(tlvs[2].ttl, 120) + self.assertEqual(tlvs[3].tlv_type, lldp.LLDP_TLV_END) def test_parse(self): buf = self.data pkt = packet.Packet(buf) i = iter(pkt) - eq_(type(next(i)), ethernet.ethernet) - eq_(type(next(i)), lldp.lldp) + self.assertEqual(type(next(i)), ethernet.ethernet) + self.assertEqual(type(next(i)), lldp.lldp) def test_tlv(self): tlv = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS, chassis_id=b'\x00\x04\x96\x1f\xa7\x26') - eq_(tlv.tlv_type, lldp.LLDP_TLV_CHASSIS_ID) - eq_(tlv.len, 7) + self.assertEqual(tlv.tlv_type, lldp.LLDP_TLV_CHASSIS_ID) + self.assertEqual(tlv.len, 7) (typelen, ) = struct.unpack('!H', b'\x02\x07') - eq_(tlv.typelen, typelen) + self.assertEqual(tlv.typelen, typelen) def test_serialize_without_ethernet(self): tlv_chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS, @@ -95,7 +94,7 @@ class TestLLDPMandatoryTLV(unittest.TestCase): tlvs = (tlv_chassis_id, tlv_port_id, tlv_ttl, tlv_end) lldp_pkt = lldp.lldp(tlvs) - eq_(lldp_pkt.serialize(None, None), + self.assertEqual(lldp_pkt.serialize(None, None), self.data[ethernet.ethernet._MIN_LEN:]) def test_serialize(self): @@ -118,7 +117,7 @@ class TestLLDPMandatoryTLV(unittest.TestCase): lldp_pkt = lldp.lldp(tlvs) pkt.add_protocol(lldp_pkt) - eq_(len(pkt.protocols), 2) + self.assertEqual(len(pkt.protocols), 2) pkt.serialize() @@ -128,9 +127,9 @@ class TestLLDPMandatoryTLV(unittest.TestCase): data_len = len(self.data) pkt_data_lldp = pkt.data[:data_len] pkt_data_pad = pkt.data[data_len:] - eq_(b'\x00' * (60 - data_len), pkt_data_pad) + self.assertEqual(b'\x00' * (60 - data_len), pkt_data_pad) - eq_(self.data, pkt_data_lldp) + self.assertEqual(self.data, pkt_data_lldp) def test_to_string(self): chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS, @@ -185,8 +184,8 @@ class TestLLDPMandatoryTLV(unittest.TestCase): lldp_str = _lldp_str % (lldp.lldp.__name__, tlvs_str) - eq_(str(lldp_pkt), lldp_str) - eq_(repr(lldp_pkt), lldp_str) + self.assertEqual(str(lldp_pkt), lldp_str) + self.assertEqual(repr(lldp_pkt), lldp_str) def test_json(self): chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS, @@ -199,7 +198,7 @@ class TestLLDPMandatoryTLV(unittest.TestCase): lldp1 = lldp.lldp(tlvs) jsondict = lldp1.to_jsondict() lldp2 = lldp.lldp.from_jsondict(jsondict['lldp']) - eq_(str(lldp1), str(lldp2)) + self.assertEqual(str(lldp1), str(lldp2)) class TestLLDPOptionalTLV(unittest.TestCase): @@ -250,49 +249,49 @@ class TestLLDPOptionalTLV(unittest.TestCase): pkt = packet.Packet(buf) i = iter(pkt) - eq_(type(next(i)), ethernet.ethernet) + self.assertEqual(type(next(i)), ethernet.ethernet) lldp_pkt = next(i) - eq_(type(lldp_pkt), lldp.lldp) + self.assertEqual(type(lldp_pkt), lldp.lldp) tlvs = lldp_pkt.tlvs # Port Description - eq_(tlvs[3].tlv_type, lldp.LLDP_TLV_PORT_DESCRIPTION) - eq_(tlvs[3].port_description, b'Summit300-48-Port 1001\x00') + self.assertEqual(tlvs[3].tlv_type, lldp.LLDP_TLV_PORT_DESCRIPTION) + self.assertEqual(tlvs[3].port_description, b'Summit300-48-Port 1001\x00') # System Name - eq_(tlvs[4].tlv_type, lldp.LLDP_TLV_SYSTEM_NAME) - eq_(tlvs[4].system_name, b'Summit300-48\x00') + self.assertEqual(tlvs[4].tlv_type, lldp.LLDP_TLV_SYSTEM_NAME) + self.assertEqual(tlvs[4].system_name, b'Summit300-48\x00') # System Description - eq_(tlvs[5].tlv_type, lldp.LLDP_TLV_SYSTEM_DESCRIPTION) - eq_(tlvs[5].system_description, + self.assertEqual(tlvs[5].tlv_type, lldp.LLDP_TLV_SYSTEM_DESCRIPTION) + self.assertEqual(tlvs[5].system_description, b'Summit300-48 - Version 7.4e.1 (Build 5) ' + b'by Release_Master 05/27/05 04:53:11\x00') # SystemCapabilities - eq_(tlvs[6].tlv_type, lldp.LLDP_TLV_SYSTEM_CAPABILITIES) - eq_(tlvs[6].system_cap & lldp.SystemCapabilities.CAP_MAC_BRIDGE, + self.assertEqual(tlvs[6].tlv_type, lldp.LLDP_TLV_SYSTEM_CAPABILITIES) + self.assertEqual(tlvs[6].system_cap & lldp.SystemCapabilities.CAP_MAC_BRIDGE, lldp.SystemCapabilities.CAP_MAC_BRIDGE) - eq_(tlvs[6].enabled_cap & lldp.SystemCapabilities.CAP_MAC_BRIDGE, + self.assertEqual(tlvs[6].enabled_cap & lldp.SystemCapabilities.CAP_MAC_BRIDGE, lldp.SystemCapabilities.CAP_MAC_BRIDGE) - eq_(tlvs[6].system_cap & lldp.SystemCapabilities.CAP_TELEPHONE, 0) - eq_(tlvs[6].enabled_cap & lldp.SystemCapabilities.CAP_TELEPHONE, 0) + self.assertEqual(tlvs[6].system_cap & lldp.SystemCapabilities.CAP_TELEPHONE, 0) + self.assertEqual(tlvs[6].enabled_cap & lldp.SystemCapabilities.CAP_TELEPHONE, 0) # Management Address - eq_(tlvs[7].tlv_type, lldp.LLDP_TLV_MANAGEMENT_ADDRESS) - eq_(tlvs[7].addr_len, 7) - eq_(tlvs[7].addr, b'\x00\x01\x30\xf9\xad\xa0') - eq_(tlvs[7].intf_num, 1001) + self.assertEqual(tlvs[7].tlv_type, lldp.LLDP_TLV_MANAGEMENT_ADDRESS) + self.assertEqual(tlvs[7].addr_len, 7) + self.assertEqual(tlvs[7].addr, b'\x00\x01\x30\xf9\xad\xa0') + self.assertEqual(tlvs[7].intf_num, 1001) # Organizationally Specific - eq_(tlvs[8].tlv_type, lldp.LLDP_TLV_ORGANIZATIONALLY_SPECIFIC) - eq_(tlvs[8].oui, b'\x00\x12\x0f') # IEEE 802.3 - eq_(tlvs[8].subtype, 0x02) # Power Via MDI + self.assertEqual(tlvs[8].tlv_type, lldp.LLDP_TLV_ORGANIZATIONALLY_SPECIFIC) + self.assertEqual(tlvs[8].oui, b'\x00\x12\x0f') # IEEE 802.3 + self.assertEqual(tlvs[8].subtype, 0x02) # Power Via MDI # End - eq_(tlvs[16].tlv_type, lldp.LLDP_TLV_END) + self.assertEqual(tlvs[16].tlv_type, lldp.LLDP_TLV_END) def test_parse_corrupted(self): buf = self.data @@ -336,13 +335,13 @@ class TestLLDPOptionalTLV(unittest.TestCase): lldp_pkt = lldp.lldp(tlvs) pkt.add_protocol(lldp_pkt) - eq_(len(pkt.protocols), 2) + self.assertEqual(len(pkt.protocols), 2) pkt.serialize() # self.data has many organizationally specific TLVs data = six.binary_type(pkt.data[:-2]) - eq_(data, self.data[:len(data)]) + self.assertEqual(data, self.data[:len(data)]) def test_to_string(self): chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS, @@ -494,8 +493,8 @@ class TestLLDPOptionalTLV(unittest.TestCase): lldp_str = _lldp_str % (lldp.lldp.__name__, tlvs_str) - eq_(str(lldp_pkt), lldp_str) - eq_(repr(lldp_pkt), lldp_str) + self.assertEqual(str(lldp_pkt), lldp_str) + self.assertEqual(repr(lldp_pkt), lldp_str) def test_json(self): chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS, @@ -524,4 +523,4 @@ class TestLLDPOptionalTLV(unittest.TestCase): lldp1 = lldp.lldp(tlvs) jsondict = lldp1.to_jsondict() lldp2 = lldp.lldp.from_jsondict(jsondict['lldp']) - eq_(str(lldp1), str(lldp2)) + self.assertEqual(str(lldp1), str(lldp2)) diff --git a/os_ken/tests/unit/packet/test_mpls.py b/os_ken/tests/unit/packet/test_mpls.py index 3cbc1693..c69987c7 100644 --- a/os_ken/tests/unit/packet/test_mpls.py +++ b/os_ken/tests/unit/packet/test_mpls.py @@ -18,7 +18,6 @@ import unittest import logging import inspect -from nose.tools import eq_ from os_ken.lib.packet import mpls @@ -49,13 +48,13 @@ class Test_mpls(unittest.TestCase): if k in mpls_values]) mpls_str = '%s(%s)' % (mpls.mpls.__name__, _mpls_str) - eq_(str(self.mp), mpls_str) - eq_(repr(self.mp), mpls_str) + self.assertEqual(str(self.mp), mpls_str) + self.assertEqual(repr(self.mp), mpls_str) def test_json(self): jsondict = self.mp.to_jsondict() mp = mpls.mpls.from_jsondict(jsondict['mpls']) - eq_(str(self.mp), str(mp)) + self.assertEqual(str(self.mp), str(mp)) def test_label_from_bin_true(self): mpls_label = 0xfffff @@ -63,8 +62,8 @@ class Test_mpls(unittest.TestCase): buf = b'\xff\xff\xf1' mpls_label_out, is_bos_out = mpls.label_from_bin(buf) - eq_(mpls_label, mpls_label_out) - eq_(is_bos, is_bos_out) + self.assertEqual(mpls_label, mpls_label_out) + self.assertEqual(is_bos, is_bos_out) def test_label_from_bin_false(self): mpls_label = 0xfffff @@ -72,8 +71,8 @@ class Test_mpls(unittest.TestCase): buf = b'\xff\xff\xf0' mpls_label_out, is_bos_out = mpls.label_from_bin(buf) - eq_(mpls_label, mpls_label_out) - eq_(is_bos, is_bos_out) + self.assertEqual(mpls_label, mpls_label_out) + self.assertEqual(is_bos, is_bos_out) def test_label_to_bin_true(self): mpls_label = 0xfffff @@ -81,7 +80,7 @@ class Test_mpls(unittest.TestCase): label = b'\xff\xff\xf1' label_out = mpls.label_to_bin(mpls_label, is_bos) - eq_(label, label_out) + self.assertEqual(label, label_out) def test_label_to_bin_false(self): mpls_label = 0xfffff @@ -89,4 +88,4 @@ class Test_mpls(unittest.TestCase): label = b'\xff\xff\xf0' label_out = mpls.label_to_bin(mpls_label, is_bos) - eq_(label, label_out) + self.assertEqual(label, label_out) diff --git a/os_ken/tests/unit/packet/test_openflow.py b/os_ken/tests/unit/packet/test_openflow.py index 10e6caf1..063b9e4c 100644 --- a/os_ken/tests/unit/packet/test_openflow.py +++ b/os_ken/tests/unit/packet/test_openflow.py @@ -18,8 +18,6 @@ import os import sys import unittest -from nose.tools import eq_ -from nose.tools import ok_ from os_ken.lib import pcaplib from os_ken.lib.packet import openflow @@ -53,10 +51,10 @@ class Test_openflow(unittest.TestCase): # Checks if message can be parsed as expected. pkt = packet.Packet(buf) openflow_pkt = pkt.get_protocol(openflow.openflow) - ok_(isinstance(openflow_pkt, openflow.openflow), + self.assertTrue(isinstance(openflow_pkt, openflow.openflow), 'Failed to parse OpenFlow message: %s' % pkt) # Checks if message can be serialized as expected. pkt.serialize() - eq_(buf, pkt.data, + self.assertEqual(buf, pkt.data, "b'%s' != b'%s'" % (binary_str(buf), binary_str(pkt.data))) diff --git a/os_ken/tests/unit/packet/test_ospf.py b/os_ken/tests/unit/packet/test_ospf.py index ee2a7293..6f2f0ef5 100644 --- a/os_ken/tests/unit/packet/test_ospf.py +++ b/os_ken/tests/unit/packet/test_ospf.py @@ -14,8 +14,6 @@ # limitations under the License. import unittest -from nose.tools import eq_ -from nose.tools import ok_ from os_ken.lib.packet import ospf @@ -37,18 +35,18 @@ class Test_ospf(unittest.TestCase): links=[link1]) binmsg = msg.serialize() msg2, cls, rest = ospf.LSA.parser(binmsg) - eq_(msg.header.checksum, msg2.header.checksum) - eq_(str(msg), str(msg2)) - eq_(rest, b'') + self.assertEqual(msg.header.checksum, msg2.header.checksum) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(rest, b'') def test_network_lsa(self): msg = ospf.NetworkLSA(id_='192.168.0.1', adv_router='192.168.0.2', mask='255.255.255.0', routers=['192.168.0.2']) binmsg = msg.serialize() msg2, cls, rest = ospf.LSA.parser(binmsg) - eq_(msg.header.checksum, msg2.header.checksum) - eq_(str(msg), str(msg2)) - eq_(rest, b'') + self.assertEqual(msg.header.checksum, msg2.header.checksum) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(rest, b'') def test_as_external_lsa(self): extnw1 = ospf.ASExternalLSA.ExternalNetwork(mask='255.255.255.0', @@ -58,18 +56,18 @@ class Test_ospf(unittest.TestCase): extnws=[extnw1]) binmsg = msg.serialize() msg2, cls, rest = ospf.LSA.parser(binmsg) - eq_(msg.header.checksum, msg2.header.checksum) - eq_(str(msg), str(msg2)) - eq_(rest, b'') + self.assertEqual(msg.header.checksum, msg2.header.checksum) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(rest, b'') def test_hello(self): msg = ospf.OSPFHello(router_id='192.168.0.1', neighbors=['192.168.0.2']) binmsg = msg.serialize() msg2, cls, rest = ospf.OSPFMessage.parser(binmsg) - eq_(msg.checksum, msg2.checksum) - eq_(str(msg), str(msg2)) - eq_(rest, b'') + self.assertEqual(msg.checksum, msg2.checksum) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(rest, b'') def test_dbdesc(self): link1 = ospf.RouterLSA.Link(id_='10.0.0.1', data='255.255.255.0', @@ -80,9 +78,9 @@ class Test_ospf(unittest.TestCase): lsa_headers=[lsa1.header]) binmsg = msg.serialize() msg2, cls, rest = ospf.OSPFMessage.parser(binmsg) - eq_(msg.checksum, msg2.checksum) - eq_(str(msg), str(msg2)) - eq_(rest, b'') + self.assertEqual(msg.checksum, msg2.checksum) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(rest, b'') def test_lsreq(self): req = ospf.OSPFLSReq.Request(type_=ospf.OSPF_ROUTER_LSA, @@ -91,9 +89,9 @@ class Test_ospf(unittest.TestCase): msg = ospf.OSPFLSReq(router_id='192.168.0.1', lsa_requests=[req]) binmsg = msg.serialize() msg2, cls, rest = ospf.OSPFMessage.parser(binmsg) - eq_(msg.checksum, msg2.checksum) - eq_(str(msg), str(msg2)) - eq_(rest, b'') + self.assertEqual(msg.checksum, msg2.checksum) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(rest, b'') def test_lsupd(self): link1 = ospf.RouterLSA.Link(id_='10.0.0.1', data='255.255.255.0', @@ -103,9 +101,9 @@ class Test_ospf(unittest.TestCase): msg = ospf.OSPFLSUpd(router_id='192.168.0.1', lsas=[lsa1]) binmsg = msg.serialize() msg2, cls, rest = ospf.OSPFMessage.parser(binmsg) - eq_(msg.checksum, msg2.checksum) - eq_(str(msg), str(msg2)) - eq_(rest, b'') + self.assertEqual(msg.checksum, msg2.checksum) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(rest, b'') def test_lsack(self): link1 = ospf.RouterLSA.Link(id_='10.0.0.1', data='255.255.255.0', @@ -116,6 +114,6 @@ class Test_ospf(unittest.TestCase): lsa_headers=[lsa1.header]) binmsg = msg.serialize() msg2, cls, rest = ospf.OSPFMessage.parser(binmsg) - eq_(msg.checksum, msg2.checksum) - eq_(str(msg), str(msg2)) - eq_(rest, b'') + self.assertEqual(msg.checksum, msg2.checksum) + self.assertEqual(str(msg), str(msg2)) + self.assertEqual(rest, b'') diff --git a/os_ken/tests/unit/packet/test_packet.py b/os_ken/tests/unit/packet/test_packet.py index 770900f6..9ddf0465 100644 --- a/os_ken/tests/unit/packet/test_packet.py +++ b/os_ken/tests/unit/packet/test_packet.py @@ -19,7 +19,6 @@ import unittest import logging import struct import inspect -from nose.tools import ok_, eq_ import six from os_ken.ofproto import ether, inet from os_ken.lib.packet import arp @@ -106,7 +105,7 @@ class TestPacket(unittest.TestCase): pad_len = 60 - len(buf) if pad_len > 0: buf += b'\x00' * pad_len - eq_(buf, p.data) + self.assertEqual(buf, p.data) # parse pkt = packet.Packet(p.data) @@ -115,22 +114,22 @@ class TestPacket(unittest.TestCase): p_arp = protocols['arp'] # ethernet - ok_(p_eth) - eq_(self.dst_mac, p_eth.dst) - eq_(self.src_mac, p_eth.src) - eq_(ether.ETH_TYPE_ARP, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual(self.dst_mac, p_eth.dst) + self.assertEqual(self.src_mac, p_eth.src) + self.assertEqual(ether.ETH_TYPE_ARP, p_eth.ethertype) # arp - ok_(p_arp) - eq_(1, p_arp.hwtype) - eq_(ether.ETH_TYPE_IP, p_arp.proto) - eq_(6, p_arp.hlen) - eq_(4, p_arp.plen) - eq_(2, p_arp.opcode) - eq_(self.src_mac, p_arp.src_mac) - eq_(self.src_ip, p_arp.src_ip) - eq_(self.dst_mac, p_arp.dst_mac) - eq_(self.dst_ip, p_arp.dst_ip) + self.assertTrue(p_arp) + self.assertEqual(1, p_arp.hwtype) + self.assertEqual(ether.ETH_TYPE_IP, p_arp.proto) + self.assertEqual(6, p_arp.hlen) + self.assertEqual(4, p_arp.plen) + self.assertEqual(2, p_arp.opcode) + self.assertEqual(self.src_mac, p_arp.src_mac) + self.assertEqual(self.src_ip, p_arp.src_ip) + self.assertEqual(self.dst_mac, p_arp.dst_mac) + self.assertEqual(self.dst_ip, p_arp.dst_ip) # to string eth_values = {'dst': self.dst_mac, @@ -157,14 +156,14 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s' % (eth_str, arp_str) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(arp_str, str(p_arp)) - eq_(arp_str, repr(p_arp)) + self.assertEqual(arp_str, str(p_arp)) + self.assertEqual(arp_str, repr(p_arp)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_vlan_arp(self): # buid packet @@ -206,7 +205,7 @@ class TestPacket(unittest.TestCase): pad_len = 60 - len(buf) if pad_len > 0: buf += b'\x00' * pad_len - eq_(buf, p.data) + self.assertEqual(buf, p.data) # parse pkt = packet.Packet(p.data) @@ -216,29 +215,29 @@ class TestPacket(unittest.TestCase): p_arp = protocols['arp'] # ethernet - ok_(p_eth) - eq_(self.dst_mac, p_eth.dst) - eq_(self.src_mac, p_eth.src) - eq_(ether.ETH_TYPE_8021Q, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual(self.dst_mac, p_eth.dst) + self.assertEqual(self.src_mac, p_eth.src) + self.assertEqual(ether.ETH_TYPE_8021Q, p_eth.ethertype) # vlan - ok_(p_vlan) - eq_(0b111, p_vlan.pcp) - eq_(0b1, p_vlan.cfi) - eq_(3, p_vlan.vid) - eq_(ether.ETH_TYPE_ARP, p_vlan.ethertype) + self.assertTrue(p_vlan) + self.assertEqual(0b111, p_vlan.pcp) + self.assertEqual(0b1, p_vlan.cfi) + self.assertEqual(3, p_vlan.vid) + self.assertEqual(ether.ETH_TYPE_ARP, p_vlan.ethertype) # arp - ok_(p_arp) - eq_(1, p_arp.hwtype) - eq_(ether.ETH_TYPE_IP, p_arp.proto) - eq_(6, p_arp.hlen) - eq_(4, p_arp.plen) - eq_(2, p_arp.opcode) - eq_(self.src_mac, p_arp.src_mac) - eq_(self.src_ip, p_arp.src_ip) - eq_(self.dst_mac, p_arp.dst_mac) - eq_(self.dst_ip, p_arp.dst_ip) + self.assertTrue(p_arp) + self.assertEqual(1, p_arp.hwtype) + self.assertEqual(ether.ETH_TYPE_IP, p_arp.proto) + self.assertEqual(6, p_arp.hlen) + self.assertEqual(4, p_arp.plen) + self.assertEqual(2, p_arp.opcode) + self.assertEqual(self.src_mac, p_arp.src_mac) + self.assertEqual(self.src_ip, p_arp.src_ip) + self.assertEqual(self.dst_mac, p_arp.dst_mac) + self.assertEqual(self.dst_ip, p_arp.dst_ip) # to string eth_values = {'dst': self.dst_mac, @@ -274,17 +273,17 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s' % (eth_str, vlan_str, arp_str) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(vlan_str, str(p_vlan)) - eq_(vlan_str, repr(p_vlan)) + self.assertEqual(vlan_str, str(p_vlan)) + self.assertEqual(vlan_str, repr(p_vlan)) - eq_(arp_str, str(p_arp)) - eq_(arp_str, repr(p_arp)) + self.assertEqual(arp_str, str(p_arp)) + self.assertEqual(arp_str, repr(p_arp)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_ipv4_udp(self): # buid packet @@ -334,44 +333,44 @@ class TestPacket(unittest.TestCase): p_udp = protocols['udp'] # ethernet - ok_(p_eth) - eq_(self.dst_mac, p_eth.dst) - eq_(self.src_mac, p_eth.src) - eq_(ether.ETH_TYPE_IP, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual(self.dst_mac, p_eth.dst) + self.assertEqual(self.src_mac, p_eth.src) + self.assertEqual(ether.ETH_TYPE_IP, p_eth.ethertype) # ipv4 - ok_(p_ipv4) - eq_(4, p_ipv4.version) - eq_(5, p_ipv4.header_length) - eq_(1, p_ipv4.tos) + self.assertTrue(p_ipv4) + self.assertEqual(4, p_ipv4.version) + self.assertEqual(5, p_ipv4.header_length) + self.assertEqual(1, p_ipv4.tos) l = len(ip_buf) + len(u_buf) + len(self.payload) - eq_(l, p_ipv4.total_length) - eq_(3, p_ipv4.identification) - eq_(1, p_ipv4.flags) - eq_(64, p_ipv4.ttl) - eq_(inet.IPPROTO_UDP, p_ipv4.proto) - eq_(self.src_ip, p_ipv4.src) - eq_(self.dst_ip, p_ipv4.dst) + self.assertEqual(l, p_ipv4.total_length) + self.assertEqual(3, p_ipv4.identification) + self.assertEqual(1, p_ipv4.flags) + self.assertEqual(64, p_ipv4.ttl) + self.assertEqual(inet.IPPROTO_UDP, p_ipv4.proto) + self.assertEqual(self.src_ip, p_ipv4.src) + self.assertEqual(self.dst_ip, p_ipv4.dst) t = bytearray(ip_buf) struct.pack_into('!H', t, 10, p_ipv4.csum) - eq_(packet_utils.checksum(t), 0) + self.assertEqual(packet_utils.checksum(t), 0) # udp - ok_(p_udp) - eq_(0x190f, p_udp.src_port) - eq_(0x1F90, p_udp.dst_port) - eq_(len(u_buf) + len(self.payload), p_udp.total_length) - eq_(0x77b2, p_udp.csum) + self.assertTrue(p_udp) + self.assertEqual(0x190f, p_udp.src_port) + self.assertEqual(0x1F90, p_udp.dst_port) + self.assertEqual(len(u_buf) + len(self.payload), p_udp.total_length) + self.assertEqual(0x77b2, p_udp.csum) t = bytearray(u_buf) struct.pack_into('!H', t, 6, p_udp.csum) ph = struct.pack('!4s4sBBH', self.src_ip_bin, self.dst_ip_bin, 0, 17, len(u_buf) + len(self.payload)) t = ph + t + self.payload - eq_(packet_utils.checksum(t), 0) + self.assertEqual(packet_utils.checksum(t), 0) # payload - ok_('payload' in protocols) - eq_(self.payload, protocols['payload']) + self.assertTrue('payload' in protocols) + self.assertEqual(self.payload, protocols['payload']) # to string eth_values = {'dst': self.dst_mac, @@ -412,17 +411,17 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s, %s' % (eth_str, ipv4_str, udp_str, repr(protocols['payload'])) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(ipv4_str, str(p_ipv4)) - eq_(ipv4_str, repr(p_ipv4)) + self.assertEqual(ipv4_str, str(p_ipv4)) + self.assertEqual(ipv4_str, repr(p_ipv4)) - eq_(udp_str, str(p_udp)) - eq_(udp_str, repr(p_udp)) + self.assertEqual(udp_str, str(p_udp)) + self.assertEqual(udp_str, repr(p_udp)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_ipv4_tcp(self): # buid packet @@ -479,49 +478,49 @@ class TestPacket(unittest.TestCase): p_tcp = protocols['tcp'] # ethernet - ok_(p_eth) - eq_(self.dst_mac, p_eth.dst) - eq_(self.src_mac, p_eth.src) - eq_(ether.ETH_TYPE_IP, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual(self.dst_mac, p_eth.dst) + self.assertEqual(self.src_mac, p_eth.src) + self.assertEqual(ether.ETH_TYPE_IP, p_eth.ethertype) # ipv4 - ok_(p_ipv4) - eq_(4, p_ipv4.version) - eq_(5, p_ipv4.header_length) - eq_(0, p_ipv4.tos) + self.assertTrue(p_ipv4) + self.assertEqual(4, p_ipv4.version) + self.assertEqual(5, p_ipv4.header_length) + self.assertEqual(0, p_ipv4.tos) l = len(ip_buf) + len(t_buf) + len(self.payload) - eq_(l, p_ipv4.total_length) - eq_(0, p_ipv4.identification) - eq_(0, p_ipv4.flags) - eq_(64, p_ipv4.ttl) - eq_(inet.IPPROTO_TCP, p_ipv4.proto) - eq_(self.src_ip, p_ipv4.src) - eq_(self.dst_ip, p_ipv4.dst) + self.assertEqual(l, p_ipv4.total_length) + self.assertEqual(0, p_ipv4.identification) + self.assertEqual(0, p_ipv4.flags) + self.assertEqual(64, p_ipv4.ttl) + self.assertEqual(inet.IPPROTO_TCP, p_ipv4.proto) + self.assertEqual(self.src_ip, p_ipv4.src) + self.assertEqual(self.dst_ip, p_ipv4.dst) t = bytearray(ip_buf) struct.pack_into('!H', t, 10, p_ipv4.csum) - eq_(packet_utils.checksum(t), 0) + self.assertEqual(packet_utils.checksum(t), 0) # tcp - ok_(p_tcp) - eq_(0x190f, p_tcp.src_port) - eq_(0x1F90, p_tcp.dst_port) - eq_(0x123, p_tcp.seq) - eq_(1, p_tcp.ack) - eq_(6, p_tcp.offset) - eq_(0b101010, p_tcp.bits) - eq_(2048, p_tcp.window_size) - eq_(0x6f, p_tcp.urgent) - eq_(len(t_buf), len(p_tcp)) + self.assertTrue(p_tcp) + self.assertEqual(0x190f, p_tcp.src_port) + self.assertEqual(0x1F90, p_tcp.dst_port) + self.assertEqual(0x123, p_tcp.seq) + self.assertEqual(1, p_tcp.ack) + self.assertEqual(6, p_tcp.offset) + self.assertEqual(0b101010, p_tcp.bits) + self.assertEqual(2048, p_tcp.window_size) + self.assertEqual(0x6f, p_tcp.urgent) + self.assertEqual(len(t_buf), len(p_tcp)) t = bytearray(t_buf) struct.pack_into('!H', t, 16, p_tcp.csum) ph = struct.pack('!4s4sBBH', self.src_ip_bin, self.dst_ip_bin, 0, 6, len(t_buf) + len(self.payload)) t = ph + t + self.payload - eq_(packet_utils.checksum(t), 0) + self.assertEqual(packet_utils.checksum(t), 0) # payload - ok_('payload' in protocols) - eq_(self.payload, protocols['payload']) + self.assertTrue('payload' in protocols) + self.assertEqual(self.payload, protocols['payload']) # to string eth_values = {'dst': self.dst_mac, @@ -568,17 +567,17 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s, %s' % (eth_str, ipv4_str, tcp_str, repr(protocols['payload'])) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(ipv4_str, str(p_ipv4)) - eq_(ipv4_str, repr(p_ipv4)) + self.assertEqual(ipv4_str, str(p_ipv4)) + self.assertEqual(ipv4_str, repr(p_ipv4)) - eq_(tcp_str, str(p_tcp)) - eq_(tcp_str, repr(p_tcp)) + self.assertEqual(tcp_str, str(p_tcp)) + self.assertEqual(tcp_str, repr(p_tcp)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_ipv4_sctp(self): # build packet @@ -632,45 +631,45 @@ class TestPacket(unittest.TestCase): p_sctp = protocols['sctp'] # ethernet - ok_(p_eth) - eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) - eq_('00:00:00:00:00:00', p_eth.src) - eq_(ether.ETH_TYPE_IP, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual('ff:ff:ff:ff:ff:ff', p_eth.dst) + self.assertEqual('00:00:00:00:00:00', p_eth.src) + self.assertEqual(ether.ETH_TYPE_IP, p_eth.ethertype) # ipv4 - ok_(p_ipv4) - eq_(4, p_ipv4.version) - eq_(5, p_ipv4.header_length) - eq_(0, p_ipv4.tos) + self.assertTrue(p_ipv4) + self.assertEqual(4, p_ipv4.version) + self.assertEqual(5, p_ipv4.header_length) + self.assertEqual(0, p_ipv4.tos) l = len(ip_buf) + len(s_buf) - eq_(l, p_ipv4.total_length) - eq_(0, p_ipv4.identification) - eq_(0, p_ipv4.flags) - eq_(255, p_ipv4.ttl) - eq_(inet.IPPROTO_SCTP, p_ipv4.proto) - eq_('10.0.0.1', p_ipv4.src) - eq_('10.0.0.2', p_ipv4.dst) + self.assertEqual(l, p_ipv4.total_length) + self.assertEqual(0, p_ipv4.identification) + self.assertEqual(0, p_ipv4.flags) + self.assertEqual(255, p_ipv4.ttl) + self.assertEqual(inet.IPPROTO_SCTP, p_ipv4.proto) + self.assertEqual('10.0.0.1', p_ipv4.src) + self.assertEqual('10.0.0.2', p_ipv4.dst) t = bytearray(ip_buf) struct.pack_into('!H', t, 10, p_ipv4.csum) - eq_(packet_utils.checksum(t), 0x1403) + self.assertEqual(packet_utils.checksum(t), 0x1403) # sctp - ok_(p_sctp) - eq_(1, p_sctp.src_port) - eq_(1, p_sctp.dst_port) - eq_(0, p_sctp.vtag) + self.assertTrue(p_sctp) + self.assertEqual(1, p_sctp.src_port) + self.assertEqual(1, p_sctp.dst_port) + self.assertEqual(0, p_sctp.vtag) assert isinstance(p_sctp.chunks[0], sctp.chunk_data) - eq_(0, p_sctp.chunks[0]._type) - eq_(0, p_sctp.chunks[0].unordered) - eq_(0, p_sctp.chunks[0].begin) - eq_(0, p_sctp.chunks[0].end) - eq_(16 + len(self.payload), p_sctp.chunks[0].length) - eq_(0, p_sctp.chunks[0].tsn) - eq_(0, p_sctp.chunks[0].sid) - eq_(0, p_sctp.chunks[0].seq) - eq_(0, p_sctp.chunks[0].payload_id) - eq_(self.payload, p_sctp.chunks[0].payload_data) - eq_(len(s_buf), len(p_sctp)) + self.assertEqual(0, p_sctp.chunks[0]._type) + self.assertEqual(0, p_sctp.chunks[0].unordered) + self.assertEqual(0, p_sctp.chunks[0].begin) + self.assertEqual(0, p_sctp.chunks[0].end) + self.assertEqual(16 + len(self.payload), p_sctp.chunks[0].length) + self.assertEqual(0, p_sctp.chunks[0].tsn) + self.assertEqual(0, p_sctp.chunks[0].sid) + self.assertEqual(0, p_sctp.chunks[0].seq) + self.assertEqual(0, p_sctp.chunks[0].payload_id) + self.assertEqual(self.payload, p_sctp.chunks[0].payload_data) + self.assertEqual(len(s_buf), len(p_sctp)) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', @@ -724,17 +723,17 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s' % (eth_str, ipv4_str, sctp_str) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(ipv4_str, str(p_ipv4)) - eq_(ipv4_str, repr(p_ipv4)) + self.assertEqual(ipv4_str, str(p_ipv4)) + self.assertEqual(ipv4_str, repr(p_ipv4)) - eq_(sctp_str, str(p_sctp)) - eq_(sctp_str, repr(p_sctp)) + self.assertEqual(sctp_str, str(p_sctp)) + self.assertEqual(sctp_str, repr(p_sctp)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_ipv4_icmp(self): # buid packet @@ -781,38 +780,38 @@ class TestPacket(unittest.TestCase): p_icmp = protocols['icmp'] # ethernet - ok_(p_eth) - eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) - eq_('00:00:00:00:00:00', p_eth.src) - eq_(ether.ETH_TYPE_IP, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual('ff:ff:ff:ff:ff:ff', p_eth.dst) + self.assertEqual('00:00:00:00:00:00', p_eth.src) + self.assertEqual(ether.ETH_TYPE_IP, p_eth.ethertype) # ipv4 - ok_(p_ipv4) - eq_(4, p_ipv4.version) - eq_(5, p_ipv4.header_length) - eq_(0, p_ipv4.tos) + self.assertTrue(p_ipv4) + self.assertEqual(4, p_ipv4.version) + self.assertEqual(5, p_ipv4.header_length) + self.assertEqual(0, p_ipv4.tos) l = len(ip_buf) + len(ic_buf) - eq_(l, p_ipv4.total_length) - eq_(0, p_ipv4.identification) - eq_(0, p_ipv4.flags) - eq_(255, p_ipv4.ttl) - eq_(inet.IPPROTO_ICMP, p_ipv4.proto) - eq_('10.0.0.1', p_ipv4.src) - eq_('10.0.0.2', p_ipv4.dst) + self.assertEqual(l, p_ipv4.total_length) + self.assertEqual(0, p_ipv4.identification) + self.assertEqual(0, p_ipv4.flags) + self.assertEqual(255, p_ipv4.ttl) + self.assertEqual(inet.IPPROTO_ICMP, p_ipv4.proto) + self.assertEqual('10.0.0.1', p_ipv4.src) + self.assertEqual('10.0.0.2', p_ipv4.dst) t = bytearray(ip_buf) struct.pack_into('!H', t, 10, p_ipv4.csum) - eq_(packet_utils.checksum(t), 0x1403) + self.assertEqual(packet_utils.checksum(t), 0x1403) # icmp - ok_(p_icmp) - eq_(8, p_icmp.type) - eq_(0, p_icmp.code) - eq_(0, p_icmp.data.id) - eq_(0, p_icmp.data.seq) - eq_(len(ic_buf), len(p_icmp)) + self.assertTrue(p_icmp) + self.assertEqual(8, p_icmp.type) + self.assertEqual(0, p_icmp.code) + self.assertEqual(0, p_icmp.data.id) + self.assertEqual(0, p_icmp.data.seq) + self.assertEqual(len(ic_buf), len(p_icmp)) t = bytearray(ic_buf) struct.pack_into('!H', t, 2, p_icmp.csum) - eq_(packet_utils.checksum(t), 0) + self.assertEqual(packet_utils.checksum(t), 0) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', @@ -858,17 +857,17 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s' % (eth_str, ipv4_str, icmp_str) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(ipv4_str, str(p_ipv4)) - eq_(ipv4_str, repr(p_ipv4)) + self.assertEqual(ipv4_str, str(p_ipv4)) + self.assertEqual(ipv4_str, repr(p_ipv4)) - eq_(icmp_str, str(p_icmp)) - eq_(icmp_str, repr(p_icmp)) + self.assertEqual(icmp_str, str(p_icmp)) + self.assertEqual(icmp_str, repr(p_icmp)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_ipv6_udp(self): # build packet @@ -911,38 +910,38 @@ class TestPacket(unittest.TestCase): p_udp = protocols['udp'] # ethernet - ok_(p_eth) - eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) - eq_('00:00:00:00:00:00', p_eth.src) - eq_(ether.ETH_TYPE_IPV6, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual('ff:ff:ff:ff:ff:ff', p_eth.dst) + self.assertEqual('00:00:00:00:00:00', p_eth.src) + self.assertEqual(ether.ETH_TYPE_IPV6, p_eth.ethertype) # ipv6 - ok_(p_ipv6) - eq_(6, p_ipv6.version) - eq_(0, p_ipv6.traffic_class) - eq_(0, p_ipv6.flow_label) - eq_(len(u_buf) + len(self.payload), p_ipv6.payload_length) - eq_(inet.IPPROTO_UDP, p_ipv6.nxt) - eq_(255, p_ipv6.hop_limit) - eq_('10::10', p_ipv6.src) - eq_('20::20', p_ipv6.dst) + self.assertTrue(p_ipv6) + self.assertEqual(6, p_ipv6.version) + self.assertEqual(0, p_ipv6.traffic_class) + self.assertEqual(0, p_ipv6.flow_label) + self.assertEqual(len(u_buf) + len(self.payload), p_ipv6.payload_length) + self.assertEqual(inet.IPPROTO_UDP, p_ipv6.nxt) + self.assertEqual(255, p_ipv6.hop_limit) + self.assertEqual('10::10', p_ipv6.src) + self.assertEqual('20::20', p_ipv6.dst) # udp - ok_(p_udp) - eq_(1, p_udp.src_port) - eq_(1, p_udp.dst_port) - eq_(len(u_buf) + len(self.payload), p_udp.total_length) - eq_(0x2B60, p_udp.csum) + self.assertTrue(p_udp) + self.assertEqual(1, p_udp.src_port) + self.assertEqual(1, p_udp.dst_port) + self.assertEqual(len(u_buf) + len(self.payload), p_udp.total_length) + self.assertEqual(0x2B60, p_udp.csum) t = bytearray(u_buf) struct.pack_into('!H', t, 6, p_udp.csum) ph = struct.pack('!16s16sI3xB', ipaddr, ipaddr, len(u_buf) + len(self.payload), 17) t = ph + t + self.payload - eq_(packet_utils.checksum(t), 0x62) + self.assertEqual(packet_utils.checksum(t), 0x62) # payload - ok_('payload' in protocols) - eq_(self.payload, protocols['payload']) + self.assertTrue('payload' in protocols) + self.assertEqual(self.payload, protocols['payload']) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', @@ -979,17 +978,17 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s, %s' % (eth_str, ipv6_str, udp_str, repr(protocols['payload'])) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(ipv6_str, str(p_ipv6)) - eq_(ipv6_str, repr(p_ipv6)) + self.assertEqual(ipv6_str, str(p_ipv6)) + self.assertEqual(ipv6_str, repr(p_ipv6)) - eq_(udp_str, str(p_udp)) - eq_(udp_str, repr(p_udp)) + self.assertEqual(udp_str, str(p_udp)) + self.assertEqual(udp_str, repr(p_udp)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_ipv6_tcp(self): # build packet @@ -1038,43 +1037,43 @@ class TestPacket(unittest.TestCase): p_tcp = protocols['tcp'] # ethernet - ok_(p_eth) - eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) - eq_('00:00:00:00:00:00', p_eth.src) - eq_(ether.ETH_TYPE_IPV6, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual('ff:ff:ff:ff:ff:ff', p_eth.dst) + self.assertEqual('00:00:00:00:00:00', p_eth.src) + self.assertEqual(ether.ETH_TYPE_IPV6, p_eth.ethertype) # ipv6 - ok_(p_ipv6) - eq_(6, p_ipv6.version) - eq_(0, p_ipv6.traffic_class) - eq_(0, p_ipv6.flow_label) - eq_(len(t_buf) + len(self.payload), p_ipv6.payload_length) - eq_(inet.IPPROTO_TCP, p_ipv6.nxt) - eq_(255, p_ipv6.hop_limit) - eq_('10::10', p_ipv6.src) - eq_('20::20', p_ipv6.dst) + self.assertTrue(p_ipv6) + self.assertEqual(6, p_ipv6.version) + self.assertEqual(0, p_ipv6.traffic_class) + self.assertEqual(0, p_ipv6.flow_label) + self.assertEqual(len(t_buf) + len(self.payload), p_ipv6.payload_length) + self.assertEqual(inet.IPPROTO_TCP, p_ipv6.nxt) + self.assertEqual(255, p_ipv6.hop_limit) + self.assertEqual('10::10', p_ipv6.src) + self.assertEqual('20::20', p_ipv6.dst) # tcp - ok_(p_tcp) - eq_(1, p_tcp.src_port) - eq_(1, p_tcp.dst_port) - eq_(0, p_tcp.seq) - eq_(0, p_tcp.ack) - eq_(6, p_tcp.offset) - eq_(0, p_tcp.bits) - eq_(0, p_tcp.window_size) - eq_(0, p_tcp.urgent) - eq_(len(t_buf), len(p_tcp)) + self.assertTrue(p_tcp) + self.assertEqual(1, p_tcp.src_port) + self.assertEqual(1, p_tcp.dst_port) + self.assertEqual(0, p_tcp.seq) + self.assertEqual(0, p_tcp.ack) + self.assertEqual(6, p_tcp.offset) + self.assertEqual(0, p_tcp.bits) + self.assertEqual(0, p_tcp.window_size) + self.assertEqual(0, p_tcp.urgent) + self.assertEqual(len(t_buf), len(p_tcp)) t = bytearray(t_buf) struct.pack_into('!H', t, 16, p_tcp.csum) ph = struct.pack('!16s16sI3xB', ipaddr, ipaddr, len(t_buf) + len(self.payload), 6) t = ph + t + self.payload - eq_(packet_utils.checksum(t), 0x62) + self.assertEqual(packet_utils.checksum(t), 0x62) # payload - ok_('payload' in protocols) - eq_(self.payload, protocols['payload']) + self.assertTrue('payload' in protocols) + self.assertEqual(self.payload, protocols['payload']) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', @@ -1117,17 +1116,17 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s, %s' % (eth_str, ipv6_str, tcp_str, repr(protocols['payload'])) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(ipv6_str, str(p_ipv6)) - eq_(ipv6_str, repr(p_ipv6)) + self.assertEqual(ipv6_str, str(p_ipv6)) + self.assertEqual(ipv6_str, repr(p_ipv6)) - eq_(tcp_str, str(p_tcp)) - eq_(tcp_str, repr(p_tcp)) + self.assertEqual(tcp_str, str(p_tcp)) + self.assertEqual(tcp_str, repr(p_tcp)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_ipv6_sctp(self): # build packet @@ -1178,39 +1177,39 @@ class TestPacket(unittest.TestCase): p_sctp = protocols['sctp'] # ethernet - ok_(p_eth) - eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) - eq_('00:00:00:00:00:00', p_eth.src) - eq_(ether.ETH_TYPE_IPV6, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual('ff:ff:ff:ff:ff:ff', p_eth.dst) + self.assertEqual('00:00:00:00:00:00', p_eth.src) + self.assertEqual(ether.ETH_TYPE_IPV6, p_eth.ethertype) # ipv6 - ok_(p_ipv6) - eq_(6, p_ipv6.version) - eq_(0, p_ipv6.traffic_class) - eq_(0, p_ipv6.flow_label) - eq_(len(s_buf), p_ipv6.payload_length) - eq_(inet.IPPROTO_SCTP, p_ipv6.nxt) - eq_(255, p_ipv6.hop_limit) - eq_('10::10', p_ipv6.src) - eq_('20::20', p_ipv6.dst) + self.assertTrue(p_ipv6) + self.assertEqual(6, p_ipv6.version) + self.assertEqual(0, p_ipv6.traffic_class) + self.assertEqual(0, p_ipv6.flow_label) + self.assertEqual(len(s_buf), p_ipv6.payload_length) + self.assertEqual(inet.IPPROTO_SCTP, p_ipv6.nxt) + self.assertEqual(255, p_ipv6.hop_limit) + self.assertEqual('10::10', p_ipv6.src) + self.assertEqual('20::20', p_ipv6.dst) # sctp - ok_(p_sctp) - eq_(1, p_sctp.src_port) - eq_(1, p_sctp.dst_port) - eq_(0, p_sctp.vtag) + self.assertTrue(p_sctp) + self.assertEqual(1, p_sctp.src_port) + self.assertEqual(1, p_sctp.dst_port) + self.assertEqual(0, p_sctp.vtag) assert isinstance(p_sctp.chunks[0], sctp.chunk_data) - eq_(0, p_sctp.chunks[0]._type) - eq_(0, p_sctp.chunks[0].unordered) - eq_(0, p_sctp.chunks[0].begin) - eq_(0, p_sctp.chunks[0].end) - eq_(16 + len(self.payload), p_sctp.chunks[0].length) - eq_(0, p_sctp.chunks[0].tsn) - eq_(0, p_sctp.chunks[0].sid) - eq_(0, p_sctp.chunks[0].seq) - eq_(0, p_sctp.chunks[0].payload_id) - eq_(self.payload, p_sctp.chunks[0].payload_data) - eq_(len(s_buf), len(p_sctp)) + self.assertEqual(0, p_sctp.chunks[0]._type) + self.assertEqual(0, p_sctp.chunks[0].unordered) + self.assertEqual(0, p_sctp.chunks[0].begin) + self.assertEqual(0, p_sctp.chunks[0].end) + self.assertEqual(16 + len(self.payload), p_sctp.chunks[0].length) + self.assertEqual(0, p_sctp.chunks[0].tsn) + self.assertEqual(0, p_sctp.chunks[0].sid) + self.assertEqual(0, p_sctp.chunks[0].seq) + self.assertEqual(0, p_sctp.chunks[0].payload_id) + self.assertEqual(self.payload, p_sctp.chunks[0].payload_data) + self.assertEqual(len(s_buf), len(p_sctp)) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', @@ -1260,17 +1259,17 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s' % (eth_str, ipv6_str, sctp_str) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(ipv6_str, str(p_ipv6)) - eq_(ipv6_str, repr(p_ipv6)) + self.assertEqual(ipv6_str, str(p_ipv6)) + self.assertEqual(ipv6_str, repr(p_ipv6)) - eq_(sctp_str, str(p_sctp)) - eq_(sctp_str, repr(p_sctp)) + self.assertEqual(sctp_str, str(p_sctp)) + self.assertEqual(sctp_str, repr(p_sctp)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_ipv6_icmpv6(self): # build packet @@ -1312,32 +1311,32 @@ class TestPacket(unittest.TestCase): p_icmpv6 = protocols['icmpv6'] # ethernet - ok_(p_eth) - eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) - eq_('00:00:00:00:00:00', p_eth.src) - eq_(ether.ETH_TYPE_IPV6, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual('ff:ff:ff:ff:ff:ff', p_eth.dst) + self.assertEqual('00:00:00:00:00:00', p_eth.src) + self.assertEqual(ether.ETH_TYPE_IPV6, p_eth.ethertype) # ipv6 - ok_(p_ipv6) - eq_(6, p_ipv6.version) - eq_(0, p_ipv6.traffic_class) - eq_(0, p_ipv6.flow_label) - eq_(len(ic_buf), p_ipv6.payload_length) - eq_(inet.IPPROTO_ICMPV6, p_ipv6.nxt) - eq_(255, p_ipv6.hop_limit) - eq_('10::10', p_ipv6.src) - eq_('20::20', p_ipv6.dst) + self.assertTrue(p_ipv6) + self.assertEqual(6, p_ipv6.version) + self.assertEqual(0, p_ipv6.traffic_class) + self.assertEqual(0, p_ipv6.flow_label) + self.assertEqual(len(ic_buf), p_ipv6.payload_length) + self.assertEqual(inet.IPPROTO_ICMPV6, p_ipv6.nxt) + self.assertEqual(255, p_ipv6.hop_limit) + self.assertEqual('10::10', p_ipv6.src) + self.assertEqual('20::20', p_ipv6.dst) # icmpv6 - ok_(p_icmpv6) - eq_(0, p_icmpv6.type_) - eq_(0, p_icmpv6.code) - eq_(len(ic_buf), len(p_icmpv6)) + self.assertTrue(p_icmpv6) + self.assertEqual(0, p_icmpv6.type_) + self.assertEqual(0, p_icmpv6.code) + self.assertEqual(len(ic_buf), len(p_icmpv6)) t = bytearray(ic_buf) struct.pack_into('!H', t, 2, p_icmpv6.csum) ph = struct.pack('!16s16sI3xB', ipaddr, ipaddr, len(ic_buf), 58) t = ph + t - eq_(packet_utils.checksum(t), 0x60) + self.assertEqual(packet_utils.checksum(t), 0x60) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', @@ -1373,17 +1372,17 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s' % (eth_str, ipv6_str, icmpv6_str) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(ipv6_str, str(p_ipv6)) - eq_(ipv6_str, repr(p_ipv6)) + self.assertEqual(ipv6_str, str(p_ipv6)) + self.assertEqual(ipv6_str, repr(p_ipv6)) - eq_(icmpv6_str, str(p_icmpv6)) - eq_(icmpv6_str, repr(p_icmpv6)) + self.assertEqual(icmpv6_str, str(p_icmpv6)) + self.assertEqual(icmpv6_str, repr(p_icmpv6)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_llc_bpdu(self): # buid packet @@ -1440,7 +1439,7 @@ class TestPacket(unittest.TestCase): pad_len = 60 - len(buf) if pad_len > 0: buf += b'\x00' * pad_len - eq_(buf, p.data) + self.assertEqual(buf, p.data) # parse pkt = packet.Packet(p.data) @@ -1450,38 +1449,38 @@ class TestPacket(unittest.TestCase): p_bpdu = protocols['ConfigurationBPDUs'] # ethernet - ok_(p_eth) - eq_(self.dst_mac, p_eth.dst) - eq_(self.src_mac, p_eth.src) - eq_(ether.ETH_TYPE_IEEE802_3, p_eth.ethertype) + self.assertTrue(p_eth) + self.assertEqual(self.dst_mac, p_eth.dst) + self.assertEqual(self.src_mac, p_eth.src) + self.assertEqual(ether.ETH_TYPE_IEEE802_3, p_eth.ethertype) # llc - ok_(p_llc) - eq_(llc.SAP_BPDU, p_llc.dsap_addr) - eq_(llc.SAP_BPDU, p_llc.ssap_addr) - eq_(0, p_llc.control.modifier_function1) - eq_(0, p_llc.control.pf_bit) - eq_(0, p_llc.control.modifier_function2) + self.assertTrue(p_llc) + self.assertEqual(llc.SAP_BPDU, p_llc.dsap_addr) + self.assertEqual(llc.SAP_BPDU, p_llc.ssap_addr) + self.assertEqual(0, p_llc.control.modifier_function1) + self.assertEqual(0, p_llc.control.pf_bit) + self.assertEqual(0, p_llc.control.modifier_function2) # bpdu - ok_(p_bpdu) - eq_(bpdu.PROTOCOL_IDENTIFIER, p_bpdu._protocol_id) - eq_(bpdu.PROTOCOLVERSION_ID_BPDU, p_bpdu._version_id) - eq_(bpdu.TYPE_CONFIG_BPDU, p_bpdu._bpdu_type) - eq_(0, p_bpdu.flags) - eq_(32768, p_bpdu.root_priority) - eq_(0, p_bpdu.root_system_id_extension) - eq_(self.src_mac, p_bpdu.root_mac_address) - eq_(0, p_bpdu.root_path_cost) - eq_(32768, p_bpdu.bridge_priority) - eq_(0, p_bpdu.bridge_system_id_extension) - eq_(self.dst_mac, p_bpdu.bridge_mac_address) - eq_(128, p_bpdu.port_priority) - eq_(4, p_bpdu.port_number) - eq_(1, p_bpdu.message_age) - eq_(20, p_bpdu.max_age) - eq_(2, p_bpdu.hello_time) - eq_(15, p_bpdu.forward_delay) + self.assertTrue(p_bpdu) + self.assertEqual(bpdu.PROTOCOL_IDENTIFIER, p_bpdu._protocol_id) + self.assertEqual(bpdu.PROTOCOLVERSION_ID_BPDU, p_bpdu._version_id) + self.assertEqual(bpdu.TYPE_CONFIG_BPDU, p_bpdu._bpdu_type) + self.assertEqual(0, p_bpdu.flags) + self.assertEqual(32768, p_bpdu.root_priority) + self.assertEqual(0, p_bpdu.root_system_id_extension) + self.assertEqual(self.src_mac, p_bpdu.root_mac_address) + self.assertEqual(0, p_bpdu.root_path_cost) + self.assertEqual(32768, p_bpdu.bridge_priority) + self.assertEqual(0, p_bpdu.bridge_system_id_extension) + self.assertEqual(self.dst_mac, p_bpdu.bridge_mac_address) + self.assertEqual(128, p_bpdu.port_priority) + self.assertEqual(4, p_bpdu.port_number) + self.assertEqual(1, p_bpdu.message_age) + self.assertEqual(20, p_bpdu.max_age) + self.assertEqual(2, p_bpdu.hello_time) + self.assertEqual(15, p_bpdu.forward_delay) # to string eth_values = {'dst': self.dst_mac, @@ -1530,24 +1529,24 @@ class TestPacket(unittest.TestCase): pkt_str = '%s, %s, %s' % (eth_str, llc_str, bpdu_str) - eq_(eth_str, str(p_eth)) - eq_(eth_str, repr(p_eth)) + self.assertEqual(eth_str, str(p_eth)) + self.assertEqual(eth_str, repr(p_eth)) - eq_(llc_str, str(p_llc)) - eq_(llc_str, repr(p_llc)) + self.assertEqual(llc_str, str(p_llc)) + self.assertEqual(llc_str, repr(p_llc)) - eq_(bpdu_str, str(p_bpdu)) - eq_(bpdu_str, repr(p_bpdu)) + self.assertEqual(bpdu_str, str(p_bpdu)) + self.assertEqual(bpdu_str, repr(p_bpdu)) - eq_(pkt_str, str(pkt)) - eq_(pkt_str, repr(pkt)) + self.assertEqual(pkt_str, str(pkt)) + self.assertEqual(pkt_str, repr(pkt)) def test_div_api(self): e = ethernet.ethernet(self.dst_mac, self.src_mac, ether.ETH_TYPE_IP) i = ipv4.ipv4() u = udp.udp(self.src_port, self.dst_port) pkt = e / i / u - ok_(isinstance(pkt, packet.Packet)) - ok_(isinstance(pkt.protocols[0], ethernet.ethernet)) - ok_(isinstance(pkt.protocols[1], ipv4.ipv4)) - ok_(isinstance(pkt.protocols[2], udp.udp)) + self.assertTrue(isinstance(pkt, packet.Packet)) + self.assertTrue(isinstance(pkt.protocols[0], ethernet.ethernet)) + self.assertTrue(isinstance(pkt.protocols[1], ipv4.ipv4)) + self.assertTrue(isinstance(pkt.protocols[2], udp.udp)) diff --git a/os_ken/tests/unit/packet/test_pbb.py b/os_ken/tests/unit/packet/test_pbb.py index 629326db..890a8b46 100644 --- a/os_ken/tests/unit/packet/test_pbb.py +++ b/os_ken/tests/unit/packet/test_pbb.py @@ -17,9 +17,6 @@ import logging import struct import unittest -from nose.tools import eq_ -from nose.tools import ok_ -from nose.tools import raises from os_ken.ofproto import ether from os_ken.ofproto import inet from os_ken.lib.packet import ethernet @@ -49,10 +46,10 @@ class Test_itag(unittest.TestCase): pass def test_init(self): - eq_(self.pcp, self.it.pcp) - eq_(self.dei, self.it.dei) - eq_(self.uca, self.it.uca) - eq_(self.sid, self.it.sid) + self.assertEqual(self.pcp, self.it.pcp) + self.assertEqual(self.dei, self.it.dei) + self.assertEqual(self.uca, self.it.uca) + self.assertEqual(self.sid, self.it.sid) def test_parser(self): _res = pbb.itag.parser(self.buf) @@ -60,17 +57,17 @@ class Test_itag(unittest.TestCase): res = _res[0] else: res = _res - eq_(res.pcp, self.pcp) - eq_(res.dei, self.dei) - eq_(res.uca, self.uca) - eq_(res.sid, self.sid) + self.assertEqual(res.pcp, self.pcp) + self.assertEqual(res.dei, self.dei) + self.assertEqual(res.uca, self.uca) + self.assertEqual(res.sid, self.sid) def test_serialize(self): data = bytearray() prev = None buf = self.it.serialize(data, prev) res = struct.unpack(pbb.itag._PACK_STR, buf) - eq_(res[0], self.data) + self.assertEqual(res[0], self.data) def _build_itag(self): b_src_mac = '00:07:0d:af:f4:54' @@ -135,38 +132,37 @@ class Test_itag(unittest.TestCase): p = self._build_itag() e = p.get_protocols(ethernet.ethernet) - ok_(e) - ok_(isinstance(e, list)) - eq_(e[0].ethertype, ether.ETH_TYPE_8021AD) - eq_(e[1].ethertype, ether.ETH_TYPE_8021AD) + self.assertTrue(e) + self.assertTrue(isinstance(e, list)) + self.assertEqual(e[0].ethertype, ether.ETH_TYPE_8021AD) + self.assertEqual(e[1].ethertype, ether.ETH_TYPE_8021AD) sv = p.get_protocols(vlan.svlan) - ok_(sv) - ok_(isinstance(sv, list)) - eq_(sv[0].ethertype, ether.ETH_TYPE_8021Q) - eq_(sv[1].ethertype, ether.ETH_TYPE_8021Q) + self.assertTrue(sv) + self.assertTrue(isinstance(sv, list)) + self.assertEqual(sv[0].ethertype, ether.ETH_TYPE_8021Q) + self.assertEqual(sv[1].ethertype, ether.ETH_TYPE_8021Q) it = p.get_protocol(pbb.itag) - ok_(it) + self.assertTrue(it) v = p.get_protocol(vlan.vlan) - ok_(v) - eq_(v.ethertype, ether.ETH_TYPE_IP) + self.assertTrue(v) + self.assertEqual(v.ethertype, ether.ETH_TYPE_IP) ip = p.get_protocol(ipv4.ipv4) - ok_(ip) + self.assertTrue(ip) - eq_(it.pcp, self.pcp) - eq_(it.dei, self.dei) - eq_(it.uca, self.uca) - eq_(it.sid, self.sid) + self.assertEqual(it.pcp, self.pcp) + self.assertEqual(it.dei, self.dei) + self.assertEqual(it.uca, self.uca) + self.assertEqual(it.sid, self.sid) - @raises(Exception) def test_malformed_itag(self): m_short_buf = self.buf[1:pbb.itag._MIN_LEN] - pbb.itag.parser(m_short_buf) + self.assertRaises(Exception, pbb.itag.parser, m_short_buf) def test_json(self): jsondict = self.it.to_jsondict() it = pbb.itag.from_jsondict(jsondict['itag']) - eq_(str(self.it), str(it)) + self.assertEqual(str(self.it), str(it)) diff --git a/os_ken/tests/unit/packet/test_sctp.py b/os_ken/tests/unit/packet/test_sctp.py index bc3c25a5..0b39ce87 100644 --- a/os_ken/tests/unit/packet/test_sctp.py +++ b/os_ken/tests/unit/packet/test_sctp.py @@ -20,8 +20,6 @@ import six import struct import unittest -from nose.tools import eq_ -from nose.tools import ok_ from os_ken.lib import addrconv from os_ken.lib.packet import packet from os_ken.lib.packet import ethernet @@ -518,11 +516,11 @@ class Test_sctp(unittest.TestCase): pass def test_init(self): - eq_(self.src_port, self.sc.src_port) - eq_(self.dst_port, self.sc.dst_port) - eq_(self.vtag, self.sc.vtag) - eq_(self.csum, self.sc.csum) - eq_(self.chunks, self.sc.chunks) + self.assertEqual(self.src_port, self.sc.src_port) + self.assertEqual(self.dst_port, self.sc.dst_port) + self.assertEqual(self.vtag, self.sc.vtag) + self.assertEqual(self.csum, self.sc.csum) + self.assertEqual(self.chunks, self.sc.chunks) def test_init_with_data(self): self.setUp_with_data() @@ -597,11 +595,11 @@ class Test_sctp(unittest.TestCase): # to calculate the lengths of parameters. self.sc.serialize(None, None) - eq_(self.src_port, res.src_port) - eq_(self.dst_port, res.dst_port) - eq_(self.vtag, res.vtag) - eq_(self.csum, res.csum) - eq_(str(self.chunks), str(res.chunks)) + self.assertEqual(self.src_port, res.src_port) + self.assertEqual(self.dst_port, res.dst_port) + self.assertEqual(self.vtag, res.vtag) + self.assertEqual(self.csum, res.csum) + self.assertEqual(str(self.chunks), str(res.chunks)) def test_parser_with_data(self): self.setUp_with_data() @@ -670,11 +668,11 @@ class Test_sctp(unittest.TestCase): def _test_serialize(self): buf = self.sc.serialize(bytearray(), None) res = struct.unpack_from(sctp.sctp._PACK_STR, buf) - eq_(self.src_port, res[0]) - eq_(self.dst_port, res[1]) - eq_(self.vtag, res[2]) + self.assertEqual(self.src_port, res[0]) + self.assertEqual(self.dst_port, res[1]) + self.assertEqual(self.vtag, res[2]) # skip compare checksum - # eq_(self.csum, res[3]) + # self.assertEqual(self.csum, res[3]) return buf[sctp.sctp._MIN_LEN:] @@ -685,71 +683,71 @@ class Test_sctp(unittest.TestCase): self.setUp_with_data() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_data._PACK_STR, buf) - eq_(sctp.chunk_data.chunk_type(), res[0]) + self.assertEqual(sctp.chunk_data.chunk_type(), res[0]) flags = ( (self.unordered << 2) | (self.begin << 1) | (self.end << 0)) - eq_(flags, res[1]) - eq_(self.length, res[2]) - eq_(self.tsn, res[3]) - eq_(self.sid, res[4]) - eq_(self.seq, res[5]) - eq_(self.payload_id, res[6]) - eq_(self.payload_data, buf[sctp.chunk_data._MIN_LEN:]) + self.assertEqual(flags, res[1]) + self.assertEqual(self.length, res[2]) + self.assertEqual(self.tsn, res[3]) + self.assertEqual(self.sid, res[4]) + self.assertEqual(self.seq, res[5]) + self.assertEqual(self.payload_id, res[6]) + self.assertEqual(self.payload_data, buf[sctp.chunk_data._MIN_LEN:]) def test_serialize_with_init(self): self.setUp_with_init() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_init._PACK_STR, buf) - eq_(sctp.chunk_init.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) - eq_(self.init_tag, res[3]) - eq_(self.a_rwnd, res[4]) - eq_(self.os, res[5]) - eq_(self.mis, res[6]) - eq_(self.i_tsn, res[7]) + self.assertEqual(sctp.chunk_init.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) + self.assertEqual(self.init_tag, res[3]) + self.assertEqual(self.a_rwnd, res[4]) + self.assertEqual(self.os, res[5]) + self.assertEqual(self.mis, res[6]) + self.assertEqual(self.i_tsn, res[7]) buf = buf[sctp.chunk_init._MIN_LEN:] res1 = struct.unpack_from(sctp.param_ipv4._PACK_STR, buf) - eq_(sctp.param_ipv4.param_type(), res1[0]) - eq_(8, res1[1]) - eq_('192.168.1.1', addrconv.ipv4.bin_to_text( + self.assertEqual(sctp.param_ipv4.param_type(), res1[0]) + self.assertEqual(8, res1[1]) + self.assertEqual('192.168.1.1', addrconv.ipv4.bin_to_text( buf[sctp.param_ipv4._MIN_LEN:sctp.param_ipv4._MIN_LEN + 4])) buf = buf[8:] res2 = struct.unpack_from(sctp.param_ipv6._PACK_STR, buf) - eq_(sctp.param_ipv6.param_type(), res2[0]) - eq_(20, res2[1]) - eq_('fe80::647e:1aff:fec4:8284', addrconv.ipv6.bin_to_text( + self.assertEqual(sctp.param_ipv6.param_type(), res2[0]) + self.assertEqual(20, res2[1]) + self.assertEqual('fe80::647e:1aff:fec4:8284', addrconv.ipv6.bin_to_text( buf[sctp.param_ipv6._MIN_LEN:sctp.param_ipv6._MIN_LEN + 16])) buf = buf[20:] res3 = struct.unpack_from(sctp.param_cookie_preserve._PACK_STR, buf) - eq_(sctp.param_cookie_preserve.param_type(), res3[0]) - eq_(8, res3[1]) - eq_(5000, res3[2]) + self.assertEqual(sctp.param_cookie_preserve.param_type(), res3[0]) + self.assertEqual(8, res3[1]) + self.assertEqual(5000, res3[2]) buf = buf[8:] res4 = struct.unpack_from(sctp.param_ecn._PACK_STR, buf) - eq_(sctp.param_ecn.param_type(), res4[0]) - eq_(4, res4[1]) + self.assertEqual(sctp.param_ecn.param_type(), res4[0]) + self.assertEqual(4, res4[1]) buf = buf[4:] res5 = struct.unpack_from(sctp.param_host_addr._PACK_STR, buf) - eq_(sctp.param_host_addr.param_type(), res5[0]) - eq_(14, res5[1]) - eq_(b'test host\x00', + self.assertEqual(sctp.param_host_addr.param_type(), res5[0]) + self.assertEqual(14, res5[1]) + self.assertEqual(b'test host\x00', buf[sctp.param_host_addr._MIN_LEN: sctp.param_host_addr._MIN_LEN + 10]) buf = buf[16:] res6 = struct.unpack_from(sctp.param_supported_addr._PACK_STR, buf) res6 = list(res6) - eq_(sctp.param_supported_addr.param_type(), res6[0]) - eq_(14, res6[1]) + self.assertEqual(sctp.param_supported_addr.param_type(), res6[0]) + self.assertEqual(14, res6[1]) buf = buf[sctp.param_supported_addr._MIN_LEN:] offset = 0 tmplist = [] @@ -758,66 +756,66 @@ class Test_sctp(unittest.TestCase): tmplist.append(tmp) offset += struct.calcsize('!H') res6.extend(tmplist) - eq_(sctp.PTYPE_IPV4, res6[2]) - eq_(sctp.PTYPE_IPV6, res6[3]) - eq_(sctp.PTYPE_COOKIE_PRESERVE, res6[4]) - eq_(sctp.PTYPE_ECN, res6[5]) - eq_(sctp.PTYPE_HOST_ADDR, res6[6]) + self.assertEqual(sctp.PTYPE_IPV4, res6[2]) + self.assertEqual(sctp.PTYPE_IPV6, res6[3]) + self.assertEqual(sctp.PTYPE_COOKIE_PRESERVE, res6[4]) + self.assertEqual(sctp.PTYPE_ECN, res6[5]) + self.assertEqual(sctp.PTYPE_HOST_ADDR, res6[6]) def test_serialize_with_init_ack(self): self.setUp_with_init_ack() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_init_ack._PACK_STR, buf) - eq_(sctp.chunk_init_ack.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) - eq_(self.init_tag, res[3]) - eq_(self.a_rwnd, res[4]) - eq_(self.os, res[5]) - eq_(self.mis, res[6]) - eq_(self.i_tsn, res[7]) + self.assertEqual(sctp.chunk_init_ack.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) + self.assertEqual(self.init_tag, res[3]) + self.assertEqual(self.a_rwnd, res[4]) + self.assertEqual(self.os, res[5]) + self.assertEqual(self.mis, res[6]) + self.assertEqual(self.i_tsn, res[7]) buf = buf[sctp.chunk_init_ack._MIN_LEN:] res1 = struct.unpack_from(sctp.param_state_cookie._PACK_STR, buf) - eq_(sctp.param_state_cookie.param_type(), res1[0]) - eq_(7, res1[1]) - eq_(b'\x01\x02\x03', + self.assertEqual(sctp.param_state_cookie.param_type(), res1[0]) + self.assertEqual(7, res1[1]) + self.assertEqual(b'\x01\x02\x03', buf[sctp.param_state_cookie._MIN_LEN: sctp.param_state_cookie._MIN_LEN + 3]) buf = buf[8:] res2 = struct.unpack_from(sctp.param_ipv4._PACK_STR, buf) - eq_(sctp.param_ipv4.param_type(), res2[0]) - eq_(8, res2[1]) - eq_('192.168.1.1', addrconv.ipv4.bin_to_text( + self.assertEqual(sctp.param_ipv4.param_type(), res2[0]) + self.assertEqual(8, res2[1]) + self.assertEqual('192.168.1.1', addrconv.ipv4.bin_to_text( buf[sctp.param_ipv4._MIN_LEN:sctp.param_ipv4._MIN_LEN + 4])) buf = buf[8:] res3 = struct.unpack_from(sctp.param_ipv6._PACK_STR, buf) - eq_(sctp.param_ipv6.param_type(), res3[0]) - eq_(20, res3[1]) - eq_('fe80::647e:1aff:fec4:8284', addrconv.ipv6.bin_to_text( + self.assertEqual(sctp.param_ipv6.param_type(), res3[0]) + self.assertEqual(20, res3[1]) + self.assertEqual('fe80::647e:1aff:fec4:8284', addrconv.ipv6.bin_to_text( buf[sctp.param_ipv6._MIN_LEN:sctp.param_ipv6._MIN_LEN + 16])) buf = buf[20:] res4 = struct.unpack_from( sctp.param_unrecognized_param._PACK_STR, buf) - eq_(sctp.param_unrecognized_param.param_type(), res4[0]) - eq_(8, res4[1]) - eq_(b'\xff\xff\x00\x04', + self.assertEqual(sctp.param_unrecognized_param.param_type(), res4[0]) + self.assertEqual(8, res4[1]) + self.assertEqual(b'\xff\xff\x00\x04', buf[sctp.param_unrecognized_param._MIN_LEN: sctp.param_unrecognized_param._MIN_LEN + 4]) buf = buf[8:] res5 = struct.unpack_from(sctp.param_ecn._PACK_STR, buf) - eq_(sctp.param_ecn.param_type(), res5[0]) - eq_(4, res5[1]) + self.assertEqual(sctp.param_ecn.param_type(), res5[0]) + self.assertEqual(4, res5[1]) buf = buf[4:] res6 = struct.unpack_from(sctp.param_host_addr._PACK_STR, buf) - eq_(sctp.param_host_addr.param_type(), res6[0]) - eq_(14, res6[1]) - eq_(b'test host\x00', + self.assertEqual(sctp.param_host_addr.param_type(), res6[0]) + self.assertEqual(14, res6[1]) + self.assertEqual(b'test host\x00', buf[sctp.param_host_addr._MIN_LEN: sctp.param_host_addr._MIN_LEN + 10]) @@ -825,13 +823,13 @@ class Test_sctp(unittest.TestCase): self.setUp_with_sack() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_sack._PACK_STR, buf) - eq_(sctp.chunk_sack.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) - eq_(self.tsn_ack, res[3]) - eq_(self.a_rwnd, res[4]) - eq_(self.gapack_num, res[5]) - eq_(self.duptsn_num, res[6]) + self.assertEqual(sctp.chunk_sack.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) + self.assertEqual(self.tsn_ack, res[3]) + self.assertEqual(self.a_rwnd, res[4]) + self.assertEqual(self.gapack_num, res[5]) + self.assertEqual(self.duptsn_num, res[6]) buf = buf[sctp.chunk_sack._MIN_LEN:] gapacks = [] @@ -847,22 +845,22 @@ class Test_sctp(unittest.TestCase): sctp.chunk_sack._DUPTSN_STR, buf) duptsns.append(duptsn) buf = buf[sctp.chunk_sack._DUPTSN_LEN:] - eq_(self.gapacks, gapacks) - eq_(self.duptsns, duptsns) + self.assertEqual(self.gapacks, gapacks) + self.assertEqual(self.duptsns, duptsns) def test_serialize_with_heartbeat(self): self.setUp_with_heartbeat() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_heartbeat._PACK_STR, buf) - eq_(sctp.chunk_heartbeat.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) + self.assertEqual(sctp.chunk_heartbeat.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) buf = buf[sctp.chunk_heartbeat._MIN_LEN:] res1 = struct.unpack_from(sctp.param_heartbeat._PACK_STR, buf) - eq_(sctp.param_heartbeat.param_type(), res1[0]) - eq_(8, res1[1]) - eq_(b'\x01\x02\x03\x04', + self.assertEqual(sctp.param_heartbeat.param_type(), res1[0]) + self.assertEqual(8, res1[1]) + self.assertEqual(b'\x01\x02\x03\x04', buf[sctp.param_heartbeat._MIN_LEN: sctp.param_heartbeat._MIN_LEN + 4]) @@ -870,15 +868,15 @@ class Test_sctp(unittest.TestCase): self.setUp_with_heartbeat_ack() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_heartbeat_ack._PACK_STR, buf) - eq_(sctp.chunk_heartbeat_ack.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) + self.assertEqual(sctp.chunk_heartbeat_ack.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) buf = buf[sctp.chunk_heartbeat_ack._MIN_LEN:] res1 = struct.unpack_from(sctp.param_heartbeat._PACK_STR, buf) - eq_(sctp.param_heartbeat.param_type(), res1[0]) - eq_(12, res1[1]) - eq_(b'\xff\xee\xdd\xcc\xbb\xaa\x99\x88', + self.assertEqual(sctp.param_heartbeat.param_type(), res1[0]) + self.assertEqual(12, res1[1]) + self.assertEqual(b'\xff\xee\xdd\xcc\xbb\xaa\x99\x88', buf[sctp.param_heartbeat._MIN_LEN: sctp.param_heartbeat._MIN_LEN + 8]) @@ -886,50 +884,50 @@ class Test_sctp(unittest.TestCase): self.setUp_with_abort() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_abort._PACK_STR, buf) - eq_(sctp.chunk_abort.chunk_type(), res[0]) + self.assertEqual(sctp.chunk_abort.chunk_type(), res[0]) flags = self.tflag << 0 - eq_(flags, res[1]) - eq_(self.length, res[2]) + self.assertEqual(flags, res[1]) + self.assertEqual(self.length, res[2]) buf = buf[sctp.chunk_abort._MIN_LEN:] res1 = struct.unpack_from(sctp.cause_invalid_stream_id._PACK_STR, buf) - eq_(sctp.cause_invalid_stream_id.cause_code(), res1[0]) - eq_(8, res1[1]) - eq_(4096, res1[2]) + self.assertEqual(sctp.cause_invalid_stream_id.cause_code(), res1[0]) + self.assertEqual(8, res1[1]) + self.assertEqual(4096, res1[2]) buf = buf[8:] res2 = struct.unpack_from(sctp.cause_missing_param._PACK_STR, buf) - eq_(sctp.cause_missing_param.cause_code(), res2[0]) - eq_(16, res2[1]) - eq_(4, res2[2]) + self.assertEqual(sctp.cause_missing_param.cause_code(), res2[0]) + self.assertEqual(16, res2[1]) + self.assertEqual(4, res2[2]) types = [] for count in range(4): (tmp, ) = struct.unpack_from( '!H', buf, sctp.cause_missing_param._MIN_LEN + 2 * count) types.append(tmp) - eq_(str([sctp.PTYPE_IPV4, sctp.PTYPE_IPV6, + self.assertEqual(str([sctp.PTYPE_IPV4, sctp.PTYPE_IPV6, sctp.PTYPE_COOKIE_PRESERVE, sctp.PTYPE_HOST_ADDR]), str(types)) buf = buf[16:] res3 = struct.unpack_from(sctp.cause_stale_cookie._PACK_STR, buf) - eq_(sctp.cause_stale_cookie.cause_code(), res3[0]) - eq_(8, res3[1]) - eq_(b'\x00\x00\x13\x88', + self.assertEqual(sctp.cause_stale_cookie.cause_code(), res3[0]) + self.assertEqual(8, res3[1]) + self.assertEqual(b'\x00\x00\x13\x88', buf[sctp.cause_stale_cookie._MIN_LEN: sctp.cause_stale_cookie._MIN_LEN + 4]) buf = buf[8:] res4 = struct.unpack_from(sctp.cause_out_of_resource._PACK_STR, buf) - eq_(sctp.cause_out_of_resource.cause_code(), res4[0]) - eq_(4, res4[1]) + self.assertEqual(sctp.cause_out_of_resource.cause_code(), res4[0]) + self.assertEqual(4, res4[1]) buf = buf[4:] res5 = struct.unpack_from( sctp.cause_unresolvable_addr._PACK_STR, buf) - eq_(sctp.cause_unresolvable_addr.cause_code(), res5[0]) - eq_(20, res5[1]) - eq_(b'\x00\x0b\x00\x0e\x74\x65\x73\x74' + + self.assertEqual(sctp.cause_unresolvable_addr.cause_code(), res5[0]) + self.assertEqual(20, res5[1]) + self.assertEqual(b'\x00\x0b\x00\x0e\x74\x65\x73\x74' + b'\x20\x68\x6f\x73\x74\x00\x00\x00', buf[sctp.cause_unresolvable_addr._MIN_LEN: sctp.cause_unresolvable_addr._MIN_LEN + 16]) @@ -937,64 +935,64 @@ class Test_sctp(unittest.TestCase): buf = buf[20:] res6 = struct.unpack_from( sctp.cause_unrecognized_chunk._PACK_STR, buf) - eq_(sctp.cause_unrecognized_chunk.cause_code(), res6[0]) - eq_(8, res6[1]) - eq_(b'\xff\x00\x00\x04', + self.assertEqual(sctp.cause_unrecognized_chunk.cause_code(), res6[0]) + self.assertEqual(8, res6[1]) + self.assertEqual(b'\xff\x00\x00\x04', buf[sctp.cause_unrecognized_chunk._MIN_LEN: sctp.cause_unrecognized_chunk._MIN_LEN + 4]) buf = buf[8:] res7 = struct.unpack_from(sctp.cause_invalid_param._PACK_STR, buf) - eq_(sctp.cause_invalid_param.cause_code(), res7[0]) - eq_(4, res7[1]) + self.assertEqual(sctp.cause_invalid_param.cause_code(), res7[0]) + self.assertEqual(4, res7[1]) buf = buf[4:] res8 = struct.unpack_from( sctp.cause_unrecognized_param._PACK_STR, buf) - eq_(sctp.cause_unrecognized_param.cause_code(), res8[0]) - eq_(8, res8[1]) - eq_(b'\xff\xff\x00\x04', + self.assertEqual(sctp.cause_unrecognized_param.cause_code(), res8[0]) + self.assertEqual(8, res8[1]) + self.assertEqual(b'\xff\xff\x00\x04', buf[sctp.cause_unrecognized_param._MIN_LEN: sctp.cause_unrecognized_param._MIN_LEN + 4]) buf = buf[8:] res9 = struct.unpack_from(sctp.cause_no_userdata._PACK_STR, buf) - eq_(sctp.cause_no_userdata.cause_code(), res9[0]) - eq_(8, res9[1]) - eq_(b'\x00\x01\xe2\x40', + self.assertEqual(sctp.cause_no_userdata.cause_code(), res9[0]) + self.assertEqual(8, res9[1]) + self.assertEqual(b'\x00\x01\xe2\x40', buf[sctp.cause_no_userdata._MIN_LEN: sctp.cause_no_userdata._MIN_LEN + 4]) buf = buf[8:] res10 = struct.unpack_from( sctp.cause_cookie_while_shutdown._PACK_STR, buf) - eq_(sctp.cause_cookie_while_shutdown.cause_code(), res10[0]) - eq_(4, res10[1]) + self.assertEqual(sctp.cause_cookie_while_shutdown.cause_code(), res10[0]) + self.assertEqual(4, res10[1]) buf = buf[4:] res11 = struct.unpack_from( sctp.cause_restart_with_new_addr._PACK_STR, buf) - eq_(sctp.cause_restart_with_new_addr.cause_code(), res11[0]) - eq_(12, res11[1]) - eq_(b'\x00\x05\x00\x08\xc0\xa8\x01\x01', + self.assertEqual(sctp.cause_restart_with_new_addr.cause_code(), res11[0]) + self.assertEqual(12, res11[1]) + self.assertEqual(b'\x00\x05\x00\x08\xc0\xa8\x01\x01', buf[sctp.cause_restart_with_new_addr._MIN_LEN: sctp.cause_restart_with_new_addr._MIN_LEN + 8]) buf = buf[12:] res12 = struct.unpack_from( sctp.cause_user_initiated_abort._PACK_STR, buf) - eq_(sctp.cause_user_initiated_abort.cause_code(), res12[0]) - eq_(19, res12[1]) - eq_(b'Key Interrupt.\x00', + self.assertEqual(sctp.cause_user_initiated_abort.cause_code(), res12[0]) + self.assertEqual(19, res12[1]) + self.assertEqual(b'Key Interrupt.\x00', buf[sctp.cause_user_initiated_abort._MIN_LEN: sctp.cause_user_initiated_abort._MIN_LEN + 15]) buf = buf[20:] res13 = struct.unpack_from( sctp.cause_protocol_violation._PACK_STR, buf) - eq_(sctp.cause_protocol_violation.cause_code(), res13[0]) - eq_(20, res13[1]) - eq_(b'Unknown reason.\x00', + self.assertEqual(sctp.cause_protocol_violation.cause_code(), res13[0]) + self.assertEqual(20, res13[1]) + self.assertEqual(b'Unknown reason.\x00', buf[sctp.cause_protocol_violation._MIN_LEN: sctp.cause_protocol_violation._MIN_LEN + 16]) @@ -1002,66 +1000,66 @@ class Test_sctp(unittest.TestCase): self.setUp_with_shutdown() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_shutdown._PACK_STR, buf) - eq_(sctp.chunk_shutdown.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) - eq_(self.tsn_ack, res[3]) + self.assertEqual(sctp.chunk_shutdown.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) + self.assertEqual(self.tsn_ack, res[3]) def test_serialize_with_shutdown_ack(self): self.setUp_with_shutdown_ack() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_shutdown_ack._PACK_STR, buf) - eq_(sctp.chunk_shutdown_ack.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) + self.assertEqual(sctp.chunk_shutdown_ack.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) def test_serialize_with_error(self): self.setUp_with_error() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_error._PACK_STR, buf) - eq_(sctp.chunk_error.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) + self.assertEqual(sctp.chunk_error.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) buf = buf[sctp.chunk_error._MIN_LEN:] res1 = struct.unpack_from(sctp.cause_invalid_stream_id._PACK_STR, buf) - eq_(sctp.cause_invalid_stream_id.cause_code(), res1[0]) - eq_(8, res1[1]) - eq_(4096, res1[2]) + self.assertEqual(sctp.cause_invalid_stream_id.cause_code(), res1[0]) + self.assertEqual(8, res1[1]) + self.assertEqual(4096, res1[2]) buf = buf[8:] res2 = struct.unpack_from(sctp.cause_missing_param._PACK_STR, buf) - eq_(sctp.cause_missing_param.cause_code(), res2[0]) - eq_(16, res2[1]) - eq_(4, res2[2]) + self.assertEqual(sctp.cause_missing_param.cause_code(), res2[0]) + self.assertEqual(16, res2[1]) + self.assertEqual(4, res2[2]) types = [] for count in range(4): (tmp, ) = struct.unpack_from( '!H', buf, sctp.cause_missing_param._MIN_LEN + 2 * count) types.append(tmp) - eq_(str([sctp.PTYPE_IPV4, sctp.PTYPE_IPV6, + self.assertEqual(str([sctp.PTYPE_IPV4, sctp.PTYPE_IPV6, sctp.PTYPE_COOKIE_PRESERVE, sctp.PTYPE_HOST_ADDR]), str(types)) buf = buf[16:] res3 = struct.unpack_from(sctp.cause_stale_cookie._PACK_STR, buf) - eq_(sctp.cause_stale_cookie.cause_code(), res3[0]) - eq_(8, res3[1]) - eq_(b'\x00\x00\x13\x88', + self.assertEqual(sctp.cause_stale_cookie.cause_code(), res3[0]) + self.assertEqual(8, res3[1]) + self.assertEqual(b'\x00\x00\x13\x88', buf[sctp.cause_stale_cookie._MIN_LEN: sctp.cause_stale_cookie._MIN_LEN + 4]) buf = buf[8:] res4 = struct.unpack_from(sctp.cause_out_of_resource._PACK_STR, buf) - eq_(sctp.cause_out_of_resource.cause_code(), res4[0]) - eq_(4, res4[1]) + self.assertEqual(sctp.cause_out_of_resource.cause_code(), res4[0]) + self.assertEqual(4, res4[1]) buf = buf[4:] res5 = struct.unpack_from( sctp.cause_unresolvable_addr._PACK_STR, buf) - eq_(sctp.cause_unresolvable_addr.cause_code(), res5[0]) - eq_(20, res5[1]) - eq_(b'\x00\x0b\x00\x0e\x74\x65\x73\x74' + + self.assertEqual(sctp.cause_unresolvable_addr.cause_code(), res5[0]) + self.assertEqual(20, res5[1]) + self.assertEqual(b'\x00\x0b\x00\x0e\x74\x65\x73\x74' + b'\x20\x68\x6f\x73\x74\x00\x00\x00', buf[sctp.cause_unresolvable_addr._MIN_LEN: sctp.cause_unresolvable_addr._MIN_LEN + 16]) @@ -1069,64 +1067,64 @@ class Test_sctp(unittest.TestCase): buf = buf[20:] res6 = struct.unpack_from( sctp.cause_unrecognized_chunk._PACK_STR, buf) - eq_(sctp.cause_unrecognized_chunk.cause_code(), res6[0]) - eq_(8, res6[1]) - eq_(b'\xff\x00\x00\x04', + self.assertEqual(sctp.cause_unrecognized_chunk.cause_code(), res6[0]) + self.assertEqual(8, res6[1]) + self.assertEqual(b'\xff\x00\x00\x04', buf[sctp.cause_unrecognized_chunk._MIN_LEN: sctp.cause_unrecognized_chunk._MIN_LEN + 4]) buf = buf[8:] res7 = struct.unpack_from(sctp.cause_invalid_param._PACK_STR, buf) - eq_(sctp.cause_invalid_param.cause_code(), res7[0]) - eq_(4, res7[1]) + self.assertEqual(sctp.cause_invalid_param.cause_code(), res7[0]) + self.assertEqual(4, res7[1]) buf = buf[4:] res8 = struct.unpack_from( sctp.cause_unrecognized_param._PACK_STR, buf) - eq_(sctp.cause_unrecognized_param.cause_code(), res8[0]) - eq_(8, res8[1]) - eq_(b'\xff\xff\x00\x04', + self.assertEqual(sctp.cause_unrecognized_param.cause_code(), res8[0]) + self.assertEqual(8, res8[1]) + self.assertEqual(b'\xff\xff\x00\x04', buf[sctp.cause_unrecognized_param._MIN_LEN: sctp.cause_unrecognized_param._MIN_LEN + 4]) buf = buf[8:] res9 = struct.unpack_from(sctp.cause_no_userdata._PACK_STR, buf) - eq_(sctp.cause_no_userdata.cause_code(), res9[0]) - eq_(8, res9[1]) - eq_(b'\x00\x01\xe2\x40', + self.assertEqual(sctp.cause_no_userdata.cause_code(), res9[0]) + self.assertEqual(8, res9[1]) + self.assertEqual(b'\x00\x01\xe2\x40', buf[sctp.cause_no_userdata._MIN_LEN: sctp.cause_no_userdata._MIN_LEN + 4]) buf = buf[8:] res10 = struct.unpack_from( sctp.cause_cookie_while_shutdown._PACK_STR, buf) - eq_(sctp.cause_cookie_while_shutdown.cause_code(), res10[0]) - eq_(4, res10[1]) + self.assertEqual(sctp.cause_cookie_while_shutdown.cause_code(), res10[0]) + self.assertEqual(4, res10[1]) buf = buf[4:] res11 = struct.unpack_from( sctp.cause_restart_with_new_addr._PACK_STR, buf) - eq_(sctp.cause_restart_with_new_addr.cause_code(), res11[0]) - eq_(12, res11[1]) - eq_(b'\x00\x05\x00\x08\xc0\xa8\x01\x01', + self.assertEqual(sctp.cause_restart_with_new_addr.cause_code(), res11[0]) + self.assertEqual(12, res11[1]) + self.assertEqual(b'\x00\x05\x00\x08\xc0\xa8\x01\x01', buf[sctp.cause_restart_with_new_addr._MIN_LEN: sctp.cause_restart_with_new_addr._MIN_LEN + 8]) buf = buf[12:] res12 = struct.unpack_from( sctp.cause_user_initiated_abort._PACK_STR, buf) - eq_(sctp.cause_user_initiated_abort.cause_code(), res12[0]) - eq_(19, res12[1]) - eq_(b'Key Interrupt.\x00', + self.assertEqual(sctp.cause_user_initiated_abort.cause_code(), res12[0]) + self.assertEqual(19, res12[1]) + self.assertEqual(b'Key Interrupt.\x00', buf[sctp.cause_user_initiated_abort._MIN_LEN: sctp.cause_user_initiated_abort._MIN_LEN + 15]) buf = buf[20:] res13 = struct.unpack_from( sctp.cause_protocol_violation._PACK_STR, buf) - eq_(sctp.cause_protocol_violation.cause_code(), res13[0]) - eq_(20, res13[1]) - eq_(b'Unknown reason.\x00', + self.assertEqual(sctp.cause_protocol_violation.cause_code(), res13[0]) + self.assertEqual(20, res13[1]) + self.assertEqual(b'Unknown reason.\x00', buf[sctp.cause_protocol_violation._MIN_LEN: sctp.cause_protocol_violation._MIN_LEN + 16]) @@ -1134,10 +1132,10 @@ class Test_sctp(unittest.TestCase): self.setUp_with_cookie_echo() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_cookie_echo._PACK_STR, buf) - eq_(sctp.chunk_cookie_echo.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) - eq_(self.cookie, + self.assertEqual(sctp.chunk_cookie_echo.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) + self.assertEqual(self.cookie, buf[sctp.chunk_cookie_echo._MIN_LEN: sctp.chunk_cookie_echo._MIN_LEN + 4]) @@ -1145,81 +1143,81 @@ class Test_sctp(unittest.TestCase): self.setUp_with_cookie_ack() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_cookie_ack._PACK_STR, buf) - eq_(sctp.chunk_cookie_ack.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) + self.assertEqual(sctp.chunk_cookie_ack.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) def test_serialize_with_ecn_echo(self): self.setUp_with_ecn_echo() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_ecn_echo._PACK_STR, buf) - eq_(sctp.chunk_ecn_echo.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) - eq_(self.low_tsn, res[3]) + self.assertEqual(sctp.chunk_ecn_echo.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) + self.assertEqual(self.low_tsn, res[3]) def test_serialize_with_cwr(self): self.setUp_with_cwr() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_cwr._PACK_STR, buf) - eq_(sctp.chunk_cwr.chunk_type(), res[0]) - eq_(self.flags, res[1]) - eq_(self.length, res[2]) - eq_(self.low_tsn, res[3]) + self.assertEqual(sctp.chunk_cwr.chunk_type(), res[0]) + self.assertEqual(self.flags, res[1]) + self.assertEqual(self.length, res[2]) + self.assertEqual(self.low_tsn, res[3]) def test_serialize_with_shutdown_complete(self): self.setUp_with_shutdown_complete() buf = self._test_serialize() res = struct.unpack_from( sctp.chunk_shutdown_complete._PACK_STR, buf) - eq_(sctp.chunk_shutdown_complete.chunk_type(), res[0]) + self.assertEqual(sctp.chunk_shutdown_complete.chunk_type(), res[0]) flags = self.tflag << 0 - eq_(flags, res[1]) - eq_(self.length, res[2]) + self.assertEqual(flags, res[1]) + self.assertEqual(self.length, res[2]) def test_serialize_with_multi_chunks(self): self.setUp_with_multi_chunks() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_sack._PACK_STR, buf) - eq_(sctp.chunk_sack.chunk_type(), res[0]) - eq_(self.s_flags, res[1]) - eq_(self.s_length, res[2]) - eq_(self.s_tsn_ack, res[3]) - eq_(self.s_a_rwnd, res[4]) - eq_(self.s_gapack_num, res[5]) - eq_(self.s_duptsn_num, res[6]) + self.assertEqual(sctp.chunk_sack.chunk_type(), res[0]) + self.assertEqual(self.s_flags, res[1]) + self.assertEqual(self.s_length, res[2]) + self.assertEqual(self.s_tsn_ack, res[3]) + self.assertEqual(self.s_a_rwnd, res[4]) + self.assertEqual(self.s_gapack_num, res[5]) + self.assertEqual(self.s_duptsn_num, res[6]) buf = buf[self.s_length:] res = struct.unpack_from(sctp.chunk_data._PACK_STR, buf) - eq_(sctp.chunk_data.chunk_type(), res[0]) + self.assertEqual(sctp.chunk_data.chunk_type(), res[0]) d1_flags = ( (self.d1_unordered << 2) | (self.d1_begin << 1) | (self.d1_end << 0)) - eq_(d1_flags, res[1]) - eq_(self.d1_length, res[2]) - eq_(self.d1_tsn, res[3]) - eq_(self.d1_sid, res[4]) - eq_(self.d1_seq, res[5]) - eq_(self.d1_payload_id, res[6]) - eq_(self.d1_payload_data, + self.assertEqual(d1_flags, res[1]) + self.assertEqual(self.d1_length, res[2]) + self.assertEqual(self.d1_tsn, res[3]) + self.assertEqual(self.d1_sid, res[4]) + self.assertEqual(self.d1_seq, res[5]) + self.assertEqual(self.d1_payload_id, res[6]) + self.assertEqual(self.d1_payload_data, buf[sctp.chunk_data._MIN_LEN: sctp.chunk_data._MIN_LEN + 10]) buf = buf[self.d1_length:] res = struct.unpack_from(sctp.chunk_data._PACK_STR, buf) - eq_(sctp.chunk_data.chunk_type(), res[0]) + self.assertEqual(sctp.chunk_data.chunk_type(), res[0]) d2_flags = ( (self.d2_unordered << 2) | (self.d2_begin << 1) | (self.d2_end << 0)) - eq_(d2_flags, res[1]) - eq_(self.d2_length, res[2]) - eq_(self.d2_tsn, res[3]) - eq_(self.d2_sid, res[4]) - eq_(self.d2_seq, res[5]) - eq_(self.d2_payload_id, res[6]) - eq_(self.d2_payload_data, + self.assertEqual(d2_flags, res[1]) + self.assertEqual(self.d2_length, res[2]) + self.assertEqual(self.d2_tsn, res[3]) + self.assertEqual(self.d2_sid, res[4]) + self.assertEqual(self.d2_seq, res[5]) + self.assertEqual(self.d2_payload_id, res[6]) + self.assertEqual(self.d2_payload_data, buf[sctp.chunk_data._MIN_LEN: sctp.chunk_data._MIN_LEN + 10]) @@ -1231,16 +1229,16 @@ class Test_sctp(unittest.TestCase): pkt = eth / ip4 / self.sc eth = pkt.get_protocol(ethernet.ethernet) - ok_(eth) - eq_(eth.ethertype, ether.ETH_TYPE_IP) + self.assertTrue(eth) + self.assertEqual(eth.ethertype, ether.ETH_TYPE_IP) ip4 = pkt.get_protocol(ipv4.ipv4) - ok_(ip4) - eq_(ip4.proto, inet.IPPROTO_SCTP) + self.assertTrue(ip4) + self.assertEqual(ip4.proto, inet.IPPROTO_SCTP) sc = pkt.get_protocol(sctp.sctp) - ok_(sc) - eq_(sc, self.sc) + self.assertTrue(sc) + self.assertEqual(sc, self.sc) def test_build_sctp_with_data(self): self.setUp_with_data() @@ -1317,8 +1315,8 @@ class Test_sctp(unittest.TestCase): if k in sctp_values]) sctp_str = '%s(%s)' % (sctp.sctp.__name__, _sctp_str) - eq_(str(self.sc), sctp_str) - eq_(repr(self.sc), sctp_str) + self.assertEqual(str(self.sc), sctp_str) + self.assertEqual(repr(self.sc), sctp_str) def test_to_string_with_data(self): self.setUp_with_data() @@ -1387,7 +1385,7 @@ class Test_sctp(unittest.TestCase): def test_json(self): jsondict = self.sc.to_jsondict() sc = sctp.sctp.from_jsondict(jsondict['sctp']) - eq_(str(self.sc), str(sc)) + self.assertEqual(str(self.sc), str(sc)) def test_json_with_data(self): self.setUp_with_data() diff --git a/os_ken/tests/unit/packet/test_slow.py b/os_ken/tests/unit/packet/test_slow.py index fc10b192..fd4a8b17 100644 --- a/os_ken/tests/unit/packet/test_slow.py +++ b/os_ken/tests/unit/packet/test_slow.py @@ -20,7 +20,6 @@ import logging from struct import pack, unpack_from import unittest -from nose.tools import ok_, eq_, raises from os_ken.ofproto import ether from os_ken.lib.packet.ethernet import ethernet from os_ken.lib.packet.packet import Packet @@ -303,55 +302,55 @@ class Test_lacp(unittest.TestCase): return p def test_init(self): - eq_(self.subtype, self.l._subtype) - eq_(self.version, self.l.version) - eq_(self.actor_tag, self.l._actor_tag) - eq_(self.actor_length, self.l._actor_length) - eq_(self.actor_system_priority, self.l.actor_system_priority) - eq_(self.actor_system, self.l.actor_system) - eq_(self.actor_key, self.l.actor_key) - eq_(self.actor_port_priority, self.l.actor_port_priority) - eq_(self.actor_port, self.l.actor_port) - eq_(self.actor_state_activity, self.l.actor_state_activity) - eq_(self.actor_state_timeout, self.l.actor_state_timeout) - eq_(self.actor_state_aggregation, + self.assertEqual(self.subtype, self.l._subtype) + self.assertEqual(self.version, self.l.version) + self.assertEqual(self.actor_tag, self.l._actor_tag) + self.assertEqual(self.actor_length, self.l._actor_length) + self.assertEqual(self.actor_system_priority, self.l.actor_system_priority) + self.assertEqual(self.actor_system, self.l.actor_system) + self.assertEqual(self.actor_key, self.l.actor_key) + self.assertEqual(self.actor_port_priority, self.l.actor_port_priority) + self.assertEqual(self.actor_port, self.l.actor_port) + self.assertEqual(self.actor_state_activity, self.l.actor_state_activity) + self.assertEqual(self.actor_state_timeout, self.l.actor_state_timeout) + self.assertEqual(self.actor_state_aggregation, self.l.actor_state_aggregation) - eq_(self.actor_state_synchronization, + self.assertEqual(self.actor_state_synchronization, self.l.actor_state_synchronization) - eq_(self.actor_state_collecting, + self.assertEqual(self.actor_state_collecting, self.l.actor_state_collecting) - eq_(self.actor_state_distributing, + self.assertEqual(self.actor_state_distributing, self.l.actor_state_distributing) - eq_(self.actor_state_defaulted, self.l.actor_state_defaulted) - eq_(self.actor_state_expired, self.l.actor_state_expired) - eq_(self.actor_state, self.l._actor_state) - eq_(self.partner_tag, self.l._partner_tag) - eq_(self.partner_length, self.l._partner_length) - eq_(self.partner_system_priority, + self.assertEqual(self.actor_state_defaulted, self.l.actor_state_defaulted) + self.assertEqual(self.actor_state_expired, self.l.actor_state_expired) + self.assertEqual(self.actor_state, self.l._actor_state) + self.assertEqual(self.partner_tag, self.l._partner_tag) + self.assertEqual(self.partner_length, self.l._partner_length) + self.assertEqual(self.partner_system_priority, self.l.partner_system_priority) - eq_(self.partner_system, self.l.partner_system) - eq_(self.partner_key, self.l.partner_key) - eq_(self.partner_port_priority, self.l.partner_port_priority) - eq_(self.partner_port, self.l.partner_port) - eq_(self.partner_state_activity, self.l.partner_state_activity) - eq_(self.partner_state_timeout, self.l.partner_state_timeout) - eq_(self.partner_state_aggregation, + self.assertEqual(self.partner_system, self.l.partner_system) + self.assertEqual(self.partner_key, self.l.partner_key) + self.assertEqual(self.partner_port_priority, self.l.partner_port_priority) + self.assertEqual(self.partner_port, self.l.partner_port) + self.assertEqual(self.partner_state_activity, self.l.partner_state_activity) + self.assertEqual(self.partner_state_timeout, self.l.partner_state_timeout) + self.assertEqual(self.partner_state_aggregation, self.l.partner_state_aggregation) - eq_(self.partner_state_synchronization, + self.assertEqual(self.partner_state_synchronization, self.l.partner_state_synchronization) - eq_(self.partner_state_collecting, + self.assertEqual(self.partner_state_collecting, self.l.partner_state_collecting) - eq_(self.partner_state_distributing, + self.assertEqual(self.partner_state_distributing, self.l.partner_state_distributing) - eq_(self.partner_state_defaulted, + self.assertEqual(self.partner_state_defaulted, self.l.partner_state_defaulted) - eq_(self.partner_state_expired, self.l.partner_state_expired) - eq_(self.partner_state, self.l._partner_state) - eq_(self.collector_tag, self.l._collector_tag) - eq_(self.collector_length, self.l._collector_length) - eq_(self.collector_max_delay, self.l.collector_max_delay) - eq_(self.terminator_tag, self.l._terminator_tag) - eq_(self.terminator_length, self.l._terminator_length) + self.assertEqual(self.partner_state_expired, self.l.partner_state_expired) + self.assertEqual(self.partner_state, self.l._partner_state) + self.assertEqual(self.collector_tag, self.l._collector_tag) + self.assertEqual(self.collector_length, self.l._collector_length) + self.assertEqual(self.collector_max_delay, self.l.collector_max_delay) + self.assertEqual(self.terminator_tag, self.l._terminator_tag) + self.assertEqual(self.terminator_length, self.l._terminator_length) def test_parser(self): _res = self.l.parser(self.buf) @@ -360,49 +359,49 @@ class Test_lacp(unittest.TestCase): else: res = _res - eq_(res._subtype, self.subtype) - eq_(res.version, self.version) - eq_(res._actor_tag, self.actor_tag) - eq_(res._actor_length, self.actor_length) - eq_(res.actor_system_priority, self.actor_system_priority) - eq_(res.actor_system, self.actor_system) - eq_(res.actor_key, self.actor_key) - eq_(res.actor_port_priority, self.actor_port_priority) - eq_(res.actor_port, self.actor_port) - eq_(res.actor_state_activity, self.actor_state_activity) - eq_(res.actor_state_timeout, self.actor_state_timeout) - eq_(res.actor_state_aggregation, self.actor_state_aggregation) - eq_(res.actor_state_synchronization, + self.assertEqual(res._subtype, self.subtype) + self.assertEqual(res.version, self.version) + self.assertEqual(res._actor_tag, self.actor_tag) + self.assertEqual(res._actor_length, self.actor_length) + self.assertEqual(res.actor_system_priority, self.actor_system_priority) + self.assertEqual(res.actor_system, self.actor_system) + self.assertEqual(res.actor_key, self.actor_key) + self.assertEqual(res.actor_port_priority, self.actor_port_priority) + self.assertEqual(res.actor_port, self.actor_port) + self.assertEqual(res.actor_state_activity, self.actor_state_activity) + self.assertEqual(res.actor_state_timeout, self.actor_state_timeout) + self.assertEqual(res.actor_state_aggregation, self.actor_state_aggregation) + self.assertEqual(res.actor_state_synchronization, self.actor_state_synchronization) - eq_(res.actor_state_collecting, self.actor_state_collecting) - eq_(res.actor_state_distributing, self.actor_state_distributing) - eq_(res.actor_state_defaulted, self.actor_state_defaulted) - eq_(res.actor_state_expired, self.actor_state_expired) - eq_(res._actor_state, self.actor_state) - eq_(res._partner_tag, self.partner_tag) - eq_(res._partner_length, self.partner_length) - eq_(res.partner_system_priority, self.partner_system_priority) - eq_(res.partner_system, self.partner_system) - eq_(res.partner_key, self.partner_key) - eq_(res.partner_port_priority, self.partner_port_priority) - eq_(res.partner_port, self.partner_port) - eq_(res.partner_state_activity, self.partner_state_activity) - eq_(res.partner_state_timeout, self.partner_state_timeout) - eq_(res.partner_state_aggregation, + self.assertEqual(res.actor_state_collecting, self.actor_state_collecting) + self.assertEqual(res.actor_state_distributing, self.actor_state_distributing) + self.assertEqual(res.actor_state_defaulted, self.actor_state_defaulted) + self.assertEqual(res.actor_state_expired, self.actor_state_expired) + self.assertEqual(res._actor_state, self.actor_state) + self.assertEqual(res._partner_tag, self.partner_tag) + self.assertEqual(res._partner_length, self.partner_length) + self.assertEqual(res.partner_system_priority, self.partner_system_priority) + self.assertEqual(res.partner_system, self.partner_system) + self.assertEqual(res.partner_key, self.partner_key) + self.assertEqual(res.partner_port_priority, self.partner_port_priority) + self.assertEqual(res.partner_port, self.partner_port) + self.assertEqual(res.partner_state_activity, self.partner_state_activity) + self.assertEqual(res.partner_state_timeout, self.partner_state_timeout) + self.assertEqual(res.partner_state_aggregation, self.partner_state_aggregation) - eq_(res.partner_state_synchronization, + self.assertEqual(res.partner_state_synchronization, self.partner_state_synchronization) - eq_(res.partner_state_collecting, self.partner_state_collecting) - eq_(res.partner_state_distributing, + self.assertEqual(res.partner_state_collecting, self.partner_state_collecting) + self.assertEqual(res.partner_state_distributing, self.partner_state_distributing) - eq_(res.partner_state_defaulted, self.partner_state_defaulted) - eq_(res.partner_state_expired, self.partner_state_expired) - eq_(res._partner_state, self.partner_state) - eq_(res._collector_tag, self.collector_tag) - eq_(res._collector_length, self.collector_length) - eq_(res.collector_max_delay, self.collector_max_delay) - eq_(res._terminator_tag, self.terminator_tag) - eq_(res._terminator_length, self.terminator_length) + self.assertEqual(res.partner_state_defaulted, self.partner_state_defaulted) + self.assertEqual(res.partner_state_expired, self.partner_state_expired) + self.assertEqual(res._partner_state, self.partner_state) + self.assertEqual(res._collector_tag, self.collector_tag) + self.assertEqual(res._collector_length, self.collector_length) + self.assertEqual(res.collector_max_delay, self.collector_max_delay) + self.assertEqual(res._terminator_tag, self.terminator_tag) + self.assertEqual(res._terminator_length, self.terminator_length) def test_serialize(self): data = bytearray() @@ -420,33 +419,33 @@ class Test_lacp(unittest.TestCase): offset += self.col_len trm_res = unpack_from(self.trm_fmt, buf, offset) - eq_(head_res[0], self.subtype) - eq_(head_res[1], self.version) + self.assertEqual(head_res[0], self.subtype) + self.assertEqual(head_res[1], self.version) - eq_(act_res[0], self.actor_tag) - eq_(act_res[1], self.actor_length) - eq_(act_res[2], self.actor_system_priority) - eq_(act_res[3], addrconv.mac.text_to_bin(self.actor_system)) - eq_(act_res[4], self.actor_key) - eq_(act_res[5], self.actor_port_priority) - eq_(act_res[6], self.actor_port) - eq_(act_res[7], self.actor_state) + self.assertEqual(act_res[0], self.actor_tag) + self.assertEqual(act_res[1], self.actor_length) + self.assertEqual(act_res[2], self.actor_system_priority) + self.assertEqual(act_res[3], addrconv.mac.text_to_bin(self.actor_system)) + self.assertEqual(act_res[4], self.actor_key) + self.assertEqual(act_res[5], self.actor_port_priority) + self.assertEqual(act_res[6], self.actor_port) + self.assertEqual(act_res[7], self.actor_state) - eq_(prt_res[0], self.partner_tag) - eq_(prt_res[1], self.partner_length) - eq_(prt_res[2], self.partner_system_priority) - eq_(prt_res[3], addrconv.mac.text_to_bin(self.partner_system)) - eq_(prt_res[4], self.partner_key) - eq_(prt_res[5], self.partner_port_priority) - eq_(prt_res[6], self.partner_port) - eq_(prt_res[7], self.partner_state) + self.assertEqual(prt_res[0], self.partner_tag) + self.assertEqual(prt_res[1], self.partner_length) + self.assertEqual(prt_res[2], self.partner_system_priority) + self.assertEqual(prt_res[3], addrconv.mac.text_to_bin(self.partner_system)) + self.assertEqual(prt_res[4], self.partner_key) + self.assertEqual(prt_res[5], self.partner_port_priority) + self.assertEqual(prt_res[6], self.partner_port) + self.assertEqual(prt_res[7], self.partner_state) - eq_(col_res[0], self.collector_tag) - eq_(col_res[1], self.collector_length) - eq_(col_res[2], self.collector_max_delay) + self.assertEqual(col_res[0], self.collector_tag) + self.assertEqual(col_res[1], self.collector_length) + self.assertEqual(col_res[2], self.collector_max_delay) - eq_(trm_res[0], self.terminator_tag) - eq_(trm_res[1], self.terminator_length) + self.assertEqual(trm_res[0], self.terminator_tag) + self.assertEqual(trm_res[1], self.terminator_length) def _build_lacp(self): ethertype = ether.ETH_TYPE_SLOW @@ -463,643 +462,645 @@ class Test_lacp(unittest.TestCase): p = self._build_lacp() e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_SLOW) + self.assertTrue(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_SLOW) l = self.find_protocol(p, "lacp") - ok_(l) + self.assertTrue(l) - eq_(l._subtype, self.subtype) - eq_(l.version, self.version) - eq_(l._actor_tag, self.actor_tag) - eq_(l._actor_length, self.actor_length) - eq_(l.actor_system_priority, self.actor_system_priority) - eq_(l.actor_system, self.actor_system) - eq_(l.actor_key, self.actor_key) - eq_(l.actor_port_priority, self.actor_port_priority) - eq_(l.actor_port, self.actor_port) - eq_(l.actor_state_activity, self.actor_state_activity) - eq_(l.actor_state_timeout, self.actor_state_timeout) - eq_(l.actor_state_aggregation, self.actor_state_aggregation) - eq_(l.actor_state_synchronization, + self.assertEqual(l._subtype, self.subtype) + self.assertEqual(l.version, self.version) + self.assertEqual(l._actor_tag, self.actor_tag) + self.assertEqual(l._actor_length, self.actor_length) + self.assertEqual(l.actor_system_priority, self.actor_system_priority) + self.assertEqual(l.actor_system, self.actor_system) + self.assertEqual(l.actor_key, self.actor_key) + self.assertEqual(l.actor_port_priority, self.actor_port_priority) + self.assertEqual(l.actor_port, self.actor_port) + self.assertEqual(l.actor_state_activity, self.actor_state_activity) + self.assertEqual(l.actor_state_timeout, self.actor_state_timeout) + self.assertEqual(l.actor_state_aggregation, self.actor_state_aggregation) + self.assertEqual(l.actor_state_synchronization, self.actor_state_synchronization) - eq_(l.actor_state_collecting, self.actor_state_collecting) - eq_(l.actor_state_distributing, self.actor_state_distributing) - eq_(l.actor_state_defaulted, self.actor_state_defaulted) - eq_(l.actor_state_expired, self.actor_state_expired) - eq_(l._actor_state, self.actor_state) - eq_(l._partner_tag, self.partner_tag) - eq_(l._partner_length, self.partner_length) - eq_(l.partner_system_priority, self.partner_system_priority) - eq_(l.partner_system, self.partner_system) - eq_(l.partner_key, self.partner_key) - eq_(l.partner_port_priority, self.partner_port_priority) - eq_(l.partner_port, self.partner_port) - eq_(l.partner_state_activity, self.partner_state_activity) - eq_(l.partner_state_timeout, self.partner_state_timeout) - eq_(l.partner_state_aggregation, self.partner_state_aggregation) - eq_(l.partner_state_synchronization, + self.assertEqual(l.actor_state_collecting, self.actor_state_collecting) + self.assertEqual(l.actor_state_distributing, self.actor_state_distributing) + self.assertEqual(l.actor_state_defaulted, self.actor_state_defaulted) + self.assertEqual(l.actor_state_expired, self.actor_state_expired) + self.assertEqual(l._actor_state, self.actor_state) + self.assertEqual(l._partner_tag, self.partner_tag) + self.assertEqual(l._partner_length, self.partner_length) + self.assertEqual(l.partner_system_priority, self.partner_system_priority) + self.assertEqual(l.partner_system, self.partner_system) + self.assertEqual(l.partner_key, self.partner_key) + self.assertEqual(l.partner_port_priority, self.partner_port_priority) + self.assertEqual(l.partner_port, self.partner_port) + self.assertEqual(l.partner_state_activity, self.partner_state_activity) + self.assertEqual(l.partner_state_timeout, self.partner_state_timeout) + self.assertEqual(l.partner_state_aggregation, self.partner_state_aggregation) + self.assertEqual(l.partner_state_synchronization, self.partner_state_synchronization) - eq_(l.partner_state_collecting, self.partner_state_collecting) - eq_(l.partner_state_distributing, + self.assertEqual(l.partner_state_collecting, self.partner_state_collecting) + self.assertEqual(l.partner_state_distributing, self.partner_state_distributing) - eq_(l.partner_state_defaulted, self.partner_state_defaulted) - eq_(l.partner_state_expired, self.partner_state_expired) - eq_(l._partner_state, self.partner_state) - eq_(l._collector_tag, self.collector_tag) - eq_(l._collector_length, self.collector_length) - eq_(l.collector_max_delay, self.collector_max_delay) - eq_(l._terminator_tag, self.terminator_tag) - eq_(l._terminator_length, self.terminator_length) + self.assertEqual(l.partner_state_defaulted, self.partner_state_defaulted) + self.assertEqual(l.partner_state_expired, self.partner_state_expired) + self.assertEqual(l._partner_state, self.partner_state) + self.assertEqual(l._collector_tag, self.collector_tag) + self.assertEqual(l._collector_length, self.collector_length) + self.assertEqual(l.collector_max_delay, self.collector_max_delay) + self.assertEqual(l._terminator_tag, self.terminator_tag) + self.assertEqual(l._terminator_length, self.terminator_length) - @raises(Exception) def test_malformed_lacp(self): m_short_buf = self.buf[1:self.length] - slow.parser(m_short_buf) + self.assertRaises(Exception, slow.parser, m_short_buf) - @raises(Exception) def test_invalid_subtype(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.subtype = 0xff invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_version(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.version = 0xff invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_actor_tag(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.actor_tag = 0x04 invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_actor_length(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.actor_length = 50 invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_partner_tag(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.partner_tag = 0x01 invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_partner_length(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.partner_length = 0 invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_collector_tag(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.collector_tag = 0x00 invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_collector_length(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.collector_length = 20 invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_terminator_tag(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.terminator_tag = 0x04 invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_terminator_length(self): + self.skipTest('This test needs to be refactored: "serialize" method ' + 'requires two input parameters that are not provided ' + 'here.') invalid_lacv = copy.deepcopy(self.l) invalid_lacv.terminator_length = self.trm_len invalid_buf = invalid_lacv.serialize() slow.parser(invalid_buf) - @raises(Exception) def test_invalid_actor_state_activity(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - 2, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + 2, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_actor_state_timeout(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - 2, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + 2, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_actor_state_aggregation(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - 2, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + 2, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_actor_state_synchronization(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - 2, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + 2, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_actor_state_collecting(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - 2, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + 2, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_actor_state_distributing(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - 2, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + 2, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_actor_state_defaulted(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - 2, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + 2, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_actor_state_expired(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - 2, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + 2, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_partner_state_activity(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - -1, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + -1, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_partner_state_timeout(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - -1, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + -1, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_partner_state_aggregation(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - -1, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + -1, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_partner_state_synchronization(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - -1, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + -1, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_partner_state_collecting(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - -1, - self.partner_state_distributing, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + -1, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_partner_state_distributing(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - -1, - self.partner_state_defaulted, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + -1, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_partner_state_defaulted(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - -1, - self.partner_state_expired, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + -1, + self.partner_state_expired, + self.collector_max_delay) - @raises(Exception) def test_invalid_partner_state_expired(self): - l = lacp(self.version, - self.actor_system_priority, - self.actor_system, - self.actor_key, - self.actor_port_priority, - self.actor_port, - self.actor_state_activity, - self.actor_state_timeout, - self.actor_state_aggregation, - self.actor_state_synchronization, - self.actor_state_collecting, - self.actor_state_distributing, - self.actor_state_defaulted, - self.actor_state_expired, - self.partner_system_priority, - self.partner_system, - self.partner_key, - self.partner_port_priority, - self.partner_port, - self.partner_state_activity, - self.partner_state_timeout, - self.partner_state_aggregation, - self.partner_state_synchronization, - self.partner_state_collecting, - self.partner_state_distributing, - self.partner_state_defaulted, - -1, - self.collector_max_delay) - l.serialize() + self.assertRaises(AssertionError, lacp, + self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + -1, + self.collector_max_delay) def test_json(self): jsondict = self.l.to_jsondict() l = lacp.from_jsondict(jsondict['lacp']) - eq_(str(self.l), str(l)) + self.assertEqual(str(self.l), str(l)) diff --git a/os_ken/tests/unit/packet/test_tcp.py b/os_ken/tests/unit/packet/test_tcp.py index 16282ce8..fe60dd8b 100644 --- a/os_ken/tests/unit/packet/test_tcp.py +++ b/os_ken/tests/unit/packet/test_tcp.py @@ -20,7 +20,6 @@ import logging import six import struct from struct import * -from nose.tools import * from os_ken.ofproto import inet from os_ken.lib.packet import tcp from os_ken.lib.packet.ipv4 import ipv4 @@ -59,31 +58,31 @@ class Test_tcp(unittest.TestCase): pass def test_init(self): - eq_(self.src_port, self.t.src_port) - eq_(self.dst_port, self.t.dst_port) - eq_(self.seq, self.t.seq) - eq_(self.ack, self.t.ack) - eq_(self.offset, self.t.offset) - eq_(self.bits, self.t.bits) - eq_(self.window_size, self.t.window_size) - eq_(self.csum, self.t.csum) - eq_(self.urgent, self.t.urgent) - eq_(self.option, self.t.option) + self.assertEqual(self.src_port, self.t.src_port) + self.assertEqual(self.dst_port, self.t.dst_port) + self.assertEqual(self.seq, self.t.seq) + self.assertEqual(self.ack, self.t.ack) + self.assertEqual(self.offset, self.t.offset) + self.assertEqual(self.bits, self.t.bits) + self.assertEqual(self.window_size, self.t.window_size) + self.assertEqual(self.csum, self.t.csum) + self.assertEqual(self.urgent, self.t.urgent) + self.assertEqual(self.option, self.t.option) def test_parser(self): r1, r2, _ = self.t.parser(self.buf) - eq_(self.src_port, r1.src_port) - eq_(self.dst_port, r1.dst_port) - eq_(self.seq, r1.seq) - eq_(self.ack, r1.ack) - eq_(self.offset, r1.offset) - eq_(self.bits, r1.bits) - eq_(self.window_size, r1.window_size) - eq_(self.csum, r1.csum) - eq_(self.urgent, r1.urgent) - eq_(self.option, r1.option) - eq_(None, r2) + self.assertEqual(self.src_port, r1.src_port) + self.assertEqual(self.dst_port, r1.dst_port) + self.assertEqual(self.seq, r1.seq) + self.assertEqual(self.ack, r1.ack) + self.assertEqual(self.offset, r1.offset) + self.assertEqual(self.bits, r1.bits) + self.assertEqual(self.window_size, r1.window_size) + self.assertEqual(self.csum, r1.csum) + self.assertEqual(self.urgent, r1.urgent) + self.assertEqual(self.option, r1.option) + self.assertEqual(None, r2) def test_serialize(self): offset = 5 @@ -99,20 +98,20 @@ class Test_tcp(unittest.TestCase): buf = t.serialize(bytearray(), prev) res = struct.unpack(tcp.tcp._PACK_STR, six.binary_type(buf)) - eq_(res[0], self.src_port) - eq_(res[1], self.dst_port) - eq_(res[2], self.seq) - eq_(res[3], self.ack) - eq_(res[4], offset << 4) - eq_(res[5], self.bits) - eq_(res[6], self.window_size) - eq_(res[8], self.urgent) + self.assertEqual(res[0], self.src_port) + self.assertEqual(res[1], self.dst_port) + self.assertEqual(res[2], self.seq) + self.assertEqual(res[3], self.ack) + self.assertEqual(res[4], offset << 4) + self.assertEqual(res[5], self.bits) + self.assertEqual(res[6], self.window_size) + self.assertEqual(res[8], self.urgent) # test __len__ # offset indicates the number of 32 bit (= 4 bytes) # words in the TCP Header. # So, we compare len(tcp) with offset * 4, here. - eq_(offset * 4, len(t)) + self.assertEqual(offset * 4, len(t)) # checksum ph = struct.pack('!4s4sBBH', @@ -120,7 +119,7 @@ class Test_tcp(unittest.TestCase): addrconv.ipv4.text_to_bin(dst_ip), 0, 6, offset * 4) d = ph + buf s = packet_utils.checksum(d) - eq_(0, s) + self.assertEqual(0, s) def test_serialize_option(self): # prepare test data @@ -149,16 +148,15 @@ class Test_tcp(unittest.TestCase): option) buf = t.serialize(bytearray(), prev) r_option_buf = buf[tcp.tcp._MIN_LEN:tcp.tcp._MIN_LEN + len(option_buf)] - eq_(option_buf, r_option_buf) + self.assertEqual(option_buf, r_option_buf) # test parser (r_tcp, _, _) = tcp.tcp.parser(buf) - eq_(str(option), str(r_tcp.option)) + self.assertEqual(str(option), str(r_tcp.option)) - @raises(Exception) def test_malformed_tcp(self): m_short_buf = self.buf[1:tcp.tcp._MIN_LEN] - tcp.tcp.parser(m_short_buf) + self.assertRaises(Exception, tcp.tcp.parser, m_short_buf) def test_default_args(self): prev = ipv4(proto=inet.IPPROTO_TCP) @@ -166,49 +164,49 @@ class Test_tcp(unittest.TestCase): buf = t.serialize(bytearray(), prev) res = struct.unpack(tcp.tcp._PACK_STR, buf) - eq_(res[0], 1) - eq_(res[1], 1) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 5 << 4) - eq_(res[5], 0) - eq_(res[6], 0) - eq_(res[8], 0) + self.assertEqual(res[0], 1) + self.assertEqual(res[1], 1) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 5 << 4) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], 0) + self.assertEqual(res[8], 0) # with option, without offset t = tcp.tcp(option=[tcp.TCPOptionMaximumSegmentSize(1460)]) buf = t.serialize(bytearray(), prev) res = struct.unpack(tcp.tcp._PACK_STR + '4s', buf) - eq_(res[0], 1) - eq_(res[1], 1) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 6 << 4) - eq_(res[5], 0) - eq_(res[6], 0) - eq_(res[8], 0) - eq_(res[9], b'\x02\x04\x05\xb4') + self.assertEqual(res[0], 1) + self.assertEqual(res[1], 1) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 6 << 4) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], 0) + self.assertEqual(res[8], 0) + self.assertEqual(res[9], b'\x02\x04\x05\xb4') # with option, with long offset t = tcp.tcp(offset=7, option=[tcp.TCPOptionWindowScale(shift_cnt=9)]) buf = t.serialize(bytearray(), prev) res = struct.unpack(tcp.tcp._PACK_STR + '8s', buf) - eq_(res[0], 1) - eq_(res[1], 1) - eq_(res[2], 0) - eq_(res[3], 0) - eq_(res[4], 7 << 4) - eq_(res[5], 0) - eq_(res[6], 0) - eq_(res[8], 0) - eq_(res[9], b'\x03\x03\x09\x00\x00\x00\x00\x00') + self.assertEqual(res[0], 1) + self.assertEqual(res[1], 1) + self.assertEqual(res[2], 0) + self.assertEqual(res[3], 0) + self.assertEqual(res[4], 7 << 4) + self.assertEqual(res[5], 0) + self.assertEqual(res[6], 0) + self.assertEqual(res[8], 0) + self.assertEqual(res[9], b'\x03\x03\x09\x00\x00\x00\x00\x00') def test_json(self): jsondict = self.t.to_jsondict() t = tcp.tcp.from_jsondict(jsondict['tcp']) - eq_(str(self.t), str(t)) + self.assertEqual(str(self.t), str(t)) class Test_TCPOption(unittest.TestCase): @@ -250,7 +248,7 @@ class Test_TCPOption(unittest.TestCase): output_buf = bytearray() for option in self.input_options: output_buf += option.serialize() - eq_(self.input_buf, output_buf) + self.assertEqual(self.input_buf, output_buf) def test_parser(self): buf = self.input_buf @@ -258,10 +256,10 @@ class Test_TCPOption(unittest.TestCase): while buf: opt, buf = tcp.TCPOption.parser(buf) output_options.append(opt) - eq_(str(self.input_options), str(output_options)) + self.assertEqual(str(self.input_options), str(output_options)) def test_json(self): for option in self.input_options: json_dict = option.to_jsondict()[option.__class__.__name__] output_option = option.__class__.from_jsondict(json_dict) - eq_(str(option), str(output_option)) + self.assertEqual(str(option), str(output_option)) diff --git a/os_ken/tests/unit/packet/test_udp.py b/os_ken/tests/unit/packet/test_udp.py index 6a41dcb1..0a0e82cc 100644 --- a/os_ken/tests/unit/packet/test_udp.py +++ b/os_ken/tests/unit/packet/test_udp.py @@ -19,7 +19,6 @@ import unittest import logging import struct from struct import * -from nose.tools import * from os_ken.ofproto import ether, inet from os_ken.lib.packet.packet import Packet from os_ken.lib.packet.udp import udp @@ -48,19 +47,19 @@ class Test_udp(unittest.TestCase): pass def test_init(self): - eq_(self.src_port, self.u.src_port) - eq_(self.dst_port, self.u.dst_port) - eq_(self.total_length, self.u.total_length) - eq_(self.csum, self.u.csum) + self.assertEqual(self.src_port, self.u.src_port) + self.assertEqual(self.dst_port, self.u.dst_port) + self.assertEqual(self.total_length, self.u.total_length) + self.assertEqual(self.csum, self.u.csum) def test_parser(self): r1, r2, _ = self.u.parser(self.buf) - eq_(self.src_port, r1.src_port) - eq_(self.dst_port, r1.dst_port) - eq_(self.total_length, r1.total_length) - eq_(self.csum, r1.csum) - eq_(None, r2) + self.assertEqual(self.src_port, r1.src_port) + self.assertEqual(self.dst_port, r1.dst_port) + self.assertEqual(self.total_length, r1.total_length) + self.assertEqual(self.csum, r1.csum) + self.assertEqual(None, r2) def test_serialize(self): src_port = 6431 @@ -77,9 +76,9 @@ class Test_udp(unittest.TestCase): buf = u.serialize(bytearray(), prev) res = struct.unpack(udp._PACK_STR, buf) - eq_(res[0], src_port) - eq_(res[1], dst_port) - eq_(res[2], struct.calcsize(udp._PACK_STR)) + self.assertEqual(res[0], src_port) + self.assertEqual(res[1], dst_port) + self.assertEqual(res[2], struct.calcsize(udp._PACK_STR)) # checksum ph = struct.pack('!4s4sBBH', @@ -87,12 +86,11 @@ class Test_udp(unittest.TestCase): addrconv.ipv4.text_to_bin(dst_ip), 0, 17, res[2]) d = ph + buf + bytearray() s = packet_utils.checksum(d) - eq_(0, s) + self.assertEqual(0, s) - @raises(Exception) def test_malformed_udp(self): m_short_buf = self.buf[1:udp._MIN_LEN] - udp.parser(m_short_buf) + self.assertRaises(Exception, udp.parser, m_short_buf) def test_default_args(self): prev = ipv4(proto=inet.IPPROTO_UDP) @@ -100,11 +98,11 @@ class Test_udp(unittest.TestCase): buf = u.serialize(bytearray(), prev) res = struct.unpack(udp._PACK_STR, buf) - eq_(res[0], 1) - eq_(res[1], 1) - eq_(res[2], udp._MIN_LEN) + self.assertEqual(res[0], 1) + self.assertEqual(res[1], 1) + self.assertEqual(res[2], udp._MIN_LEN) def test_json(self): jsondict = self.u.to_jsondict() u = udp.from_jsondict(jsondict['udp']) - eq_(str(self.u), str(u)) + self.assertEqual(str(self.u), str(u)) diff --git a/os_ken/tests/unit/packet/test_vlan.py b/os_ken/tests/unit/packet/test_vlan.py index 74db4591..cd9d864b 100644 --- a/os_ken/tests/unit/packet/test_vlan.py +++ b/os_ken/tests/unit/packet/test_vlan.py @@ -19,7 +19,6 @@ import unittest import logging import struct from struct import * -from nose.tools import * from os_ken.ofproto import ether, inet from os_ken.lib.packet.ethernet import ethernet from os_ken.lib.packet.packet import Packet @@ -57,19 +56,19 @@ class Test_vlan(unittest.TestCase): return p def test_init(self): - eq_(self.pcp, self.v.pcp) - eq_(self.cfi, self.v.cfi) - eq_(self.vid, self.v.vid) - eq_(self.ethertype, self.v.ethertype) + self.assertEqual(self.pcp, self.v.pcp) + self.assertEqual(self.cfi, self.v.cfi) + self.assertEqual(self.vid, self.v.vid) + self.assertEqual(self.ethertype, self.v.ethertype) def test_parser(self): res, ptype, _ = self.v.parser(self.buf) - eq_(res.pcp, self.pcp) - eq_(res.cfi, self.cfi) - eq_(res.vid, self.vid) - eq_(res.ethertype, self.ethertype) - eq_(ptype, ipv4) + self.assertEqual(res.pcp, self.pcp) + self.assertEqual(res.cfi, self.cfi) + self.assertEqual(res.vid, self.vid) + self.assertEqual(res.ethertype, self.ethertype) + self.assertEqual(ptype, ipv4) def test_serialize(self): data = bytearray() @@ -79,8 +78,8 @@ class Test_vlan(unittest.TestCase): fmt = vlan._PACK_STR res = struct.unpack(fmt, buf) - eq_(res[0], self.tci) - eq_(res[1], self.ethertype) + self.assertEqual(res[0], self.tci) + self.assertEqual(res[1], self.ethertype) def _build_vlan(self): src_mac = '00:07:0d:af:f4:54' @@ -117,30 +116,29 @@ class Test_vlan(unittest.TestCase): p = self._build_vlan() e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_8021Q) + self.assertTrue(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_8021Q) v = self.find_protocol(p, "vlan") - ok_(v) - eq_(v.ethertype, ether.ETH_TYPE_IP) + self.assertTrue(v) + self.assertEqual(v.ethertype, ether.ETH_TYPE_IP) ip = self.find_protocol(p, "ipv4") - ok_(ip) + self.assertTrue(ip) - eq_(v.pcp, self.pcp) - eq_(v.cfi, self.cfi) - eq_(v.vid, self.vid) - eq_(v.ethertype, self.ethertype) + self.assertEqual(v.pcp, self.pcp) + self.assertEqual(v.cfi, self.cfi) + self.assertEqual(v.vid, self.vid) + self.assertEqual(v.ethertype, self.ethertype) - @raises(Exception) def test_malformed_vlan(self): m_short_buf = self.buf[1:vlan._MIN_LEN] - vlan.parser(m_short_buf) + self.assertRaises(Exception, vlan.parser, m_short_buf) def test_json(self): jsondict = self.v.to_jsondict() v = vlan.from_jsondict(jsondict['vlan']) - eq_(str(self.v), str(v)) + self.assertEqual(str(self.v), str(v)) class Test_svlan(unittest.TestCase): @@ -167,19 +165,19 @@ class Test_svlan(unittest.TestCase): return p def test_init(self): - eq_(self.pcp, self.sv.pcp) - eq_(self.cfi, self.sv.cfi) - eq_(self.vid, self.sv.vid) - eq_(self.ethertype, self.sv.ethertype) + self.assertEqual(self.pcp, self.sv.pcp) + self.assertEqual(self.cfi, self.sv.cfi) + self.assertEqual(self.vid, self.sv.vid) + self.assertEqual(self.ethertype, self.sv.ethertype) def test_parser(self): res, ptype, _ = self.sv.parser(self.buf) - eq_(res.pcp, self.pcp) - eq_(res.cfi, self.cfi) - eq_(res.vid, self.vid) - eq_(res.ethertype, self.ethertype) - eq_(ptype, vlan) + self.assertEqual(res.pcp, self.pcp) + self.assertEqual(res.cfi, self.cfi) + self.assertEqual(res.vid, self.vid) + self.assertEqual(res.ethertype, self.ethertype) + self.assertEqual(ptype, vlan) def test_serialize(self): data = bytearray() @@ -189,8 +187,8 @@ class Test_svlan(unittest.TestCase): fmt = svlan._PACK_STR res = struct.unpack(fmt, buf) - eq_(res[0], self.tci) - eq_(res[1], self.ethertype) + self.assertEqual(res[0], self.tci) + self.assertEqual(res[1], self.ethertype) def _build_svlan(self): src_mac = '00:07:0d:af:f4:54' @@ -235,31 +233,30 @@ class Test_svlan(unittest.TestCase): p = self._build_svlan() e = self.find_protocol(p, "ethernet") - ok_(e) - eq_(e.ethertype, ether.ETH_TYPE_8021AD) + self.assertTrue(e) + self.assertEqual(e.ethertype, ether.ETH_TYPE_8021AD) sv = self.find_protocol(p, "svlan") - ok_(sv) - eq_(sv.ethertype, ether.ETH_TYPE_8021Q) + self.assertTrue(sv) + self.assertEqual(sv.ethertype, ether.ETH_TYPE_8021Q) v = self.find_protocol(p, "vlan") - ok_(v) - eq_(v.ethertype, ether.ETH_TYPE_IP) + self.assertTrue(v) + self.assertEqual(v.ethertype, ether.ETH_TYPE_IP) ip = self.find_protocol(p, "ipv4") - ok_(ip) + self.assertTrue(ip) - eq_(sv.pcp, self.pcp) - eq_(sv.cfi, self.cfi) - eq_(sv.vid, self.vid) - eq_(sv.ethertype, self.ethertype) + self.assertEqual(sv.pcp, self.pcp) + self.assertEqual(sv.cfi, self.cfi) + self.assertEqual(sv.vid, self.vid) + self.assertEqual(sv.ethertype, self.ethertype) - @raises(Exception) def test_malformed_svlan(self): m_short_buf = self.buf[1:svlan._MIN_LEN] - svlan.parser(m_short_buf) + self.assertRaises(Exception, vlan.parser, m_short_buf) def test_json(self): jsondict = self.sv.to_jsondict() sv = svlan.from_jsondict(jsondict['svlan']) - eq_(str(self.sv), str(sv)) + self.assertEqual(str(self.sv), str(sv)) diff --git a/os_ken/tests/unit/packet/test_vrrp.py b/os_ken/tests/unit/packet/test_vrrp.py index 2ebce295..c3403400 100644 --- a/os_ken/tests/unit/packet/test_vrrp.py +++ b/os_ken/tests/unit/packet/test_vrrp.py @@ -22,9 +22,6 @@ import six import struct import inspect -from nose.tools import eq_, ok_ -from nose.tools import raises - from os_ken.ofproto import inet from os_ken.lib.packet import ipv4 from os_ken.lib.packet import ipv6 @@ -66,30 +63,30 @@ class Test_vrrpv2(unittest.TestCase): pass def test_init(self): - eq_(self.type_, self.vrrpv2.type) - eq_(self.vrid, self.vrrpv2.vrid) - eq_(self.priority, self.vrrpv2.priority) - eq_(self.count_ip, self.vrrpv2.count_ip) - eq_(self.auth_type, self.vrrpv2.auth_type) - eq_(1, len(self.vrrpv2.ip_addresses)) - eq_(self.ip_address, self.vrrpv2.ip_addresses[0]) - eq_(self.auth_data, self.vrrpv2.auth_data) + self.assertEqual(self.type_, self.vrrpv2.type) + self.assertEqual(self.vrid, self.vrrpv2.vrid) + self.assertEqual(self.priority, self.vrrpv2.priority) + self.assertEqual(self.count_ip, self.vrrpv2.count_ip) + self.assertEqual(self.auth_type, self.vrrpv2.auth_type) + self.assertEqual(1, len(self.vrrpv2.ip_addresses)) + self.assertEqual(self.ip_address, self.vrrpv2.ip_addresses[0]) + self.assertEqual(self.auth_data, self.vrrpv2.auth_data) def test_parser(self): vrrpv2, _cls, _ = self.vrrpv2.parser(self.buf) - eq_(self.version, vrrpv2.version) - eq_(self.type_, vrrpv2.type) - eq_(self.vrid, vrrpv2.vrid) - eq_(self.priority, vrrpv2.priority) - eq_(self.count_ip, vrrpv2.count_ip) - eq_(self.auth_type, vrrpv2.auth_type) - eq_(self.max_adver_int, vrrpv2.max_adver_int) - eq_(self.checksum, vrrpv2.checksum) - eq_(1, len(vrrpv2.ip_addresses)) - eq_(str, type(vrrpv2.ip_addresses[0])) - eq_(self.ip_address, vrrpv2.ip_addresses[0]) - eq_(self.auth_data, vrrpv2.auth_data) + self.assertEqual(self.version, vrrpv2.version) + self.assertEqual(self.type_, vrrpv2.type) + self.assertEqual(self.vrid, vrrpv2.vrid) + self.assertEqual(self.priority, vrrpv2.priority) + self.assertEqual(self.count_ip, vrrpv2.count_ip) + self.assertEqual(self.auth_type, vrrpv2.auth_type) + self.assertEqual(self.max_adver_int, vrrpv2.max_adver_int) + self.assertEqual(self.checksum, vrrpv2.checksum) + self.assertEqual(1, len(vrrpv2.ip_addresses)) + self.assertEqual(str, type(vrrpv2.ip_addresses[0])) + self.assertEqual(self.ip_address, vrrpv2.ip_addresses[0]) + self.assertEqual(self.auth_data, vrrpv2.auth_data) def test_serialize(self): src_ip = '192.168.0.1' @@ -111,26 +108,25 @@ class Test_vrrpv2(unittest.TestCase): pack_str = vrrp.vrrpv2._PACK_STR + '4sII' pack_len = struct.calcsize(pack_str) res = struct.unpack(pack_str, six.binary_type(buf)) - eq_(res[0], vrrp.vrrp_to_version_type(vrrp.VRRP_VERSION_V2, type_)) - eq_(res[1], vrid) - eq_(res[2], priority) - eq_(res[3], len(ip_addresses)) - eq_(res[4], vrrp.VRRP_AUTH_NO_AUTH) - eq_(res[5], max_adver_int) + self.assertEqual(res[0], vrrp.vrrp_to_version_type(vrrp.VRRP_VERSION_V2, type_)) + self.assertEqual(res[1], vrid) + self.assertEqual(res[2], priority) + self.assertEqual(res[3], len(ip_addresses)) + self.assertEqual(res[4], vrrp.VRRP_AUTH_NO_AUTH) + self.assertEqual(res[5], max_adver_int) # res[6] is checksum - eq_(res[7], addrconv.ipv4.text_to_bin(ip_address)) - eq_(res[8], 0) - eq_(res[9], 0) - eq_(len(buf), pack_len) + self.assertEqual(res[7], addrconv.ipv4.text_to_bin(ip_address)) + self.assertEqual(res[8], 0) + self.assertEqual(res[9], 0) + self.assertEqual(len(buf), pack_len) # checksum s = packet_utils.checksum(buf) - eq_(0, s) + self.assertEqual(0, s) - @raises(Exception) def test_malformed_vrrpv2(self): m_short_buf = self.buf[1:vrrp.vrrpv2._MIN_LEN] - vrrp.vrrp.parser(m_short_buf) + self.assertRaises(Exception, vrrp.vrrp.parser, m_short_buf) def test_create_packet(self): primary_ip = '192.168.0.2' @@ -138,7 +134,7 @@ class Test_vrrpv2(unittest.TestCase): p0.serialize() p1 = packet.Packet(six.binary_type(p0.data)) p1.serialize() - eq_(p0.data, p1.data) + self.assertEqual(p0.data, p1.data) def _test_is_valid(self, type_=None, vrid=None, priority=None, max_adver_int=None): @@ -156,34 +152,34 @@ class Test_vrrpv2(unittest.TestCase): return vrrp_.is_valid() def test_is_valid_ok(self): - ok_(self._test_is_valid()) + self.assertTrue(self._test_is_valid()) def test_is_valid_ng_type(self): - ok_(not self._test_is_valid(type_=15)) + self.assertTrue(not self._test_is_valid(type_=15)) def test_is_valid_ng_vrid_min(self): vrid = vrrp.VRRP_VRID_MIN - 1 - ok_(not self._test_is_valid(vrid=vrid)) + self.assertTrue(not self._test_is_valid(vrid=vrid)) def test_is_valid_ng_vrid_max(self): vrid = vrrp.VRRP_VRID_MAX + 1 - ok_(not self._test_is_valid(vrid=vrid)) + self.assertTrue(not self._test_is_valid(vrid=vrid)) def test_is_valid_ng_priority_min(self): priority = vrrp.VRRP_PRIORITY_MIN - 1 - ok_(not self._test_is_valid(priority=priority)) + self.assertTrue(not self._test_is_valid(priority=priority)) def test_is_valid_ng_priority_max(self): priority = vrrp.VRRP_PRIORITY_MAX + 1 - ok_(not self._test_is_valid(priority=priority)) + self.assertTrue(not self._test_is_valid(priority=priority)) def test_is_valid_ng_adver_min(self): max_adver_int = vrrp.VRRP_V2_MAX_ADVER_INT_MIN - 1 - ok_(not self._test_is_valid(max_adver_int=max_adver_int)) + self.assertTrue(not self._test_is_valid(max_adver_int=max_adver_int)) def test_is_valid_ng_adver_max(self): max_adver_int = vrrp.VRRP_V2_MAX_ADVER_INT_MAX + 1 - ok_(not self._test_is_valid(max_adver_int=max_adver_int)) + self.assertTrue(not self._test_is_valid(max_adver_int=max_adver_int)) def test_to_string(self): vrrpv2_values = {'version': self.version, @@ -202,8 +198,8 @@ class Test_vrrpv2(unittest.TestCase): if k in vrrpv2_values]) vrrpv2_str = '%s(%s)' % (vrrp.vrrpv2.__name__, _vrrpv2_str) - eq_(str(self.vrrpv2), vrrpv2_str) - eq_(repr(self.vrrpv2), vrrpv2_str) + self.assertEqual(str(self.vrrpv2), vrrpv2_str) + self.assertEqual(repr(self.vrrpv2), vrrpv2_str) class Test_vrrpv3_ipv4(unittest.TestCase): @@ -232,26 +228,26 @@ class Test_vrrpv3_ipv4(unittest.TestCase): pass def test_init(self): - eq_(self.type_, self.vrrpv3.type) - eq_(self.vrid, self.vrrpv3.vrid) - eq_(self.priority, self.vrrpv3.priority) - eq_(self.count_ip, self.vrrpv3.count_ip) - eq_(1, len(self.vrrpv3.ip_addresses)) - eq_(self.ip_address, self.vrrpv3.ip_addresses[0]) + self.assertEqual(self.type_, self.vrrpv3.type) + self.assertEqual(self.vrid, self.vrrpv3.vrid) + self.assertEqual(self.priority, self.vrrpv3.priority) + self.assertEqual(self.count_ip, self.vrrpv3.count_ip) + self.assertEqual(1, len(self.vrrpv3.ip_addresses)) + self.assertEqual(self.ip_address, self.vrrpv3.ip_addresses[0]) def test_parser(self): vrrpv3, _cls, _ = self.vrrpv3.parser(self.buf) - eq_(self.version, vrrpv3.version) - eq_(self.type_, vrrpv3.type) - eq_(self.vrid, vrrpv3.vrid) - eq_(self.priority, vrrpv3.priority) - eq_(self.count_ip, vrrpv3.count_ip) - eq_(self.max_adver_int, vrrpv3.max_adver_int) - eq_(self.checksum, vrrpv3.checksum) - eq_(1, len(vrrpv3.ip_addresses)) - eq_(str, type(vrrpv3.ip_addresses[0])) - eq_(self.ip_address, vrrpv3.ip_addresses[0]) + self.assertEqual(self.version, vrrpv3.version) + self.assertEqual(self.type_, vrrpv3.type) + self.assertEqual(self.vrid, vrrpv3.vrid) + self.assertEqual(self.priority, vrrpv3.priority) + self.assertEqual(self.count_ip, vrrpv3.count_ip) + self.assertEqual(self.max_adver_int, vrrpv3.max_adver_int) + self.assertEqual(self.checksum, vrrpv3.checksum) + self.assertEqual(1, len(vrrpv3.ip_addresses)) + self.assertEqual(str, type(vrrpv3.ip_addresses[0])) + self.assertEqual(self.ip_address, vrrpv3.ip_addresses[0]) def test_serialize(self): src_ip = '192.168.0.1' @@ -274,14 +270,14 @@ class Test_vrrpv3_ipv4(unittest.TestCase): pack_str = vrrp.vrrpv3._PACK_STR + '4s' pack_len = struct.calcsize(pack_str) res = struct.unpack(pack_str, six.binary_type(buf)) - eq_(res[0], vrrp.vrrp_to_version_type(vrrp.VRRP_VERSION_V3, type_)) - eq_(res[1], vrid) - eq_(res[2], priority) - eq_(res[3], len(ip_addresses)) - eq_(res[4], max_adver_int) + self.assertEqual(res[0], vrrp.vrrp_to_version_type(vrrp.VRRP_VERSION_V3, type_)) + self.assertEqual(res[1], vrid) + self.assertEqual(res[2], priority) + self.assertEqual(res[3], len(ip_addresses)) + self.assertEqual(res[4], max_adver_int) # res[5] is checksum - eq_(res[6], addrconv.ipv4.text_to_bin(ip_address)) - eq_(len(buf), pack_len) + self.assertEqual(res[6], addrconv.ipv4.text_to_bin(ip_address)) + self.assertEqual(len(buf), pack_len) print(res) # checksum @@ -290,12 +286,11 @@ class Test_vrrpv3_ipv4(unittest.TestCase): addrconv.ipv4.text_to_bin(dst_ip), inet.IPPROTO_VRRP, pack_len) s = packet_utils.checksum(ph + buf) - eq_(0, s) + self.assertEqual(0, s) - @raises(Exception) def test_malformed_vrrpv3(self): m_short_buf = self.buf[1:vrrp.vrrpv3._MIN_LEN] - vrrp.vrrp.parser(m_short_buf) + self.assertRaises(Exception, vrrp.vrrp.parser, m_short_buf) def test_create_packet(self): primary_ip = '192.168.0.2' @@ -303,7 +298,7 @@ class Test_vrrpv3_ipv4(unittest.TestCase): p0.serialize() p1 = packet.Packet(six.binary_type(p0.data)) p1.serialize() - eq_(p0.data, p1.data) + self.assertEqual(p0.data, p1.data) def _test_is_valid(self, type_=None, vrid=None, priority=None, max_adver_int=None): @@ -321,34 +316,34 @@ class Test_vrrpv3_ipv4(unittest.TestCase): return vrrp_.is_valid() def test_is_valid_ok(self): - ok_(self._test_is_valid()) + self.assertTrue(self._test_is_valid()) def test_is_valid_ng_type(self): - ok_(not self._test_is_valid(type_=15)) + self.assertTrue(not self._test_is_valid(type_=15)) def test_is_valid_ng_vrid_min(self): vrid = vrrp.VRRP_VRID_MIN - 1 - ok_(not self._test_is_valid(vrid=vrid)) + self.assertTrue(not self._test_is_valid(vrid=vrid)) def test_is_valid_ng_vrid_max(self): vrid = vrrp.VRRP_VRID_MAX + 1 - ok_(not self._test_is_valid(vrid=vrid)) + self.assertTrue(not self._test_is_valid(vrid=vrid)) def test_is_valid_ng_priority_min(self): priority = vrrp.VRRP_PRIORITY_MIN - 1 - ok_(not self._test_is_valid(priority=priority)) + self.assertTrue(not self._test_is_valid(priority=priority)) def test_is_valid_ng_priority_max(self): priority = vrrp.VRRP_PRIORITY_MAX + 1 - ok_(not self._test_is_valid(priority=priority)) + self.assertTrue(not self._test_is_valid(priority=priority)) def test_is_valid_ng_adver_min(self): max_adver_int = vrrp.VRRP_V3_MAX_ADVER_INT_MIN - 1 - ok_(not self._test_is_valid(max_adver_int=max_adver_int)) + self.assertTrue(not self._test_is_valid(max_adver_int=max_adver_int)) def test_is_valid_ng_adver_max(self): max_adver_int = vrrp.VRRP_V3_MAX_ADVER_INT_MAX + 1 - ok_(not self._test_is_valid(max_adver_int=max_adver_int)) + self.assertTrue(not self._test_is_valid(max_adver_int=max_adver_int)) def test_to_string(self): vrrpv3_values = {'version': self.version, @@ -367,8 +362,8 @@ class Test_vrrpv3_ipv4(unittest.TestCase): if k in vrrpv3_values]) vrrpv3_str = '%s(%s)' % (vrrp.vrrpv3.__name__, _vrrpv3_str) - eq_(str(self.vrrpv3), vrrpv3_str) - eq_(repr(self.vrrpv3), vrrpv3_str) + self.assertEqual(str(self.vrrpv3), vrrpv3_str) + self.assertEqual(repr(self.vrrpv3), vrrpv3_str) class Test_vrrpv3_ipv6(unittest.TestCase): @@ -397,26 +392,26 @@ class Test_vrrpv3_ipv6(unittest.TestCase): pass def test_init(self): - eq_(self.type_, self.vrrpv3.type) - eq_(self.vrid, self.vrrpv3.vrid) - eq_(self.priority, self.vrrpv3.priority) - eq_(self.count_ip, self.vrrpv3.count_ip) - eq_(1, len(self.vrrpv3.ip_addresses)) - eq_(self.ip_address, self.vrrpv3.ip_addresses[0]) + self.assertEqual(self.type_, self.vrrpv3.type) + self.assertEqual(self.vrid, self.vrrpv3.vrid) + self.assertEqual(self.priority, self.vrrpv3.priority) + self.assertEqual(self.count_ip, self.vrrpv3.count_ip) + self.assertEqual(1, len(self.vrrpv3.ip_addresses)) + self.assertEqual(self.ip_address, self.vrrpv3.ip_addresses[0]) def test_parser(self): vrrpv3, _cls, _ = self.vrrpv3.parser(self.buf) - eq_(self.version, vrrpv3.version) - eq_(self.type_, vrrpv3.type) - eq_(self.vrid, vrrpv3.vrid) - eq_(self.priority, vrrpv3.priority) - eq_(self.count_ip, vrrpv3.count_ip) - eq_(self.max_adver_int, vrrpv3.max_adver_int) - eq_(self.checksum, vrrpv3.checksum) - eq_(1, len(vrrpv3.ip_addresses)) - eq_(str, type(vrrpv3.ip_addresses[0])) - eq_(self.ip_address, vrrpv3.ip_addresses[0]) + self.assertEqual(self.version, vrrpv3.version) + self.assertEqual(self.type_, vrrpv3.type) + self.assertEqual(self.vrid, vrrpv3.vrid) + self.assertEqual(self.priority, vrrpv3.priority) + self.assertEqual(self.count_ip, vrrpv3.count_ip) + self.assertEqual(self.max_adver_int, vrrpv3.max_adver_int) + self.assertEqual(self.checksum, vrrpv3.checksum) + self.assertEqual(1, len(vrrpv3.ip_addresses)) + self.assertEqual(str, type(vrrpv3.ip_addresses[0])) + self.assertEqual(self.ip_address, vrrpv3.ip_addresses[0]) def test_serialize(self): src_ip = '2001:db8:2000::1' @@ -439,14 +434,14 @@ class Test_vrrpv3_ipv6(unittest.TestCase): pack_str = vrrp.vrrpv3._PACK_STR + '16s' pack_len = struct.calcsize(pack_str) res = struct.unpack(pack_str, six.binary_type(buf)) - eq_(res[0], vrrp.vrrp_to_version_type(vrrp.VRRP_VERSION_V3, type_)) - eq_(res[1], vrid) - eq_(res[2], priority) - eq_(res[3], len(ip_addresses)) - eq_(res[4], max_adver_int) + self.assertEqual(res[0], vrrp.vrrp_to_version_type(vrrp.VRRP_VERSION_V3, type_)) + self.assertEqual(res[1], vrid) + self.assertEqual(res[2], priority) + self.assertEqual(res[3], len(ip_addresses)) + self.assertEqual(res[4], max_adver_int) # res[5] is checksum - eq_(res[6], addrconv.ipv6.text_to_bin(ip_address)) - eq_(len(buf), pack_len) + self.assertEqual(res[6], addrconv.ipv6.text_to_bin(ip_address)) + self.assertEqual(len(buf), pack_len) print(res) # checksum @@ -455,12 +450,11 @@ class Test_vrrpv3_ipv6(unittest.TestCase): addrconv.ipv6.text_to_bin(dst_ip), pack_len, inet.IPPROTO_VRRP) s = packet_utils.checksum(ph + buf) - eq_(0, s) + self.assertEqual(0, s) - @raises(Exception) def test_malformed_vrrpv3(self): m_short_buf = self.buf[1:vrrp.vrrpv3._MIN_LEN] - vrrp.vrrp.parser(m_short_buf) + self.assertRaises(Exception, vrrp.vrrp.parser, m_short_buf) def test_create_packet(self): primary_ip = '2001:db8:2000::3' @@ -471,7 +465,7 @@ class Test_vrrpv3_ipv6(unittest.TestCase): p1.serialize() print(len(p0.data), p0.data) print(len(p1.data), p1.data) - eq_(p0.data, p1.data) + self.assertEqual(p0.data, p1.data) def test_to_string(self): vrrpv3_values = {'version': self.version, @@ -490,5 +484,5 @@ class Test_vrrpv3_ipv6(unittest.TestCase): if k in vrrpv3_values]) vrrpv3_str = '%s(%s)' % (vrrp.vrrpv3.__name__, _vrrpv3_str) - eq_(str(self.vrrpv3), vrrpv3_str) - eq_(repr(self.vrrpv3), vrrpv3_str) + self.assertEqual(str(self.vrrpv3), vrrpv3_str) + self.assertEqual(repr(self.vrrpv3), vrrpv3_str) diff --git a/os_ken/tests/unit/packet/test_vxlan.py b/os_ken/tests/unit/packet/test_vxlan.py index 85f76ecf..e84f956e 100644 --- a/os_ken/tests/unit/packet/test_vxlan.py +++ b/os_ken/tests/unit/packet/test_vxlan.py @@ -16,9 +16,6 @@ import logging import unittest -from nose.tools import eq_ -from nose.tools import raises - from os_ken.lib.packet import ethernet from os_ken.lib.packet import vxlan @@ -45,38 +42,37 @@ class Test_vxlan(unittest.TestCase): } def test_init(self): - eq_(self.vni, self.pkt.vni) + self.assertEqual(self.vni, self.pkt.vni) def test_parser(self): parsed_pkt, next_proto_cls, rest_buf = vxlan.vxlan.parser(self.buf) - eq_(self.vni, parsed_pkt.vni) - eq_(ethernet.ethernet, next_proto_cls) - eq_(b'test_payload', rest_buf) + self.assertEqual(self.vni, parsed_pkt.vni) + self.assertEqual(ethernet.ethernet, next_proto_cls) + self.assertEqual(b'test_payload', rest_buf) - @raises(AssertionError) def test_invalid_flags(self): invalid_flags_bug = ( b'\x00\x00\x00\x00' # all bits are set to zero b'\x12\x34\x56\x00' # vni = 0x123456 (24 bits) ) - vxlan.vxlan.parser(invalid_flags_bug) + self.assertRaises(Exception, vxlan.vxlan.parser, invalid_flags_bug) def test_serialize(self): serialized_buf = self.pkt.serialize(payload=None, prev=None) - eq_(self.buf[:vxlan.vxlan._MIN_LEN], serialized_buf) + self.assertEqual(self.buf[:vxlan.vxlan._MIN_LEN], serialized_buf) def test_from_jsondict(self): pkt_from_json = vxlan.vxlan.from_jsondict( self.jsondict[vxlan.vxlan.__name__]) - eq_(self.vni, pkt_from_json.vni) + self.assertEqual(self.vni, pkt_from_json.vni) def test_to_jsondict(self): jsondict_from_pkt = self.pkt.to_jsondict() - eq_(self.jsondict, jsondict_from_pkt) + self.assertEqual(self.jsondict, jsondict_from_pkt) def test_vni_from_bin(self): vni = vxlan.vni_from_bin(b'\x12\x34\x56') - eq_(self.vni, vni) + self.assertEqual(self.vni, vni) def test_vni_to_bin(self): - eq_(b'\x12\x34\x56', vxlan.vni_to_bin(self.vni)) + self.assertEqual(b'\x12\x34\x56', vxlan.vni_to_bin(self.vni)) diff --git a/os_ken/tests/unit/packet/test_zebra.py b/os_ken/tests/unit/packet/test_zebra.py index d999b65c..f7f78803 100644 --- a/os_ken/tests/unit/packet/test_zebra.py +++ b/os_ken/tests/unit/packet/test_zebra.py @@ -19,9 +19,6 @@ import sys import unittest from unittest import mock -from nose.tools import eq_ -from nose.tools import ok_ -from nose.tools import raises import six from os_ken.lib import pcaplib @@ -45,8 +42,7 @@ class Test_zebra(unittest.TestCase): Test case for os_ken.lib.packet.zebra. """ - @staticmethod - def _test_pcap_single(f): + def _test_pcap_single(self, f): zebra_pcap_file = os.path.join(PCAP_DATA_DIR, f + '.pcap') # print('*** testing %s' % zebra_pcap_file) @@ -55,15 +51,15 @@ class Test_zebra(unittest.TestCase): pkt = packet.Packet(buf) zebra_pkts = pkt.get_protocols(zebra.ZebraMessage) for zebra_pkt in zebra_pkts: - ok_(isinstance(zebra_pkt, zebra.ZebraMessage), + self.assertTrue(isinstance(zebra_pkt, zebra.ZebraMessage), 'Failed to parse Zebra message: %s' % pkt) - ok_(not isinstance(pkt.protocols[-1], + self.assertTrue(not isinstance(pkt.protocols[-1], (six.binary_type, bytearray)), 'Some messages could not be parsed in %s: %s' % (f, pkt)) # Checks if Zebra message can be serialized as expected. pkt.serialize() - eq_(binary_str(buf), binary_str(pkt.data)) + self.assertEqual(binary_str(buf), binary_str(pkt.data)) def test_pcap_quagga(self): files = [ @@ -87,19 +83,17 @@ class Test_zebra(unittest.TestCase): class TestZebraMessage(unittest.TestCase): def test_get_header_size(self): - eq_(zebra.ZebraMessage.V0_HEADER_SIZE, + self.assertEqual(zebra.ZebraMessage.V0_HEADER_SIZE, zebra.ZebraMessage.get_header_size(0)) - eq_(zebra.ZebraMessage.V1_HEADER_SIZE, + self.assertEqual(zebra.ZebraMessage.V1_HEADER_SIZE, zebra.ZebraMessage.get_header_size(2)) - eq_(zebra.ZebraMessage.V3_HEADER_SIZE, + self.assertEqual(zebra.ZebraMessage.V3_HEADER_SIZE, zebra.ZebraMessage.get_header_size(3)) - eq_(zebra.ZebraMessage.V3_HEADER_SIZE, + self.assertEqual(zebra.ZebraMessage.V3_HEADER_SIZE, zebra.ZebraMessage.get_header_size(4)) - @raises(ValueError) def test_get_header_size_invalid_version(self): - eq_(zebra.ZebraMessage.V0_HEADER_SIZE, - zebra.ZebraMessage.get_header_size(0xff)) + self.assertRaises(ValueError, zebra.ZebraMessage.get_header_size, 0xff) class TestZebraRedistributeAdd(unittest.TestCase): @@ -111,11 +105,11 @@ class TestZebraRedistributeAdd(unittest.TestCase): def test_parser(self): body = zebra.ZebraRedistributeAdd.parse(self.buf, version=3) - eq_(self.route_type, body.route_type) + self.assertEqual(self.route_type, body.route_type) buf = body.serialize(version=3) - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraIPv4ImportLookup(unittest.TestCase): @@ -131,14 +125,14 @@ class TestZebraIPv4ImportLookup(unittest.TestCase): def test_parser(self): body = zebra.ZebraIPv4ImportLookup.parse(self.buf) - eq_(self.prefix, body.prefix) - eq_(self.metric, body.metric) - eq_(self.nexthop_num, len(body.nexthops)) - eq_(self.from_zebra, body.from_zebra) + self.assertEqual(self.prefix, body.prefix) + self.assertEqual(self.metric, body.metric) + self.assertEqual(self.nexthop_num, len(body.nexthops)) + self.assertEqual(self.from_zebra, body.from_zebra) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraIPv4ImportLookupFromZebra(unittest.TestCase): @@ -159,16 +153,16 @@ class TestZebraIPv4ImportLookupFromZebra(unittest.TestCase): def test_parser(self): body = zebra.ZebraIPv4ImportLookup.parse_from_zebra(self.buf) - eq_(self.prefix, body.prefix) - eq_(self.metric, body.metric) - eq_(self.nexthop_num, len(body.nexthops)) - eq_(self.nexthop_type, body.nexthops[0].type) - eq_(self.ifindex, body.nexthops[0].ifindex) - eq_(self.from_zebra, body.from_zebra) + self.assertEqual(self.prefix, body.prefix) + self.assertEqual(self.metric, body.metric) + self.assertEqual(self.nexthop_num, len(body.nexthops)) + self.assertEqual(self.nexthop_type, body.nexthops[0].type) + self.assertEqual(self.ifindex, body.nexthops[0].ifindex) + self.assertEqual(self.from_zebra, body.from_zebra) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraIPv4NexthopLookupMRib(unittest.TestCase): @@ -183,14 +177,14 @@ class TestZebraIPv4NexthopLookupMRib(unittest.TestCase): def test_parser(self): body = zebra.ZebraIPv4NexthopLookupMRib.parse(self.buf) - eq_(self.addr, body.addr) - eq_(self.distance, body.distance) - eq_(self.metric, body.metric) - eq_(self.nexthop_num, len(body.nexthops)) + self.assertEqual(self.addr, body.addr) + self.assertEqual(self.distance, body.distance) + self.assertEqual(self.metric, body.metric) + self.assertEqual(self.nexthop_num, len(body.nexthops)) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraIPv4NexthopLookupMRibFromZebra(unittest.TestCase): @@ -212,16 +206,16 @@ class TestZebraIPv4NexthopLookupMRibFromZebra(unittest.TestCase): def test_parser(self): body = zebra.ZebraIPv4NexthopLookupMRib.parse(self.buf) - eq_(self.addr, body.addr) - eq_(self.distance, body.distance) - eq_(self.metric, body.metric) - eq_(self.nexthop_num, len(body.nexthops)) - eq_(self.nexthop_type, body.nexthops[0].type) - eq_(self.ifindex, body.nexthops[0].ifindex) + self.assertEqual(self.addr, body.addr) + self.assertEqual(self.distance, body.distance) + self.assertEqual(self.metric, body.metric) + self.assertEqual(self.nexthop_num, len(body.nexthops)) + self.assertEqual(self.nexthop_type, body.nexthops[0].type) + self.assertEqual(self.ifindex, body.nexthops[0].ifindex) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraNexthopUpdateIPv6(unittest.TestCase): @@ -246,16 +240,16 @@ class TestZebraNexthopUpdateIPv6(unittest.TestCase): def test_parser(self): body = zebra.ZebraNexthopUpdate.parse(self.buf) - eq_(self.family, body.family) - eq_(self.prefix, body.prefix) - eq_(self.metric, body.metric) - eq_(self.nexthop_num, len(body.nexthops)) - eq_(self.nexthop_type, body.nexthops[0].type) - eq_(self.ifindex, body.nexthops[0].ifindex) + self.assertEqual(self.family, body.family) + self.assertEqual(self.prefix, body.prefix) + self.assertEqual(self.metric, body.metric) + self.assertEqual(self.nexthop_num, len(body.nexthops)) + self.assertEqual(self.nexthop_type, body.nexthops[0].type) + self.assertEqual(self.ifindex, body.nexthops[0].ifindex) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraInterfaceNbrAddressAdd(unittest.TestCase): @@ -273,13 +267,13 @@ class TestZebraInterfaceNbrAddressAdd(unittest.TestCase): def test_parser(self): body = zebra.ZebraInterfaceNbrAddressAdd.parse(self.buf) - eq_(self.ifindex, body.ifindex) - eq_(self.family, body.family) - eq_(self.prefix, body.prefix) + self.assertEqual(self.ifindex, body.ifindex) + self.assertEqual(self.family, body.family) + self.assertEqual(self.prefix, body.prefix) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraInterfaceBfdDestinationUpdate(unittest.TestCase): @@ -304,16 +298,16 @@ class TestZebraInterfaceBfdDestinationUpdate(unittest.TestCase): def test_parser(self): body = zebra.ZebraInterfaceBfdDestinationUpdate.parse(self.buf) - eq_(self.ifindex, body.ifindex) - eq_(self.dst_family, body.dst_family) - eq_(self.dst_prefix, body.dst_prefix) - eq_(self.status, body.status) - eq_(self.src_family, body.src_family) - eq_(self.src_prefix, body.src_prefix) + self.assertEqual(self.ifindex, body.ifindex) + self.assertEqual(self.dst_family, body.dst_family) + self.assertEqual(self.dst_prefix, body.dst_prefix) + self.assertEqual(self.status, body.status) + self.assertEqual(self.src_family, body.src_family) + self.assertEqual(self.src_prefix, body.src_prefix) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraBfdDestinationRegisterMultiHopEnabled(unittest.TestCase): @@ -345,21 +339,21 @@ class TestZebraBfdDestinationRegisterMultiHopEnabled(unittest.TestCase): def test_parser(self): body = zebra.ZebraBfdDestinationRegister.parse(self.buf) - eq_(self.pid, body.pid) - eq_(self.dst_family, body.dst_family) - eq_(self.dst_prefix, body.dst_prefix) - eq_(self.min_rx_timer, body.min_rx_timer) - eq_(self.min_tx_timer, body.min_tx_timer) - eq_(self.detect_mult, body.detect_mult) - eq_(self.multi_hop, body.multi_hop) - eq_(self.src_family, body.src_family) - eq_(self.src_prefix, body.src_prefix) - eq_(self.multi_hop_count, body.multi_hop_count) - eq_(self.ifname, body.ifname) + self.assertEqual(self.pid, body.pid) + self.assertEqual(self.dst_family, body.dst_family) + self.assertEqual(self.dst_prefix, body.dst_prefix) + self.assertEqual(self.min_rx_timer, body.min_rx_timer) + self.assertEqual(self.min_tx_timer, body.min_tx_timer) + self.assertEqual(self.detect_mult, body.detect_mult) + self.assertEqual(self.multi_hop, body.multi_hop) + self.assertEqual(self.src_family, body.src_family) + self.assertEqual(self.src_prefix, body.src_prefix) + self.assertEqual(self.multi_hop_count, body.multi_hop_count) + self.assertEqual(self.ifname, body.ifname) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraBfdDestinationRegisterMultiHopDisabled(unittest.TestCase): @@ -392,21 +386,21 @@ class TestZebraBfdDestinationRegisterMultiHopDisabled(unittest.TestCase): def test_parser(self): body = zebra.ZebraBfdDestinationRegister.parse(self.buf) - eq_(self.pid, body.pid) - eq_(self.dst_family, body.dst_family) - eq_(self.dst_prefix, body.dst_prefix) - eq_(self.min_rx_timer, body.min_rx_timer) - eq_(self.min_tx_timer, body.min_tx_timer) - eq_(self.detect_mult, body.detect_mult) - eq_(self.multi_hop, body.multi_hop) - eq_(self.src_family, body.src_family) - eq_(self.src_prefix, body.src_prefix) - eq_(self.multi_hop_count, body.multi_hop_count) - eq_(self.ifname, body.ifname) + self.assertEqual(self.pid, body.pid) + self.assertEqual(self.dst_family, body.dst_family) + self.assertEqual(self.dst_prefix, body.dst_prefix) + self.assertEqual(self.min_rx_timer, body.min_rx_timer) + self.assertEqual(self.min_tx_timer, body.min_tx_timer) + self.assertEqual(self.detect_mult, body.detect_mult) + self.assertEqual(self.multi_hop, body.multi_hop) + self.assertEqual(self.src_family, body.src_family) + self.assertEqual(self.src_prefix, body.src_prefix) + self.assertEqual(self.multi_hop_count, body.multi_hop_count) + self.assertEqual(self.ifname, body.ifname) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraBfdDestinationRegisterMultiHopEnabledIPv6(unittest.TestCase): @@ -444,21 +438,21 @@ class TestZebraBfdDestinationRegisterMultiHopEnabledIPv6(unittest.TestCase): def test_parser(self): body = zebra.ZebraBfdDestinationRegister.parse(self.buf) - eq_(self.pid, body.pid) - eq_(self.dst_family, body.dst_family) - eq_(self.dst_prefix, body.dst_prefix) - eq_(self.min_rx_timer, body.min_rx_timer) - eq_(self.min_tx_timer, body.min_tx_timer) - eq_(self.detect_mult, body.detect_mult) - eq_(self.multi_hop, body.multi_hop) - eq_(self.src_family, body.src_family) - eq_(self.src_prefix, body.src_prefix) - eq_(self.multi_hop_count, body.multi_hop_count) - eq_(self.ifname, body.ifname) + self.assertEqual(self.pid, body.pid) + self.assertEqual(self.dst_family, body.dst_family) + self.assertEqual(self.dst_prefix, body.dst_prefix) + self.assertEqual(self.min_rx_timer, body.min_rx_timer) + self.assertEqual(self.min_tx_timer, body.min_tx_timer) + self.assertEqual(self.detect_mult, body.detect_mult) + self.assertEqual(self.multi_hop, body.multi_hop) + self.assertEqual(self.src_family, body.src_family) + self.assertEqual(self.src_prefix, body.src_prefix) + self.assertEqual(self.multi_hop_count, body.multi_hop_count) + self.assertEqual(self.ifname, body.ifname) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraBfdDestinationDeregisterMultiHopEnabled(unittest.TestCase): @@ -484,18 +478,18 @@ class TestZebraBfdDestinationDeregisterMultiHopEnabled(unittest.TestCase): def test_parser(self): body = zebra.ZebraBfdDestinationDeregister.parse(self.buf) - eq_(self.pid, body.pid) - eq_(self.dst_family, body.dst_family) - eq_(self.dst_prefix, body.dst_prefix) - eq_(self.multi_hop, body.multi_hop) - eq_(self.src_family, body.src_family) - eq_(self.src_prefix, body.src_prefix) - eq_(self.multi_hop_count, body.multi_hop_count) - eq_(self.ifname, body.ifname) + self.assertEqual(self.pid, body.pid) + self.assertEqual(self.dst_family, body.dst_family) + self.assertEqual(self.dst_prefix, body.dst_prefix) + self.assertEqual(self.multi_hop, body.multi_hop) + self.assertEqual(self.src_family, body.src_family) + self.assertEqual(self.src_prefix, body.src_prefix) + self.assertEqual(self.multi_hop_count, body.multi_hop_count) + self.assertEqual(self.ifname, body.ifname) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraBfdDestinationDeregisterMultiHopDisabled(unittest.TestCase): @@ -522,18 +516,18 @@ class TestZebraBfdDestinationDeregisterMultiHopDisabled(unittest.TestCase): def test_parser(self): body = zebra.ZebraBfdDestinationDeregister.parse(self.buf) - eq_(self.pid, body.pid) - eq_(self.dst_family, body.dst_family) - eq_(self.dst_prefix, body.dst_prefix) - eq_(self.multi_hop, body.multi_hop) - eq_(self.src_family, body.src_family) - eq_(self.src_prefix, body.src_prefix) - eq_(self.multi_hop_count, body.multi_hop_count) - eq_(self.ifname, body.ifname) + self.assertEqual(self.pid, body.pid) + self.assertEqual(self.dst_family, body.dst_family) + self.assertEqual(self.dst_prefix, body.dst_prefix) + self.assertEqual(self.multi_hop, body.multi_hop) + self.assertEqual(self.src_family, body.src_family) + self.assertEqual(self.src_prefix, body.src_prefix) + self.assertEqual(self.multi_hop_count, body.multi_hop_count) + self.assertEqual(self.ifname, body.ifname) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraBfdDestinationDeregisterMultiHopEnabledIPv6(unittest.TestCase): @@ -565,18 +559,18 @@ class TestZebraBfdDestinationDeregisterMultiHopEnabledIPv6(unittest.TestCase): def test_parser(self): body = zebra.ZebraBfdDestinationDeregister.parse(self.buf) - eq_(self.pid, body.pid) - eq_(self.dst_family, body.dst_family) - eq_(self.dst_prefix, body.dst_prefix) - eq_(self.multi_hop, body.multi_hop) - eq_(self.src_family, body.src_family) - eq_(self.src_prefix, body.src_prefix) - eq_(self.multi_hop_count, body.multi_hop_count) - eq_(self.ifname, body.ifname) + self.assertEqual(self.pid, body.pid) + self.assertEqual(self.dst_family, body.dst_family) + self.assertEqual(self.dst_prefix, body.dst_prefix) + self.assertEqual(self.multi_hop, body.multi_hop) + self.assertEqual(self.src_family, body.src_family) + self.assertEqual(self.src_prefix, body.src_prefix) + self.assertEqual(self.multi_hop_count, body.multi_hop_count) + self.assertEqual(self.ifname, body.ifname) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraVrfAdd(unittest.TestCase): @@ -597,11 +591,11 @@ class TestZebraVrfAdd(unittest.TestCase): def test_parser(self): body = zebra.ZebraVrfAdd.parse(self.buf) - eq_(self.vrf_name, body.vrf_name) + self.assertEqual(self.vrf_name, body.vrf_name) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraInterfaceVrfUpdate(unittest.TestCase): @@ -616,12 +610,12 @@ class TestZebraInterfaceVrfUpdate(unittest.TestCase): def test_parser(self): body = zebra.ZebraInterfaceVrfUpdate.parse(self.buf) - eq_(self.ifindex, body.ifindex) - eq_(self.vrf_id, body.vrf_id) + self.assertEqual(self.ifindex, body.ifindex) + self.assertEqual(self.vrf_id, body.vrf_id) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraInterfaceEnableRadv(unittest.TestCase): @@ -636,12 +630,12 @@ class TestZebraInterfaceEnableRadv(unittest.TestCase): def test_parser(self): body = zebra.ZebraInterfaceEnableRadv.parse(self.buf) - eq_(self.ifindex, body.ifindex) - eq_(self.interval, body.interval) + self.assertEqual(self.ifindex, body.ifindex) + self.assertEqual(self.interval, body.interval) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraMplsLabelsAddIPv4(unittest.TestCase): @@ -667,17 +661,17 @@ class TestZebraMplsLabelsAddIPv4(unittest.TestCase): def test_parser(self): body = zebra.ZebraMplsLabelsAdd.parse(self.buf) - eq_(self.route_type, body.route_type) - eq_(self.family, body.family) - eq_(self.prefix, body.prefix) - eq_(self.gate_addr, body.gate_addr) - eq_(self.distance, body.distance) - eq_(self.in_label, body.in_label) - eq_(self.out_label, body.out_label) + self.assertEqual(self.route_type, body.route_type) + self.assertEqual(self.family, body.family) + self.assertEqual(self.prefix, body.prefix) + self.assertEqual(self.gate_addr, body.gate_addr) + self.assertEqual(self.distance, body.distance) + self.assertEqual(self.in_label, body.in_label) + self.assertEqual(self.out_label, body.out_label) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) class TestZebraMplsLabelsAddIPv6(unittest.TestCase): @@ -709,14 +703,14 @@ class TestZebraMplsLabelsAddIPv6(unittest.TestCase): def test_parser(self): body = zebra.ZebraMplsLabelsAdd.parse(self.buf) - eq_(self.route_type, body.route_type) - eq_(self.family, body.family) - eq_(self.prefix, body.prefix) - eq_(self.gate_addr, body.gate_addr) - eq_(self.distance, body.distance) - eq_(self.in_label, body.in_label) - eq_(self.out_label, body.out_label) + self.assertEqual(self.route_type, body.route_type) + self.assertEqual(self.family, body.family) + self.assertEqual(self.prefix, body.prefix) + self.assertEqual(self.gate_addr, body.gate_addr) + self.assertEqual(self.distance, body.distance) + self.assertEqual(self.in_label, body.in_label) + self.assertEqual(self.out_label, body.out_label) buf = body.serialize() - eq_(binary_str(self.buf), binary_str(buf)) + self.assertEqual(binary_str(self.buf), binary_str(buf)) diff --git a/os_ken/tests/unit/sample/__init__.py b/os_ken/tests/unit/sample/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/os_ken/tests/unit/sample/test_sample1.py b/os_ken/tests/unit/sample/test_sample1.py deleted file mode 100644 index 3c2fa5c5..00000000 --- a/os_ken/tests/unit/sample/test_sample1.py +++ /dev/null @@ -1,19 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -import unittest -from nose.tools import ok_, eq_ - -import logging - - -LOG = logging.getLogger('os_ken.tests.test_sample1') - - -class TestSample1(unittest.TestCase): - - def testS1Func1(self): - LOG.debug('testS1Func1 - START') - ok_(True) - - def testS1Func2(self): - ok_(True) diff --git a/os_ken/tests/unit/sample/test_sample2.py b/os_ken/tests/unit/sample/test_sample2.py deleted file mode 100644 index 24918b34..00000000 --- a/os_ken/tests/unit/sample/test_sample2.py +++ /dev/null @@ -1,13 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -import unittest -from nose.tools import ok_, eq_ - - -class TestSample2(unittest.TestCase): - - def testS2Func1(self): - ok_(True) - - def testS2Func2(self): - ok_(True) diff --git a/os_ken/tests/unit/services/protocols/bgp/core_managers/test_table_manager.py b/os_ken/tests/unit/services/protocols/bgp/core_managers/test_table_manager.py index 8d73c744..f83c1874 100644 --- a/os_ken/tests/unit/services/protocols/bgp/core_managers/test_table_manager.py +++ b/os_ken/tests/unit/services/protocols/bgp/core_managers/test_table_manager.py @@ -18,14 +18,11 @@ import logging import unittest from unittest import mock -from nose.tools import ok_, eq_, raises - from os_ken.lib.packet.bgp import BGPPathAttributeOrigin from os_ken.lib.packet.bgp import BGPPathAttributeAsPath from os_ken.lib.packet.bgp import BGP_ATTR_ORIGIN_IGP from os_ken.lib.packet.bgp import BGP_ATTR_TYPE_ORIGIN from os_ken.lib.packet.bgp import BGP_ATTR_TYPE_AS_PATH -from os_ken.lib.packet.bgp import BGP_ATTR_TYPE_EXTENDED_COMMUNITIES from os_ken.lib.packet.bgp import IPAddrPrefix from os_ken.lib.packet.bgp import IP6AddrPrefix from os_ken.lib.packet.bgp import EvpnArbitraryEsi @@ -33,21 +30,13 @@ from os_ken.lib.packet.bgp import EvpnLACPEsi from os_ken.lib.packet.bgp import EvpnEthernetAutoDiscoveryNLRI from os_ken.lib.packet.bgp import EvpnMacIPAdvertisementNLRI from os_ken.lib.packet.bgp import EvpnInclusiveMulticastEthernetTagNLRI -from os_ken.lib.packet.bgp import FlowSpecIPv4NLRI -from os_ken.lib.packet.bgp import BGPPathAttributeExtendedCommunities from os_ken.services.protocols.bgp.bgpspeaker import EVPN_MAX_ET from os_ken.services.protocols.bgp.bgpspeaker import ESI_TYPE_LACP -from os_ken.services.protocols.bgp.bgpspeaker import FLOWSPEC_FAMILY_IPV4 -from os_ken.services.protocols.bgp.bgpspeaker import FLOWSPEC_FAMILY_VPNV4 -from os_ken.services.protocols.bgp.bgpspeaker import FLOWSPEC_TA_SAMPLE -from os_ken.services.protocols.bgp.bgpspeaker import FLOWSPEC_TA_TERMINAL from os_ken.services.protocols.bgp.core import BgpCoreError from os_ken.services.protocols.bgp.core_managers import table_manager from os_ken.services.protocols.bgp.rtconf.vrfs import VRF_RF_IPV4 from os_ken.services.protocols.bgp.rtconf.vrfs import VRF_RF_IPV6 from os_ken.services.protocols.bgp.rtconf.vrfs import VRF_RF_L2_EVPN -from os_ken.services.protocols.bgp.rtconf.vrfs import VRF_RF_IPV4_FLOWSPEC -from os_ken.services.protocols.bgp.utils.bgp import create_v4flowspec_actions LOG = logging.getLogger(__name__) @@ -81,17 +70,17 @@ class Test_TableCoreManager(unittest.TestCase): # Check call_args_list = vrf_table_mock.insert_vrf_path.call_args_list - ok_(len(call_args_list) == 1) # insert_vrf_path should be called once + self.assertTrue(len(call_args_list) == 1) # insert_vrf_path should be called once args, kwargs = call_args_list[0] - ok_(len(args) == 0) # no positional argument - eq_(str(prefix_inst), str(kwargs['nlri'])) - eq_(is_withdraw, kwargs['is_withdraw']) + self.assertTrue(len(args) == 0) # no positional argument + self.assertEqual(str(prefix_inst), str(kwargs['nlri'])) + self.assertEqual(is_withdraw, kwargs['is_withdraw']) if is_withdraw: - eq_(None, kwargs['next_hop']) - eq_(False, kwargs['gen_lbl']) + self.assertEqual(None, kwargs['next_hop']) + self.assertEqual(False, kwargs['gen_lbl']) else: - eq_(next_hop, kwargs['next_hop']) - eq_(True, kwargs['gen_lbl']) + self.assertEqual(next_hop, kwargs['next_hop']) + self.assertEqual(True, kwargs['gen_lbl']) def test_update_vrf_table_ipv4(self): # Prepare test data @@ -233,13 +222,15 @@ class Test_TableCoreManager(unittest.TestCase): # Check call_args_list = vrf_table_mock.insert_vrf_path.call_args_list - ok_(len(call_args_list) == 1) # insert_vrf_path should be called once + self.assertTrue( + len(call_args_list) == 1) # insert_vrf_path should be called once args, kwargs = call_args_list[0] - ok_(len(args) == 0) # no positional argument - eq_(str(prefix_inst), str(kwargs['nlri'])) - eq_(next_hop, kwargs['next_hop']) - eq_(False, kwargs['gen_lbl']) # should not generate MPLS labels - eq_(tunnel_type, kwargs['tunnel_type']) + self.assertTrue(len(args) == 0) # no positional argument + self.assertEqual(str(prefix_inst), str(kwargs['nlri'])) + self.assertEqual(next_hop, kwargs['next_hop']) + self.assertEqual( + False, kwargs['gen_lbl']) # should not generate MPLS labels + self.assertEqual(tunnel_type, kwargs['tunnel_type']) def test_update_vrf_table_ipv4_withdraw(self): # Prepare test data @@ -257,7 +248,6 @@ class Test_TableCoreManager(unittest.TestCase): next_hop, route_family, route_type, is_withdraw=True, **kwargs) - @raises(BgpCoreError) @mock.patch( 'os_ken.services.protocols.bgp.core_managers.TableCoreManager.__init__', mock.MagicMock(return_value=None)) @@ -277,15 +267,11 @@ class Test_TableCoreManager(unittest.TestCase): tbl_mng._tables = {} # no table # Test - tbl_mng.update_vrf_table( - route_dist=route_dist, - prefix=prefix_str, - next_hop=next_hop, - route_family=route_family, - route_type=route_type, - **kwargs) + self.assertRaises(BgpCoreError, tbl_mng.update_vrf_table, + route_dist=route_dist, prefix=prefix_str, + next_hop=next_hop, route_family=route_family, + route_type=route_type, **kwargs) - @raises(BgpCoreError) def test_update_vrf_table_invalid_next_hop(self): # Prepare test data route_dist = '65000:100' @@ -298,11 +284,10 @@ class Test_TableCoreManager(unittest.TestCase): route_type = None # should be ignored kwargs = {} # should be ignored - self._test_update_vrf_table(prefix_inst, route_dist, prefix_str, - next_hop, route_family, route_type, - **kwargs) + self.assertRaises(BgpCoreError, self._test_update_vrf_table, + prefix_inst, route_dist, prefix_str, next_hop, + route_family, route_type, **kwargs) - @raises(BgpCoreError) def test_update_vrf_table_invalid_ipv4_prefix(self): # Prepare test data route_dist = '65000:100' @@ -315,11 +300,10 @@ class Test_TableCoreManager(unittest.TestCase): route_type = None # should be ignored kwargs = {} # should be ignored - self._test_update_vrf_table(prefix_inst, route_dist, prefix_str, - next_hop, route_family, route_type, - **kwargs) + self.assertRaises(BgpCoreError, self._test_update_vrf_table, + prefix_inst, route_dist, prefix_str, + next_hop, route_family, route_type, **kwargs) - @raises(BgpCoreError) def test_update_vrf_table_invalid_ipv6_prefix(self): # Prepare test data route_dist = '65000:100' @@ -332,11 +316,10 @@ class Test_TableCoreManager(unittest.TestCase): route_type = None # should be ignored kwargs = {} # should be ignored - self._test_update_vrf_table(prefix_inst, route_dist, prefix_str, - next_hop, route_family, route_type, - **kwargs) + self.assertRaises(BgpCoreError, self._test_update_vrf_table, + prefix_inst, route_dist, prefix_str, next_hop, + route_family, route_type, **kwargs) - @raises(BgpCoreError) def test_update_vrf_table_invalid_route_family(self): # Prepare test data route_dist = '65000:100' @@ -349,9 +332,9 @@ class Test_TableCoreManager(unittest.TestCase): route_type = None # should be ignored kwargs = {} # should be ignored - self._test_update_vrf_table(prefix_inst, route_dist, prefix_str, - next_hop, route_family, route_type, - **kwargs) + self.assertRaises(BgpCoreError, self._test_update_vrf_table, + prefix_inst, route_dist, prefix_str, next_hop, + route_family, route_type, **kwargs) @mock.patch( 'os_ken.services.protocols.bgp.core_managers.TableCoreManager.__init__', @@ -380,15 +363,15 @@ class Test_TableCoreManager(unittest.TestCase): # Check call_args_list = learn_path_mock.call_args_list - ok_(len(call_args_list) == 1) # learn_path should be called once + self.assertTrue(len(call_args_list) == 1) # learn_path should be called once args, kwargs = call_args_list[0] - ok_(len(kwargs) == 0) # no keyword argument + self.assertTrue(len(kwargs) == 0) # no keyword argument output_path = args[0] - eq_(None, output_path.source) - eq_(prefix, output_path.nlri.prefix) - eq_(pathattrs, str(output_path.pathattr_map)) - eq_(expected_next_hop, output_path.nexthop) - eq_(is_withdraw, output_path.is_withdraw) + self.assertEqual(None, output_path.source) + self.assertEqual(prefix, output_path.nlri.prefix) + self.assertEqual(pathattrs, str(output_path.pathattr_map)) + self.assertEqual(expected_next_hop, output_path.nexthop) + self.assertEqual(is_withdraw, output_path.is_withdraw) def test_update_global_table_ipv4(self): self._test_update_global_table( @@ -460,12 +443,12 @@ class Test_TableCoreManager(unittest.TestCase): # Check call_args_list = vrf_table_mock.insert_vrffs_path.call_args_list - ok_(len( + self.assertTrue(len( call_args_list) == 1) # insert_vrffs_path should be called once args, kwargs = call_args_list[0] - ok_(len(args) == 0) # no positional argument - eq_(prefix, kwargs['nlri'].prefix) - eq_(is_withdraw, kwargs['is_withdraw']) + self.assertTrue(len(args) == 0) # no positional argument + self.assertEqual(prefix, kwargs['nlri'].prefix) + self.assertEqual(is_withdraw, kwargs['is_withdraw']) def test_update_flowspec_vrf_table_vpnv4(self): flowspec_family = 'vpnv4fs' @@ -510,7 +493,6 @@ class Test_TableCoreManager(unittest.TestCase): is_withdraw=False, ) - @raises(BgpCoreError) def test_update_flowspec_vrf_table_vpnv4_invalid_actions(self): flowspec_family = 'vpnv4fs' route_family = 'ipv4fs' @@ -525,17 +507,15 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'ipv4fs(dst_prefix:10.70.1.0/24)' - self._test_update_flowspec_vrf_table( - flowspec_family=flowspec_family, - route_family=route_family, - route_dist=route_dist, - rules=rules, - prefix=prefix, - is_withdraw=False, - actions=actions, - ) + self.assertRaises(BgpCoreError, self._test_update_flowspec_vrf_table, + flowspec_family=flowspec_family, + route_family=route_family, + route_dist=route_dist, + rules=rules, + prefix=prefix, + is_withdraw=False, + actions=actions) - @raises(BgpCoreError) def test_update_flowspec_vrf_table_vpnv4_invalid_flowspec_family(self): flowspec_family = 'invalid' route_family = 'ipv4fs' @@ -545,16 +525,14 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'ipv4fs(dst_prefix:10.70.1.0/24)' - self._test_update_flowspec_vrf_table( - flowspec_family=flowspec_family, - route_family=route_family, - route_dist=route_dist, - rules=rules, - prefix=prefix, - is_withdraw=False, - ) + self.assertRaises(BgpCoreError, self._test_update_flowspec_vrf_table, + flowspec_family=flowspec_family, + route_family=route_family, + route_dist=route_dist, + rules=rules, + prefix=prefix, + is_withdraw=False) - @raises(BgpCoreError) def test_update_flowspec_vrf_table_vpnv4_invalid_route_family(self): flowspec_family = 'vpnv4fs' route_family = 'invalid' @@ -564,14 +542,13 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'ipv4fs(dst_prefix:10.70.1.0/24)' - self._test_update_flowspec_vrf_table( - flowspec_family=flowspec_family, - route_family=route_family, - route_dist=route_dist, - rules=rules, - prefix=prefix, - is_withdraw=False, - ) + self.assertRaises(BgpCoreError, self._test_update_flowspec_vrf_table, + flowspec_family=flowspec_family, + route_family=route_family, + route_dist=route_dist, + rules=rules, + prefix=prefix, + is_withdraw=False) @mock.patch( 'os_ken.services.protocols.bgp.core_managers.TableCoreManager.__init__', @@ -594,14 +571,14 @@ class Test_TableCoreManager(unittest.TestCase): # Check call_args_list = learn_path_mock.call_args_list - ok_(len(call_args_list) == 1) # learn_path should be called once + self.assertTrue(len(call_args_list) == 1) # learn_path should be called once args, kwargs = call_args_list[0] - ok_(len(kwargs) == 0) # no keyword argument + self.assertTrue(len(kwargs) == 0) # no keyword argument output_path = args[0] - eq_(None, output_path.source) - eq_(prefix, output_path.nlri.prefix) - eq_(None, output_path.nexthop) - eq_(is_withdraw, output_path.is_withdraw) + self.assertEqual(None, output_path.source) + self.assertEqual(prefix, output_path.nlri.prefix) + self.assertEqual(None, output_path.nexthop) + self.assertEqual(is_withdraw, output_path.is_withdraw) def test_update_flowspec_global_table_ipv4(self): flowspec_family = 'ipv4fs' @@ -638,7 +615,6 @@ class Test_TableCoreManager(unittest.TestCase): is_withdraw=False, ) - @raises(BgpCoreError) def test_update_flowspec_global_table_ipv4_invalid_actions(self): flowspec_family = 'ipv4fs' rules = { @@ -651,15 +627,14 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'ipv4fs(dst_prefix:10.60.1.0/24)' - self._test_update_flowspec_global_table( - flowspec_family=flowspec_family, - rules=rules, - prefix=prefix, - is_withdraw=False, - actions=actions, - ) + self.assertRaises(BgpCoreError, + self._test_update_flowspec_global_table, + flowspec_family=flowspec_family, + rules=rules, + prefix=prefix, + is_withdraw=False, + actions=actions) - @raises(BgpCoreError) def test_update_flowspec_global_table_ipv4_invalid_flowspec_family(self): flowspec_family = 'invalid' rules = { @@ -673,13 +648,13 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'ipv4fs(dst_prefix:10.60.1.0/24)' - self._test_update_flowspec_global_table( - flowspec_family=flowspec_family, - rules=rules, - prefix=prefix, - is_withdraw=False, - actions=actions, - ) + self.assertRaises(BgpCoreError, + self._test_update_flowspec_global_table, + flowspec_family=flowspec_family, + rules=rules, + prefix=prefix, + is_withdraw=False, + actions=actions) def test_update_flowspec_global_table_ipv6(self): flowspec_family = 'ipv6fs' @@ -716,7 +691,6 @@ class Test_TableCoreManager(unittest.TestCase): is_withdraw=False, ) - @raises(BgpCoreError) def test_update_flowspec_global_table_ipv6_invalid_actions(self): flowspec_family = 'ipv6fs' rules = { @@ -729,15 +703,14 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'ipv4fs(dst_prefix:2001::3/128/32)' - self._test_update_flowspec_global_table( - flowspec_family=flowspec_family, - rules=rules, - prefix=prefix, - is_withdraw=False, - actions=actions, - ) + self.assertRaises(BgpCoreError, + self._test_update_flowspec_global_table, + flowspec_family=flowspec_family, + rules=rules, + prefix=prefix, + is_withdraw=False, + actions=actions) - @raises(BgpCoreError) def test_update_flowspec_global_table_ipv6_invalid_flowspec_family(self): flowspec_family = 'invalid' rules = { @@ -751,13 +724,13 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'ipv4fs(dst_prefix:2001::3/128/32)' - self._test_update_flowspec_global_table( - flowspec_family=flowspec_family, - rules=rules, - prefix=prefix, - is_withdraw=False, - actions=actions, - ) + self.assertRaises(BgpCoreError, + self._test_update_flowspec_global_table, + flowspec_family=flowspec_family, + rules=rules, + prefix=prefix, + is_withdraw=False, + actions=actions) def test_update_flowspec_vrf_table_vpnv6(self): flowspec_family = 'vpnv6fs' @@ -802,7 +775,6 @@ class Test_TableCoreManager(unittest.TestCase): is_withdraw=False, ) - @raises(BgpCoreError) def test_update_flowspec_vrf_table_vpnv6_invalid_actions(self): flowspec_family = 'vpnv6fs' route_family = 'ipv6fs' @@ -817,17 +789,15 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'ipv6fs(dst_prefix:2001::3/128/32)' - self._test_update_flowspec_vrf_table( - flowspec_family=flowspec_family, - route_family=route_family, - route_dist=route_dist, - rules=rules, - prefix=prefix, - is_withdraw=False, - actions=actions, - ) + self.assertRaises(BgpCoreError, self._test_update_flowspec_vrf_table, + flowspec_family=flowspec_family, + route_family=route_family, + route_dist=route_dist, + rules=rules, + prefix=prefix, + is_withdraw=False, + actions=actions) - @raises(BgpCoreError) def test_update_flowspec_vrf_table_vpnv6_invalid_route_family(self): flowspec_family = 'vpnv6fs' route_family = 'invalid' @@ -837,14 +807,13 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'ipv4fs(dst_prefix:2001::3/128/32)' - self._test_update_flowspec_vrf_table( - flowspec_family=flowspec_family, - route_family=route_family, - route_dist=route_dist, - rules=rules, - prefix=prefix, - is_withdraw=False, - ) + self.assertRaises(BgpCoreError, self._test_update_flowspec_vrf_table, + flowspec_family=flowspec_family, + route_family=route_family, + route_dist=route_dist, + rules=rules, + prefix=prefix, + is_withdraw=False) def test_update_flowspec_vrf_table_l2vpn(self): flowspec_family = 'l2vpnfs' @@ -889,7 +858,6 @@ class Test_TableCoreManager(unittest.TestCase): is_withdraw=False, ) - @raises(BgpCoreError) def test_update_flowspec_vrf_table_l2vpn_invalid_actions(self): flowspec_family = 'l2vpnfs' route_family = 'l2vpnfs' @@ -904,17 +872,15 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'l2vpnfs(dst_mac:12:34:56:78:9a:bc)' - self._test_update_flowspec_vrf_table( - flowspec_family=flowspec_family, - route_family=route_family, - route_dist=route_dist, - rules=rules, - prefix=prefix, - is_withdraw=False, - actions=actions, - ) + self.assertRaises(BgpCoreError, self._test_update_flowspec_vrf_table, + flowspec_family=flowspec_family, + route_family=route_family, + route_dist=route_dist, + rules=rules, + prefix=prefix, + is_withdraw=False, + actions=actions) - @raises(BgpCoreError) def test_update_flowspec_vrf_table_l2vpn_invalid_route_family(self): flowspec_family = 'l2vpnfs' route_family = 'invalid' @@ -924,11 +890,10 @@ class Test_TableCoreManager(unittest.TestCase): } prefix = 'l2vpnfs(dst_mac:12:34:56:78:9a:bc)' - self._test_update_flowspec_vrf_table( - flowspec_family=flowspec_family, - route_family=route_family, - route_dist=route_dist, - rules=rules, - prefix=prefix, - is_withdraw=False, - ) + self.assertRaises(BgpCoreError, self._test_update_flowspec_vrf_table, + flowspec_family=flowspec_family, + route_family=route_family, + route_dist=route_dist, + rules=rules, + prefix=prefix, + is_withdraw=False) diff --git a/os_ken/tests/unit/services/protocols/bgp/test_bgpspeaker.py b/os_ken/tests/unit/services/protocols/bgp/test_bgpspeaker.py index 3bcf21fa..9ddd795c 100644 --- a/os_ken/tests/unit/services/protocols/bgp/test_bgpspeaker.py +++ b/os_ken/tests/unit/services/protocols/bgp/test_bgpspeaker.py @@ -17,8 +17,6 @@ import logging import unittest from unittest import mock -from nose.tools import raises - from os_ken.services.protocols.bgp import bgpspeaker from os_ken.services.protocols.bgp.bgpspeaker import EVPN_MAX_ET from os_ken.services.protocols.bgp.bgpspeaker import ESI_TYPE_LACP @@ -392,7 +390,6 @@ class Test_BGPSpeaker(unittest.TestCase): mock_call.assert_called_with( 'evpn_prefix.add_local', **expected_kwargs) - @raises(ValueError) @mock.patch('os_ken.services.protocols.bgp.bgpspeaker.BGPSpeaker.__init__', mock.MagicMock(return_value=None)) @mock.patch('os_ken.services.protocols.bgp.bgpspeaker.call') @@ -408,19 +405,14 @@ class Test_BGPSpeaker(unittest.TestCase): # Test speaker = bgpspeaker.BGPSpeaker(65000, '10.0.0.1') - speaker.evpn_prefix_add( - route_type=route_type, - route_dist=route_dist, - esi=esi, - ethernet_tag_id=ethernet_tag_id, - mac_addr=mac_addr, - ip_addr=ip_addr, - next_hop=next_hop, - ) - - # Check - mock_call.assert_called_with( - 'evpn_prefix.add_local', 'Invalid arguments detected') + self.assertRaises(ValueError, speaker.evpn_prefix_add, + route_type=route_type, + route_dist=route_dist, + esi=esi, + ethernet_tag_id=ethernet_tag_id, + mac_addr=mac_addr, + ip_addr=ip_addr, + next_hop=next_hop) @mock.patch( 'os_ken.services.protocols.bgp.bgpspeaker.BGPSpeaker.__init__', @@ -523,7 +515,6 @@ class Test_BGPSpeaker(unittest.TestCase): mock_call.assert_called_with( 'evpn_prefix.delete_local', **expected_kwargs) - @raises(ValueError) @mock.patch('os_ken.services.protocols.bgp.bgpspeaker.BGPSpeaker.__init__', mock.MagicMock(return_value=None)) @mock.patch('os_ken.services.protocols.bgp.bgpspeaker.call') @@ -538,18 +529,13 @@ class Test_BGPSpeaker(unittest.TestCase): # Test speaker = bgpspeaker.BGPSpeaker(65000, '10.0.0.1') - speaker.evpn_prefix_del( - route_type=route_type, - route_dist=route_dist, - esi=esi, - ethernet_tag_id=ethernet_tag_id, - mac_addr=mac_addr, - ip_addr=ip_addr, - ) - - # Check - mock_call.assert_called_with( - 'evpn_prefix.delete_local', 'Invalid arguments detected') + self.assertRaises(ValueError, speaker.evpn_prefix_del, + route_type=route_type, + route_dist=route_dist, + esi=esi, + ethernet_tag_id=ethernet_tag_id, + mac_addr=mac_addr, + ip_addr=ip_addr) @mock.patch( 'os_ken.services.protocols.bgp.bgpspeaker.BGPSpeaker.__init__', @@ -684,7 +670,6 @@ class Test_BGPSpeaker(unittest.TestCase): mock_call.assert_called_with( 'evpn_prefix.add_local', **expected_kwargs) - @raises(ValueError) @mock.patch( 'os_ken.services.protocols.bgp.bgpspeaker.BGPSpeaker.__init__', mock.MagicMock(return_value=None)) @@ -700,17 +685,12 @@ class Test_BGPSpeaker(unittest.TestCase): # Test speaker = bgpspeaker.BGPSpeaker(65000, '10.0.0.1') - speaker.evpn_prefix_add( - route_type=route_type, - route_dist=route_dist, - ethernet_tag_id=ethernet_tag_id, - ip_addr=ip_addr, - pmsi_tunnel_type=pmsi_tunnel_type, - ) - - # Check - mock_call.assert_called_with( - 'evpn_prefix.add_local', 'Invalid arguments detected') + self.assertRaises(ValueError, speaker.evpn_prefix_add, + route_type=route_type, + route_dist=route_dist, + ethernet_tag_id=ethernet_tag_id, + ip_addr=ip_addr, + pmsi_tunnel_type=pmsi_tunnel_type) @mock.patch( 'os_ken.services.protocols.bgp.bgpspeaker.BGPSpeaker.__init__', diff --git a/os_ken/tests/unit/services/protocols/bgp/test_peer.py b/os_ken/tests/unit/services/protocols/bgp/test_peer.py index 37bd709f..cc33c0cb 100644 --- a/os_ken/tests/unit/services/protocols/bgp/test_peer.py +++ b/os_ken/tests/unit/services/protocols/bgp/test_peer.py @@ -17,8 +17,6 @@ import logging import unittest from unittest import mock -from nose.tools import eq_ - from os_ken.lib.packet import bgp from os_ken.services.protocols.bgp import peer @@ -44,8 +42,8 @@ class Test_Peer(unittest.TestCase): output_as_path_attr = _peer._construct_as_path_attr( input_as_path_attr, input_as4_path_attr) - eq_(bgp.BGP_ATTR_TYPE_AS_PATH, output_as_path_attr.type) - eq_(expected_as_path, output_as_path_attr.path_seg_list) + self.assertEqual(bgp.BGP_ATTR_TYPE_AS_PATH, output_as_path_attr.type) + self.assertEqual(expected_as_path, output_as_path_attr.path_seg_list) def test_construct_as_path_attr_sequence_only(self): # Test Data @@ -154,8 +152,8 @@ class Test_Peer(unittest.TestCase): output_as_path_attr = _peer._construct_as_path_attr( input_as_path_attr, input_as4_path_attr) - eq_(bgp.BGP_ATTR_TYPE_AS_PATH, output_as_path_attr.type) - eq_(expected_as_path, output_as_path_attr.path_seg_list) + self.assertEqual(bgp.BGP_ATTR_TYPE_AS_PATH, output_as_path_attr.type) + self.assertEqual(expected_as_path, output_as_path_attr.path_seg_list) @mock.patch.object( peer.Peer, '__init__', mock.MagicMock(return_value=None)) @@ -167,8 +165,8 @@ class Test_Peer(unittest.TestCase): # TEST output_as_path, output_as4_path = _peer._trans_as_path(input_as_path) - eq_(expected_as_path, output_as_path) - eq_(expected_as4_path, output_as4_path) + self.assertEqual(expected_as_path, output_as_path) + self.assertEqual(expected_as4_path, output_as4_path) @mock.patch.object( peer.Peer, 'is_four_octet_as_number_cap_valid', @@ -234,11 +232,11 @@ class Test_Peer(unittest.TestCase): as4_aggregator_attr = umsg_pattrs.get( bgp.BGP_ATTR_TYPE_AS4_AGGREGATOR, None) - eq_(ex_as_path_value, as_path_attr.value) - eq_(None, as4_path_attr) - eq_(ex_aggregator_as_number, aggregator_attr.as_number) - eq_(ex_aggregator_addr, aggregator_attr.addr) - eq_(None, as4_aggregator_attr) + self.assertEqual(ex_as_path_value, as_path_attr.value) + self.assertEqual(None, as4_path_attr) + self.assertEqual(ex_aggregator_as_number, aggregator_attr.as_number) + self.assertEqual(ex_aggregator_addr, aggregator_attr.addr) + self.assertEqual(None, as4_aggregator_attr) @mock.patch.object( peer.Peer, '__init__', mock.MagicMock(return_value=None)) diff --git a/os_ken/tests/unit/services/protocols/bgp/utils/test_bgp.py b/os_ken/tests/unit/services/protocols/bgp/utils/test_bgp.py index 73345ad5..231b8b44 100644 --- a/os_ken/tests/unit/services/protocols/bgp/utils/test_bgp.py +++ b/os_ken/tests/unit/services/protocols/bgp/utils/test_bgp.py @@ -17,8 +17,6 @@ import logging import unittest -from nose.tools import eq_, raises - from os_ken.lib.packet.bgp import ( BGPFlowSpecTrafficRateCommunity, BGPFlowSpecTrafficActionCommunity, @@ -28,7 +26,6 @@ from os_ken.lib.packet.bgp import ( BGPFlowSpecTPIDActionCommunity, ) -from os_ken.services.protocols.bgp.core import BgpCoreError from os_ken.services.protocols.bgp.utils.bgp import create_v4flowspec_actions from os_ken.services.protocols.bgp.utils.bgp import create_v6flowspec_actions from os_ken.services.protocols.bgp.utils.bgp import create_l2vpnflowspec_actions @@ -46,7 +43,7 @@ class Test_Utils_BGP(unittest.TestCase): communities = create_v4flowspec_actions(actions) expected_communities.sort(key=lambda x: x.subtype) communities.sort(key=lambda x: x.subtype) - eq_(str(expected_communities), str(communities)) + self.assertEqual(str(expected_communities), str(communities)) def test_create_v4flowspec_actions_all_actions(self): actions = { @@ -78,7 +75,6 @@ class Test_Utils_BGP(unittest.TestCase): expected_communities = [] self._test_create_v4flowspec_actions(actions, expected_communities) - @raises(ValueError) def test_create_v4flowspec_actions_not_exist_actions(self): actions = { 'traffic_test': { @@ -86,13 +82,14 @@ class Test_Utils_BGP(unittest.TestCase): }, } expected_communities = [] - self._test_create_v4flowspec_actions(actions, expected_communities) + self.assertRaises(ValueError, self._test_create_v4flowspec_actions, + actions, expected_communities) def _test_create_v6flowspec_actions(self, actions, expected_communities): communities = create_v6flowspec_actions(actions) expected_communities.sort(key=lambda x: x.subtype) communities.sort(key=lambda x: x.subtype) - eq_(str(expected_communities), str(communities)) + self.assertEqual(str(expected_communities), str(communities)) def test_create_v6flowspec_actions_all_actions(self): actions = { @@ -124,7 +121,6 @@ class Test_Utils_BGP(unittest.TestCase): expected_communities = [] self._test_create_v6flowspec_actions(actions, expected_communities) - @raises(ValueError) def test_create_v6flowspec_actions_not_exist_actions(self): actions = { 'traffic_test': { @@ -132,13 +128,14 @@ class Test_Utils_BGP(unittest.TestCase): }, } expected_communities = [] - self._test_create_v6flowspec_actions(actions, expected_communities) + self.assertRaises(ValueError, self._test_create_v6flowspec_actions, + actions, expected_communities) def _test_create_l2vpnflowspec_actions(self, actions, expected_communities): communities = create_l2vpnflowspec_actions(actions) expected_communities.sort(key=lambda x: x.subtype) communities.sort(key=lambda x: x.subtype) - eq_(str(expected_communities), str(communities)) + self.assertEqual(str(expected_communities), str(communities)) def test_create_l2vpnflowspec_actions_all_actions(self): actions = { @@ -200,7 +197,6 @@ class Test_Utils_BGP(unittest.TestCase): expected_communities = [] self._test_create_l2vpnflowspec_actions(actions, expected_communities) - @raises(ValueError) def test_create_l2vpnflowspec_actions_not_exist_actions(self): actions = { 'traffic_test': { @@ -208,4 +204,5 @@ class Test_Utils_BGP(unittest.TestCase): }, } expected_communities = [] - self._test_create_l2vpnflowspec_actions(actions, expected_communities) + self.assertRaises(ValueError, self._test_create_l2vpnflowspec_actions, + actions, expected_communities) diff --git a/os_ken/tests/unit/services/protocols/bgp/utils/test_validation.py b/os_ken/tests/unit/services/protocols/bgp/utils/test_validation.py index 89a720d3..7b472bb8 100644 --- a/os_ken/tests/unit/services/protocols/bgp/utils/test_validation.py +++ b/os_ken/tests/unit/services/protocols/bgp/utils/test_validation.py @@ -16,8 +16,6 @@ import logging import unittest -from nose.tools import eq_, ok_ - from os_ken.services.protocols.bgp.utils import validation @@ -30,186 +28,199 @@ class Test_Utils_Validation(unittest.TestCase): """ def test_is_valid_mac(self): - ok_(validation.is_valid_mac('aa:bb:cc:dd:ee:ff')) + self.assertTrue(validation.is_valid_mac('aa:bb:cc:dd:ee:ff')) def test_is_valid_mac_hyphenation(self): - ok_(validation.is_valid_mac('aa-bb-cc-dd-ee-ff')) + self.assertTrue(validation.is_valid_mac('aa-bb-cc-dd-ee-ff')) def test_is_valid_mac_short(self): - eq_(False, validation.is_valid_mac('aa:bb:cc:dd:ee')) + self.assertEqual(False, validation.is_valid_mac('aa:bb:cc:dd:ee')) def test_is_valid_ip_prefix(self): - ok_(validation.is_valid_ip_prefix(24, 32)) + self.assertTrue(validation.is_valid_ip_prefix(24, 32)) def test_is_valid_ip_prefix_str(self): - ok_(validation.is_valid_ip_prefix('24', 32)) + self.assertTrue(validation.is_valid_ip_prefix('24', 32)) def test_is_valid_ip_prefix_not_digit(self): - eq_(False, validation.is_valid_ip_prefix('foo', 32)) + self.assertEqual(False, validation.is_valid_ip_prefix('foo', 32)) def test_is_valid_ip_prefix_over(self): - eq_(False, validation.is_valid_ip_prefix(100, 32)) + self.assertEqual(False, validation.is_valid_ip_prefix(100, 32)) def test_is_valid_ipv4(self): - ok_(validation.is_valid_ipv4('10.0.0.1')) + self.assertTrue(validation.is_valid_ipv4('10.0.0.1')) def test_is_valid_ipv4_not_dot(self): - eq_(False, validation.is_valid_ipv4('192:168:0:1')) + self.assertEqual(False, validation.is_valid_ipv4('192:168:0:1')) def test_is_valid_ipv4_prefix(self): - ok_(validation.is_valid_ipv4_prefix('10.0.0.1/24')) + self.assertTrue(validation.is_valid_ipv4_prefix('10.0.0.1/24')) def test_is_valid_ipv4_prefix_not_str(self): - eq_(False, validation.is_valid_ipv4_prefix(1234)) + self.assertEqual(False, validation.is_valid_ipv4_prefix(1234)) def test_is_valid_ipv4_prefix_without_prefix(self): - eq_(False, validation.is_valid_ipv4_prefix('10.0.0.1')) + self.assertEqual(False, validation.is_valid_ipv4_prefix('10.0.0.1')) def test_is_valid_ipv4_prefix_invalid_addr(self): - eq_(False, validation.is_valid_ipv4_prefix('xxx.xxx.xxx.xxx/24')) + self.assertEqual(False, + validation.is_valid_ipv4_prefix('xxx.xxx.xxx.xxx/24')) def test_is_valid_ipv6(self): - ok_(validation.is_valid_ipv6('fe80::0011:aabb:ccdd:eeff')) + self.assertTrue(validation.is_valid_ipv6('fe80::0011:aabb:ccdd:eeff')) def test_is_valid_ipv6_not_colon(self): - eq_(False, validation.is_valid_ipv6('fe80--0011-aabb-ccdd-eeff')) + self.assertEqual(False, + validation.is_valid_ipv6('fe80--0011-aabb-ccdd-eeff')) def test_is_valid_ipv6_prefix(self): - ok_(validation.is_valid_ipv6_prefix('fe80::0011:aabb:ccdd:eeff/64')) + self.assertTrue( + validation.is_valid_ipv6_prefix('fe80::0011:aabb:ccdd:eeff/64')) def test_is_valid_ipv6_prefix_not_str(self): - eq_(False, validation.is_valid_ipv6_prefix(1234)) + self.assertEqual(False, + validation.is_valid_ipv6_prefix(1234)) def test_is_valid_ipv6_prefix_without_prefix(self): - eq_(False, + self.assertEqual( + False, validation.is_valid_ipv6_prefix('fe80::0011:aabb:ccdd:eeff')) def test_is_valid_ipv6_prefix_invalid_addr(self): - eq_(False, validation.is_valid_ipv6_prefix('xxxx::xxxx/64')) + self.assertEqual(False, + validation.is_valid_ipv6_prefix('xxxx::xxxx/64')) def test_is_valid_old_asn(self): - ok_(validation.is_valid_old_asn(65000)) + self.assertTrue(validation.is_valid_old_asn(65000)) def test_is_valid_old_asn_negative(self): - eq_(False, validation.is_valid_old_asn(-1)) + self.assertEqual(False, validation.is_valid_old_asn(-1)) def test_is_valid_old_asn_over(self): - eq_(False, validation.is_valid_old_asn(0xffff + 1)) + self.assertEqual(False, validation.is_valid_old_asn(0xffff + 1)) def test_is_valid_asn(self): - ok_(validation.is_valid_asn(6553800)) + self.assertTrue(validation.is_valid_asn(6553800)) def test_is_valid_asn_old(self): - ok_(validation.is_valid_asn(65000)) + self.assertTrue(validation.is_valid_asn(65000)) def test_is_valid_asn_negative(self): - eq_(False, validation.is_valid_asn(-1)) + self.assertEqual(False, validation.is_valid_asn(-1)) def test_is_valid_asn_over(self): - eq_(False, validation.is_valid_asn(0xffffffff + 1)) + self.assertEqual(False, validation.is_valid_asn(0xffffffff + 1)) def test_is_valid_vpnv4_prefix(self): - ok_(validation.is_valid_vpnv4_prefix('100:200:10.0.0.1/24')) + self.assertTrue( + validation.is_valid_vpnv4_prefix('100:200:10.0.0.1/24')) def test_is_valid_vpnv4_prefix_not_str(self): - eq_(False, validation.is_valid_vpnv4_prefix(1234)) + self.assertEqual(False, validation.is_valid_vpnv4_prefix(1234)) def test_is_valid_vpnv4_prefix_short_rd(self): - eq_(False, validation.is_valid_vpnv4_prefix('100:10.0.0.1/24')) + self.assertEqual(False, + validation.is_valid_vpnv4_prefix('100:10.0.0.1/24')) def test_is_valid_vpnv4_prefix_invalid_rd(self): - eq_(False, validation.is_valid_vpnv4_prefix('foo:bar:10.0.0.1/24')) + self.assertEqual( + False, validation.is_valid_vpnv4_prefix('foo:bar:10.0.0.1/24')) def test_is_valid_vpnv6_prefix(self): - ok_(validation.is_valid_vpnv6_prefix( + self.assertTrue(validation.is_valid_vpnv6_prefix( '100:200:fe80::0011:aabb:ccdd:eeff/64')) def test_is_valid_vpnv6_prefix_not_str(self): - eq_(False, validation.is_valid_vpnv6_prefix(1234)) + self.assertEqual(False, validation.is_valid_vpnv6_prefix(1234)) def test_is_valid_vpnv6_prefix_short_rd(self): - eq_(False, validation.is_valid_vpnv6_prefix('100:eeff/64')) + self.assertEqual(False, + validation.is_valid_vpnv6_prefix('100:eeff/64')) def test_is_valid_vpnv6_prefix_invalid_rd(self): - eq_(False, validation.is_valid_vpnv6_prefix('foo:bar:10.0.0.1/24')) + self.assertEqual( + False, validation.is_valid_vpnv6_prefix('foo:bar:10.0.0.1/24')) def test_is_valid_med(self): - ok_(validation.is_valid_med(100)) + self.assertTrue(validation.is_valid_med(100)) def test_is_valid_med_not_num(self): - eq_(False, validation.is_valid_med('foo')) + self.assertEqual(False, validation.is_valid_med('foo')) def test_is_valid_med_negative(self): - eq_(False, validation.is_valid_med(-1)) + self.assertEqual(False, validation.is_valid_med(-1)) def test_is_valid_med_over(self): - eq_(False, validation.is_valid_med(0xffffffff + 1)) + self.assertEqual(False, validation.is_valid_med(0xffffffff + 1)) def test_is_valid_mpls_label(self): - ok_(validation.is_valid_mpls_label(100)) + self.assertTrue(validation.is_valid_mpls_label(100)) def test_is_valid_mpls_label_reserved(self): - eq_(False, validation.is_valid_mpls_label(4)) + self.assertEqual(False, validation.is_valid_mpls_label(4)) def test_is_valid_mpls_label_not_num(self): - eq_(False, validation.is_valid_mpls_label('foo')) + self.assertEqual(False, validation.is_valid_mpls_label('foo')) def test_is_valid_mpls_label_negative(self): - eq_(False, validation.is_valid_mpls_label(-1)) + self.assertEqual(False, validation.is_valid_mpls_label(-1)) def test_is_valid_mpls_label_over(self): - eq_(False, validation.is_valid_mpls_label(0x100000 + 1)) + self.assertEqual(False, validation.is_valid_mpls_label(0x100000 + 1)) def test_is_valid_mpls_labels(self): - ok_(validation.is_valid_mpls_labels([100, 200])) + self.assertTrue(validation.is_valid_mpls_labels([100, 200])) def test_is_valid_mpls_labels_not_list(self): - eq_(False, validation.is_valid_mpls_labels(100)) + self.assertEqual(False, validation.is_valid_mpls_labels(100)) def test_is_valid_mpls_labels_with_invalid_label(self): - eq_(False, validation.is_valid_mpls_labels(['foo', 200])) + self.assertEqual(False, validation.is_valid_mpls_labels(['foo', 200])) def test_is_valid_route_dist(self): - ok_(validation.is_valid_route_dist('65000:222')) + self.assertTrue(validation.is_valid_route_dist('65000:222')) def test_is_valid_route_dist_ipv4_based(self): - ok_(validation.is_valid_route_dist('10.0.0.1:333')) + self.assertTrue(validation.is_valid_route_dist('10.0.0.1:333')) def test_is_valid_route_not_str(self): - eq_(False, validation.is_valid_route_dist(65000)) + self.assertEqual(False, validation.is_valid_route_dist(65000)) def test_is_valid_route_dist_short(self): - eq_(False, validation.is_valid_route_dist('65000')) + self.assertEqual(False, validation.is_valid_route_dist('65000')) def test_is_valid_route_dist_invalid_ipv4_addr(self): - eq_(False, validation.is_valid_route_dist('xxx.xxx.xxx.xxx:333')) + self.assertEqual(False, + validation.is_valid_route_dist('xxx.xxx.xxx.xxx:333')) def test_is_valid_esi(self): - ok_(validation.is_valid_esi(100)) + self.assertTrue(validation.is_valid_esi(100)) def test_is_valid_esi_not_int(self): - eq_(False, validation.is_valid_esi('foo')) + self.assertEqual(False, validation.is_valid_esi('foo')) def test_is_valid_ethernet_tag_id(self): - ok_(validation.is_valid_ethernet_tag_id(100)) + self.assertTrue(validation.is_valid_ethernet_tag_id(100)) def test_is_valid_ethernet_tag_id_not_int(self): - eq_(False, validation.is_valid_ethernet_tag_id('foo')) + self.assertEqual(False, validation.is_valid_ethernet_tag_id('foo')) def test_is_valid_ethernet_tag_id_negative(self): - eq_(False, validation.is_valid_ethernet_tag_id(-1)) + self.assertEqual(False, validation.is_valid_ethernet_tag_id(-1)) def test_is_valid_ethernet_tag_id_over(self): - eq_(False, validation.is_valid_ethernet_tag_id(0xffffffff + 1)) + self.assertEqual(False, + validation.is_valid_ethernet_tag_id(0xffffffff + 1)) def test_is_valid_vni(self): - ok_(validation.is_valid_vni(100)) + self.assertTrue(validation.is_valid_vni(100)) def test_is_valid_vni_not_int(self): - eq_(False, validation.is_valid_vni('foo')) + self.assertEqual(False, validation.is_valid_vni('foo')) def test_is_valid_vni_negative(self): - eq_(False, validation.is_valid_vni(-1)) + self.assertEqual(False, validation.is_valid_vni(-1)) def test_is_valid_vni_over(self): - eq_(False, validation.is_valid_vni(0xffffff + 1)) + self.assertEqual(False, validation.is_valid_vni(0xffffff + 1)) diff --git a/os_ken/tests/unit/test_utils.py b/os_ken/tests/unit/test_utils.py deleted file mode 100644 index dd998f74..00000000 --- a/os_ken/tests/unit/test_utils.py +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (C) 2014 Nippon Telegraph and Telephone Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest -import logging -import six -from nose.tools import eq_ - -from os_ken import utils - -LOG = logging.getLogger(__name__) - - -class Test_utils(unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - def test_hex_array_string(self): - """ - Test hex_array() with str type. - """ - expected_result = '0x01 0x02 0x03 0x04' - data = b'\x01\x02\x03\x04' - eq_(expected_result, utils.hex_array(data)) - - def test_hex_array_bytearray(self): - """ - Test hex_array() with bytearray type. - """ - expected_result = '0x01 0x02 0x03 0x04' - data = bytearray(b'\x01\x02\x03\x04') - eq_(expected_result, utils.hex_array(data)) - - def test_hex_array_bytes(self): - """ - Test hex_array() with bytes type. (Python3 only) - """ - if six.PY2: - return - expected_result = '0x01 0x02 0x03 0x04' - data = bytes(b'\x01\x02\x03\x04') - eq_(expected_result, utils.hex_array(data)) - - def test_binary_str_string(self): - """ - Test binary_str() with str type. - """ - expected_result = '\\x01\\x02\\x03\\x04' - data = b'\x01\x02\x03\x04' - eq_(expected_result, utils.binary_str(data)) - - def test_binary_str_bytearray(self): - """ - Test binary_str() with bytearray type. - """ - expected_result = '\\x01\\x02\\x03\\x04' - data = bytearray(b'\x01\x02\x03\x04') - eq_(expected_result, utils.binary_str(data)) - - def test_binary_str_bytes(self): - """ - Test binary_str() with bytes type. (Python3 only) - """ - if six.PY2: - return - expected_result = '\\x01\\x02\\x03\\x04' - data = bytes(b'\x01\x02\x03\x04') - eq_(expected_result, utils.binary_str(data)) diff --git a/requirements.txt b/requirements.txt index 7c8857c8..b6f037ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ pbr>=2.0.0 # Apache-2.0 eventlet>=0.26.1 # MIT msgpack>=1.0.0 # RPC library, BGP speaker(net_cntl) +ncclient>=0.6.13 # Apache-2.0 netaddr>=0.7.18 # BSD oslo.config>=5.1.0 ovs>=2.8.0 # OVSDB diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index 8c281a51..00000000 --- a/run_tests.sh +++ /dev/null @@ -1,196 +0,0 @@ -#!/bin/sh - -if [ -z "${PYTHON}" ]; then - PYTHON=python3 -fi - -usage() { - echo "Usage: $0 [OPTION]..." - echo "Run OSKen's test suite(s)" - echo "" - echo " -V, --virtual-env Always use virtualenv. Install automatically if not present" - echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment" - echo " -c, --coverage Generate coverage report" - echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." - echo " -p, --pycodestyle, --pep8 Just run pycodestyle(pep8)" - echo " -P, --no-pycodestyle, --no-pep8 Don't run pycodestyle(pep8)" - echo " -l, --pylint Just run pylint" - echo " -i, --integrated Run integrated test" - echo " -v, --verbose Run verbose pylint analysis" - echo " -h, --help Print this usage message" - echo "" - echo "Note: with no options specified, the script will try to run the tests in a virtual environment," - echo " If no virtualenv is found, the script will ask if you would like to create one. If you " - echo " prefer to run tests NOT in a virtual environment, simply pass the -N option." - exit -} - -process_option() { - case "$1" in - -h|--help) usage;; - -V|--virtual-env) always_venv=1; never_venv=0;; - -N|--no-virtual-env) always_venv=0; never_venv=1;; - -f|--force) force=1;; - -p|--pycodestyle|--pep8) just_pycodestyle=1; never_venv=1; always_venv=0;; - -P|--no-pycodestyle|--no-pep8) no_pycodestyle=1;; - -l|--pylint) just_pylint=1;; - -i|--integrated) integrated=1;; - -c|--coverage) coverage=1;; - -v|--verbose) verbose=1;; - -*) noseopts="$noseopts $1";; - *) noseargs="$noseargs $1" - esac -} - -venv=.venv -with_venv=tools/with_venv.sh -always_venv=0 -never_venv=0 -just_pycodestyle=0 -no_pycodestyle=0 -just_pylint=0 -integrated=0 -force=0 -noseargs= -wrapper="" -coverage=0 -verbose=0 - -for arg in "$@"; do - process_option $arg -done - -# If enabled, tell nose to collect coverage data -if [ $coverage -eq 1 ]; then - noseopts="$noseopts --with-coverage --cover-package=os_ken" -fi - -run_tests() { - # Just run the test suites in current environment - ${wrapper} rm -f ./$PLUGIN_DIR/tests.sqlite - - if [ $verbose -eq 1 ]; then - ${wrapper} $NOSETESTS - else - ${wrapper} $NOSETESTS 2> run_tests.log - fi - # If we get some short import error right away, print the error log directly - RESULT=$? - if [ "$RESULT" -ne "0" ]; - then - ERRSIZE=`wc -l run_tests.log | awk '{print \$1}'` - if [ $verbose -eq 0 -a "$ERRSIZE" -lt "40" ]; - then - cat run_tests.log - fi - fi - return $RESULT -} - -run_pylint() { - echo "Running pylint ..." - PYLINT_OPTIONS="--rcfile=.pylintrc --output-format=parseable" - PYLINT_INCLUDE="os_ken os_ken/tests/bin/osken-client" - export PYTHONPATH=$PYTHONPATH:.os_ken - PYLINT_LOG=pylint.log - - ${wrapper} pylint $PYLINT_OPTIONS $PYLINT_INCLUDE > $PYLINT_LOG - #BASE_CMD="pylint $PYLINT_OPTIONS $PYLINT_INCLUDE > $PYLINT_LOG" - #[ $verbose -eq 1 ] && $BASE_CMD || msg_count=`$BASE_CMD | grep 'os_ken/' | wc -l` - #if [ $verbose -eq 0 ]; then - # echo "Pylint messages count: " $msg_count - #fi - export PYTHONPATH=$OLD_PYTHONPATH -} - -run_pycodestyle() { - PYCODESTYLE=$(which pycodestyle || which pep8) - if [ -z "${PYCODESTYLE}" ] - then - echo "Please install pycodestyle or pep8" - return 1 - fi - echo "Running $(basename ${PYCODESTYLE}) ..." - - PYCODESTYLE_OPTIONS="--repeat --show-source" - PYCODESTYLE_INCLUDE="os_ken setup*.py" - PYCODESTYLE_LOG=pycodestyle.log - ${wrapper} ${PYCODESTYLE} $PYCODESTYLE_OPTIONS $PYCODESTYLE_INCLUDE | tee $PYCODESTYLE_LOG -} - -run_integrated() { - echo "Running integrated test ..." - - INTEGRATED_TEST_RUNNER="./os_ken/tests/integrated/run_tests_with_ovs12.py" - sudo PYTHONPATH=. nosetests -s $INTEGRATED_TEST_RUNNER -} -#NOSETESTS="nosetests $noseopts $noseargs" -NOSETESTS="${PYTHON} ./os_ken/tests/run_tests.py $noseopts $noseargs" - -#if [ -n "$PLUGIN_DIR" ] -#then -# if ! [ -f ./$PLUGIN_DIR/run_tests.py ] -# then -# echo "Could not find run_tests.py in plugin directory $PLUGIN_DIR" -# exit 1 -# fi -#fi - -if [ $never_venv -eq 0 ] -then - # Remove the virtual environment if --force used - if [ $force -eq 1 ]; then - echo "Cleaning virtualenv..." - rm -rf ${venv} - fi - if [ -e ${venv} ]; then - wrapper="${with_venv}" - else - if [ $always_venv -eq 1 ]; then - # Automatically install the virtualenv - ${PYTHON} tools/install_venv.py - wrapper="${with_venv}" - else - echo -e "No virtual environment found...create one? (Y/n) \c" - read use_ve - if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then - # Install the virtualenv and run the test suite in it - ${PYTHON} tools/install_venv.py - wrapper=${with_venv} - fi - fi - fi -fi - -# Delete old coverage data from previous runs -if [ $coverage -eq 1 ]; then - ${wrapper} coverage erase -fi - -if [ $just_pycodestyle -eq 1 ]; then - run_pycodestyle - exit -fi -if [ $just_pylint -eq 1 ]; then - run_pylint - exit -fi - -if [ $integrated -eq 1 ]; then - run_integrated - exit -fi - -run_tests -RV=$? -if [ $no_pycodestyle -eq 0 ]; then - run_pycodestyle -fi - -if [ $coverage -eq 1 ]; then - echo "Generating coverage report in coverage.xml and covhtml/" - ${wrapper} coverage xml -i - ${wrapper} coverage html -d covhtml -i -fi - -exit $RV diff --git a/test-requirements.txt b/test-requirements.txt index 6edf030c..f895baca 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -9,6 +9,6 @@ python-subunit>=1.0.0 # Apache-2.0/BSD oslotest>=3.2.0 # Apache-2.0 stestr>=1.0.0 # Apache-2.0 testtools>=2.2.0 # MIT -nose>=1.3.7 # LGPL pycodestyle>=2.0.0 # MIT pylint==1.9.2 # GPLv2 +testscenarios>=0.4 # Apache-2.0/BSD diff --git a/tools/install_venv.py b/tools/install_venv.py deleted file mode 100644 index 29639801..00000000 --- a/tools/install_venv.py +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env python -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. -# All Rights Reserved. -# -# Copyright 2010 OpenStack LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Installation script for Quantum's development virtualenv -""" - -import os -import subprocess -import sys - - -ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) -VENV = os.path.join(ROOT, '.venv') -PIP_REQUIRES = os.path.join(ROOT, 'tools', 'pip-requires') -OPTIONAL_REQUIRES = os.path.join(ROOT, 'tools', 'optional-requires') -TEST_REQUIRES = os.path.join(ROOT, 'tools', 'test-requires') -PY_VERSION = "python%s.%s" % (sys.version_info[0], sys.version_info[1]) - -VENV_EXISTS = bool(os.path.exists(VENV)) - -def die(message, *args): - print >> sys.stderr, message % args - sys.exit(1) - - -def run_command(cmd, redirect_output=True, check_exit_code=True): - """ - Runs a command in an out-of-process shell, returning the - output of that command. Working directory is ROOT. - """ - if redirect_output: - stdout = subprocess.PIPE - else: - stdout = None - proc = subprocess.Popen(cmd, cwd=ROOT, stdout=stdout) - output = proc.communicate()[0] - if check_exit_code and proc.returncode != 0: - raise Exception('Command "%s" failed.\n%s' % (' '.join(cmd), output)) - return output - - -HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'], - check_exit_code=False).strip()) -HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'], - check_exit_code=False).strip()) - - -def check_dependencies(): - """Make sure virtualenv is in the path.""" - - if not HAS_VIRTUALENV: - raise Exception('Virtualenv not found. ' + \ - 'Try installing python-virtualenv') - print 'done.' - - -def create_virtualenv(venv=VENV, install_pip=False): - """Creates the virtual environment and installs PIP only into the - virtual environment - """ - print 'Creating venv...', - - install = ['virtualenv', '-q', venv] - run_command(install) - - print 'done.' - print 'Installing pip in virtualenv...', - if install_pip and \ - not run_command(['tools/with_venv.sh', 'easy_install', - 'pip>1.0']): - die("Failed to install pip.") - print 'done.' - - -def install_dependencies(venv=VENV): - print 'Installing dependencies with pip (this can take a while)...' - run_command(['tools/with_venv.sh', 'pip', 'install', '-r', - PIP_REQUIRES], redirect_output=False) - run_command(['tools/with_venv.sh', 'pip', 'install', '-r', - OPTIONAL_REQUIRES], redirect_output=False) - run_command(['tools/with_venv.sh', 'pip', 'install', '-r', - TEST_REQUIRES], redirect_output=False) - - # Tell the virtual env how to "import quantum" - pthfile = os.path.join(venv, "lib", PY_VERSION, "site-packages", - "quantum.pth") - f = open(pthfile, 'w') - f.write("%s\n" % ROOT) - - -def print_help(): - help = """ - Quantum development environment setup is complete. - - Quantum development uses virtualenv to track and manage Python dependencies - while in development and testing. - - To activate the Quantum virtualenv for the extent of your current shell - session you can run: - - $ source .venv/bin/activate - - Or, if you prefer, you can run commands in the virtualenv on a case by case - basis by running: - - $ tools/with_venv.sh - - Also, make test will automatically use the virtualenv. - """ - print help - - -def main(argv): - check_dependencies() - create_virtualenv() - install_dependencies() - print_help() - -if __name__ == '__main__': - main(sys.argv) diff --git a/tools/test-requires b/tools/test-requires deleted file mode 100644 index c9e6ace8..00000000 --- a/tools/test-requires +++ /dev/null @@ -1,4 +0,0 @@ -coverage>=4.0,!=4.4 -nose>=1.3.7 -pycodestyle>=2.0.0 -pylint==1.9.2 diff --git a/tox.ini b/tox.ini index fbe0c599..ca451e90 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ skipsdist = True ignore_basepython_conflict = True [testenv] -basepython = python3 +basepython = {env:TOX_PYTHON:python3} usedevelop = True setenv = VIRTUAL_ENV={envdir} @@ -17,10 +17,8 @@ deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -# TODO(hongbin): this is the way Ryu runs unit tests and we inherit -# this approach as a start. In the future, we should migrate to stestr -# for consistency with other OpenStack projects. -commands = python ./os_ken/tests/run_tests.py {posargs} +commands = + stestr run {posargs} [testenv:pep8] commands = flake8 {posargs} @@ -87,6 +85,7 @@ show-source = True # H104: Files with no code shouldn't contain any license header nor comments # H105: Don't use author tags. We use version control instead. # H201: Do not write ``except:``, use ``except Exception:`` at the very least. +# H202: assertRaises Exception too broad # H301: Do not import more than one module per line (*) # H306: Alphabetically order your imports by the full module path # H401: Docstrings should not start with a space. @@ -95,6 +94,6 @@ show-source = True # H405: Multi line docstrings should start with a one line summary followed by an empty line. # H501: Do not use ``locals()`` or ``self.__dict__`` for formatting strings # W504 line break after binary operator -ignore = E113,E123,E125,W503,E116,E128,E402,E501,E704,E722,E731,E741,F401,F403,F405,F811,F812,F821,F841,H101,H102,H104,H105,H201,H301,H306,H401,H403,H404,H405,H501,W504 +ignore = E113,E123,E125,W503,E116,E128,E402,E501,E704,E722,E731,E741,F401,F403,F405,F811,F812,F821,F841,H101,H102,H104,H105,H201,H202,H301,H306,H401,H403,H404,H405,H501,W504 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,os_ken/contrib