Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop hard dependency on unittest2 #1040

Merged
merged 2 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ nose # http://nose.readthedocs.org/en/latest/
pep8 # https://github.com/jcrocholl/pep8
pyflakes # https://launchpad.net/pyflakes
coveralls # https://coveralls.io/
unittest2>=0.5.1 # https://pypi.python.org/pypi/unittest2
5 changes: 4 additions & 1 deletion tests/functional/test_core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
__author__ = "rsherman, vnitinv"

import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from jnpr.junos.exception import RpcTimeoutError

Expand Down
5 changes: 4 additions & 1 deletion tests/functional/test_table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
__author__ = "rsherman, vnitinv"

import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr

from jnpr.junos.op.routes import RouteTable
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/factory/test_to_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
__author__ = "Rick Sherman"

import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from mock import patch
import os
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/facts/test__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
__author__ = "Stacy Smith"
__credits__ = "Jeremy Schulman, Nitin Kumar"

import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
import importlib
import sys
Expand Down
17 changes: 11 additions & 6 deletions tests/unit/facts/test_swver.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
__author__ = "Stacy Smith"
__credits__ = "Jeremy Schulman, Nitin Kumar"

import unittest2 as unittest
import six
try:
import unittest2 as unittest
except:
import unittest
from nose.plugins.attrib import attr

from jnpr.junos.facts.swver import version_info, get_facts


@attr('unit')
class TestVersionInfo(unittest.TestCase):

if six.PY2:
assertCountEqual = unittest.TestCase.assertItemsEqual
def test_version_info_after_type_len_else(self):
self.assertEqual(version_info('12.1X46-D10').build, None)

def test_version_info_X_type_non_hyphenated(self):
self.assertItemsEqual(
self.assertCountEqual(
version_info('11.4X12.2'),
[('build', 2), ('major', (11, 4)), ('minor', '12'), ('type', 'X')])

def test_version_info_X_type_non_hyphenated_nobuild(self):
self.assertItemsEqual(
self.assertCountEqual(
version_info('11.4X12'),
[('build', None), ('major', (11, 4)), ('minor', '12'), ('type', 'X')])

Expand Down Expand Up @@ -61,12 +66,12 @@ def test_version_to_yaml(self):
"build: 5\nmajor: !!python/tuple\n- 11\n- 4\nminor: '7'\ntype: R\n")

def test_version_iter(self):
self.assertItemsEqual(
self.assertCountEqual(
version_info('11.4R7.5'),
[('build', 5), ('major', (11, 4)), ('minor', '7'), ('type', 'R')])

def test_version_feature_velocity(self):
self.assertItemsEqual(
self.assertCountEqual(
version_info('15.4F7.5'),
[('build', 5), ('major', (15, 4)), ('minor', '7'), ('type', 'F')])

Expand Down
5 changes: 4 additions & 1 deletion tests/unit/ofacts/test_swver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
__author__ = "Nitin Kumar, Rick Sherman"
__credits__ = "Jeremy Schulman"

import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from mock import patch, MagicMock
import os
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/test_console.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from jnpr.junos.utils.config import Config
from nose.plugins.attrib import attr
from mock import patch, MagicMock, call
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/test_decorators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr

from lxml.etree import XML
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/test_device.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from mock import MagicMock, patch, mock_open, call
import os
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/test_factcache.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from mock import patch, MagicMock, call
from jnpr.junos.exception import FactLoopError
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/transport/test_serial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from mock import MagicMock, patch
import sys
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/transport/test_tty.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import logging
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest

from nose.plugins.attrib import attr
from mock import MagicMock, patch
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/transport/test_tty_netconf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from mock import MagicMock, patch
from jnpr.junos.transport.tty_netconf import tty_netconf
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/transport/test_tty_ssh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import socket
import sys
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from mock import MagicMock, patch
from jnpr.junos.transport.tty_ssh import SSH
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/transport/test_tty_telnet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import sys
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from mock import MagicMock, patch
from jnpr.junos.transport.tty_telnet import Telnet
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/utils/test_sw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import os
import sys
from six import StringIO
import unittest2 as unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from nose.plugins.attrib import attr
from contextlib import contextmanager
from jnpr.junos import Device
Expand Down