summaryrefslogtreecommitdiff
path: root/tests/type
diff options
context:
space:
mode:
Diffstat (limited to 'tests/type')
-rw-r--r--tests/type/__main__.py6
-rw-r--r--tests/type/test_char.py12
-rw-r--r--tests/type/test_constraint.py7
-rw-r--r--tests/type/test_namedtype.py7
-rw-r--r--tests/type/test_namedval.py15
-rw-r--r--tests/type/test_opentype.py7
-rw-r--r--tests/type/test_tag.py7
-rw-r--r--tests/type/test_univ.py49
-rw-r--r--tests/type/test_useful.py7
9 files changed, 24 insertions, 93 deletions
diff --git a/tests/type/__main__.py b/tests/type/__main__.py
index fcc66e7..d6f44e6 100644
--- a/tests/type/__main__.py
+++ b/tests/type/__main__.py
@@ -4,11 +4,7 @@
# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
-try:
- import unittest2 as unittest
-
-except ImportError:
- import unittest
+import unittest
suite = unittest.TestLoader().loadTestsFromNames(
['tests.type.test_constraint.suite',
diff --git a/tests/type/test_char.py b/tests/type/test_char.py
index 8540a3e..e2fac73 100644
--- a/tests/type/test_char.py
+++ b/tests/type/test_char.py
@@ -6,12 +6,7 @@
#
import pickle
import sys
-
-try:
- import unittest2 as unittest
-
-except ImportError:
- import unittest
+import unittest
from tests.base import BaseTestCase
@@ -111,9 +106,8 @@ class AbstractStringTestCase(object):
assert self.pythonString in self.asn1String
assert self.pythonString + self.pythonString not in self.asn1String
- if sys.version_info[:2] > (2, 4):
- def testReverse(self):
- assert list(reversed(self.asn1String)) == list(reversed(self.pythonString))
+ def testReverse(self):
+ assert list(reversed(self.asn1String)) == list(reversed(self.pythonString))
def testSchemaPickling(self):
old_asn1 = self.asn1Type()
diff --git a/tests/type/test_constraint.py b/tests/type/test_constraint.py
index 7ef6293..8a88731 100644
--- a/tests/type/test_constraint.py
+++ b/tests/type/test_constraint.py
@@ -5,12 +5,7 @@
# License: http://snmplabs.com/pyasn1/license.html
#
import sys
-
-try:
- import unittest2 as unittest
-
-except ImportError:
- import unittest
+import unittest
from tests.base import BaseTestCase
diff --git a/tests/type/test_namedtype.py b/tests/type/test_namedtype.py
index 7cff45e..e2ab60b 100644
--- a/tests/type/test_namedtype.py
+++ b/tests/type/test_namedtype.py
@@ -5,12 +5,7 @@
# License: http://snmplabs.com/pyasn1/license.html
#
import sys
-
-try:
- import unittest2 as unittest
-
-except ImportError:
- import unittest
+import unittest
from tests.base import BaseTestCase
diff --git a/tests/type/test_namedval.py b/tests/type/test_namedval.py
index 4ac08cf..eae6b4d 100644
--- a/tests/type/test_namedval.py
+++ b/tests/type/test_namedval.py
@@ -5,12 +5,7 @@
# License: http://snmplabs.com/pyasn1/license.html
#
import sys
-
-try:
- import unittest2 as unittest
-
-except ImportError:
- import unittest
+import unittest
from tests.base import BaseTestCase
@@ -23,10 +18,10 @@ class NamedValuesCaseBase(BaseTestCase):
self.e = namedval.NamedValues(('off', 0), ('on', 1))
def testDict(self):
- assert set(self.e.items()) == set([('off', 0), ('on', 1)])
- assert set(self.e.keys()) == set(['off', 'on'])
- assert set(self.e) == set(['off', 'on'])
- assert set(self.e.values()) == set([0, 1])
+ assert set(self.e.items()) == {('off', 0), ('on', 1)}
+ assert set(self.e.keys()) == {'off', 'on'}
+ assert set(self.e) == {'off', 'on'}
+ assert set(self.e.values()) == {0, 1}
assert 'on' in self.e and 'off' in self.e and 'xxx' not in self.e
assert 0 in self.e and 1 in self.e and 2 not in self.e
diff --git a/tests/type/test_opentype.py b/tests/type/test_opentype.py
index ff6788f..a3efbf0 100644
--- a/tests/type/test_opentype.py
+++ b/tests/type/test_opentype.py
@@ -5,12 +5,7 @@
# License: http://snmplabs.com/pyasn1/license.html
#
import sys
-
-try:
- import unittest2 as unittest
-
-except ImportError:
- import unittest
+import unittest
from tests.base import BaseTestCase
diff --git a/tests/type/test_tag.py b/tests/type/test_tag.py
index e8dd7a3..7e8f694 100644
--- a/tests/type/test_tag.py
+++ b/tests/type/test_tag.py
@@ -5,12 +5,7 @@
# License: http://snmplabs.com/pyasn1/license.html
#
import sys
-
-try:
- import unittest2 as unittest
-
-except ImportError:
- import unittest
+import unittest
from tests.base import BaseTestCase
diff --git a/tests/type/test_univ.py b/tests/type/test_univ.py
index 124e5e9..04923bb 100644
--- a/tests/type/test_univ.py
+++ b/tests/type/test_univ.py
@@ -7,12 +7,7 @@
import math
import pickle
import sys
-
-try:
- import unittest2 as unittest
-
-except ImportError:
- import unittest
+import unittest
from tests.base import BaseTestCase
@@ -148,21 +143,11 @@ class NoValueTestCase(BaseTestCase):
def testSizeOf(self):
try:
- if hasattr(sys, 'getsizeof'):
- sys.getsizeof(univ.noValue)
-
- # TODO: remove when Py2.5 support is gone
- elif sys.version_info > (2, 6):
- raise unittest.SkipTest("no sys.getsizeof() method")
+ sys.getsizeof(univ.noValue)
except PyAsn1Error:
assert False, 'sizeof failed for NoValue object'
- except TypeError:
- # TODO: remove when Py2.5 support is gone
- if sys.version_info > (2, 6):
- raise unittest.SkipTest("sys.getsizeof() raises TypeError")
-
class IntegerTestCase(BaseTestCase):
def testStr(self):
@@ -278,9 +263,8 @@ class IntegerTestCase(BaseTestCase):
def testCeil(self):
assert math.ceil(univ.Integer(1)) == 1, '__ceil__() fails'
- if sys.version_info[0:2] > (2, 5):
- def testTrunc(self):
- assert math.trunc(univ.Integer(1)) == 1, '__trunc__() fails'
+ def testTrunc(self):
+ assert math.trunc(univ.Integer(1)) == 1, '__trunc__() fails'
def testPrettyIn(self):
assert univ.Integer('3') == 3, 'prettyIn() fails'
@@ -437,9 +421,8 @@ class BitStringTestCase(BaseTestCase):
assert self.b.clone("'A98A'H")[1] == 0
assert self.b.clone("'A98A'H")[2] == 1
- if sys.version_info[:2] > (2, 4):
- def testReverse(self):
- assert list(reversed(univ.BitString([0, 0, 1]))) == list(univ.BitString([1, 0, 0]))
+ def testReverse(self):
+ assert list(reversed(univ.BitString([0, 0, 1]))) == list(univ.BitString([1, 0, 0]))
def testAsOctets(self):
assert self.b.clone(hexValue='A98A').asOctets() == ints2octs((0xa9, 0x8a)), 'testAsOctets() fails'
@@ -539,9 +522,8 @@ class OctetStringWithUnicodeMixIn(object):
assert self.encodedPythonString in s
assert self.encodedPythonString * 2 not in s
- if sys.version_info[:2] > (2, 4):
- def testReverse(self):
- assert list(reversed(univ.OctetString(self.encodedPythonString))) == list(reversed(self.encodedPythonString))
+ def testReverse(self):
+ assert list(reversed(univ.OctetString(self.encodedPythonString))) == list(reversed(self.encodedPythonString))
class OctetStringWithAsciiTestCase(OctetStringWithUnicodeMixIn, BaseTestCase):
@@ -565,11 +547,6 @@ class OctetStringUnicodeErrorTestCase(BaseTestCase):
except PyAsn1UnicodeEncodeError:
pass
- # TODO: remove when Py2.5 support is gone
- else:
- if sys.version_info > (2, 6):
- assert False, 'Unicode encoding error not caught'
-
def testDecodeError(self):
serialized = ints2octs((0xff, 0xfe))
@@ -585,11 +562,6 @@ class OctetStringUnicodeErrorTestCase(BaseTestCase):
except PyAsn1UnicodeDecodeError:
pass
- # TODO: remove when Py2.5 support is gone
- else:
- if sys.version_info > (2, 6):
- assert False, 'Unicode decoding error not caught'
-
class OctetStringWithUtf8TestCase(OctetStringWithUnicodeMixIn, BaseTestCase):
initializer = (208, 176, 208, 177, 208, 178)
@@ -860,9 +832,8 @@ class RealTestCase(BaseTestCase):
def testCeil(self):
assert math.ceil(univ.Real(1.2)) == 2.0, '__ceil__() fails'
- if sys.version_info[0:2] > (2, 5):
- def testTrunc(self):
- assert math.trunc(univ.Real(1.1)) == 1.0, '__trunc__() fails'
+ def testTrunc(self):
+ assert math.trunc(univ.Real(1.1)) == 1.0, '__trunc__() fails'
def testTag(self):
assert univ.Real().tagSet == tag.TagSet(
diff --git a/tests/type/test_useful.py b/tests/type/test_useful.py
index 8a5ab30..5078232 100644
--- a/tests/type/test_useful.py
+++ b/tests/type/test_useful.py
@@ -8,12 +8,7 @@ import datetime
import pickle
import sys
from copy import deepcopy
-
-try:
- import unittest2 as unittest
-
-except ImportError:
- import unittest
+import unittest
from tests.base import BaseTestCase