From f443d4ea68736bfb7849f83ed054fcbd51971765 Mon Sep 17 00:00:00 2001 From: Tim Rozet Date: Wed, 6 Sep 2017 14:33:18 -0400 Subject: Adds parser tests and cleanup Adds unit testing for the common/parsers library and cleans up some of the test files syntax. Change-Id: I7ff9d7ba20b028fba410af900a0c3107a5806d8f Signed-off-by: Tim Rozet --- apex/tests/test_apex_ip_utils.py | 42 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'apex/tests/test_apex_ip_utils.py') diff --git a/apex/tests/test_apex_ip_utils.py b/apex/tests/test_apex_ip_utils.py index 04a1b2bb..eb4549d2 100644 --- a/apex/tests/test_apex_ip_utils.py +++ b/apex/tests/test_apex_ip_utils.py @@ -12,19 +12,21 @@ import re from ipaddress import IPv4Address from ipaddress import ip_network -from nose.tools import assert_equal -from nose.tools import assert_false -from nose.tools import assert_is_instance -from nose.tools import assert_raises -from nose.tools import assert_regexp_matches -from nose.tools import assert_true - -from apex.network.ip_utils import IPUtilsException -from apex.network.ip_utils import _validate_ip_range -from apex.network.ip_utils import find_gateway -from apex.network.ip_utils import get_interface -from apex.network.ip_utils import get_ip -from apex.network.ip_utils import get_ip_range +from nose.tools import ( + assert_equal, + assert_false, + assert_is_instance, + assert_raises, + assert_regexp_matches, + assert_true) + +from apex.network.ip_utils import ( + IPUtilsException, + _validate_ip_range, + find_gateway, + get_interface, + get_ip, + get_ip_range) ip4_pattern = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') ip4_range_pattern = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\d{1,' @@ -40,19 +42,19 @@ def get_default_gateway_linux(): return fields[0] -class TestIpUtils(object): +class TestIpUtils: @classmethod - def setup_class(klass): + def setup_class(cls): """This method is run once for each class before any tests are run""" - klass.iface_name = get_default_gateway_linux() - iface = get_interface(klass.iface_name) - klass.iface = iface + cls.iface_name = get_default_gateway_linux() + iface = get_interface(cls.iface_name) + cls.iface = iface @classmethod - def teardown_class(klass): + def teardown_class(cls): """This method is run once for each class _after_ all tests are run""" - def setUp(self): + def setup(self): """This method is run once before _each_ test method is executed""" def teardown(self): -- cgit 1.2.3-korg