diff --git a/.travis.yml b/.travis.yml index 65de8a2953280582c6af173dcc2391a82631b4ab_LnRyYXZpcy55bWw=..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_LnRyYXZpcy55bWw= 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,43 +2,17 @@ cache: pip matrix: include: - - os: linux - dist: trusty - python: '2.6' - - os: linux - dist: trusty - python: '2.7' - - os: linux - dist: trusty - python: '3.2' - - os: linux - dist: trusty - python: '3.3' - - os: linux - dist: trusty - python: '3.4' - - os: linux - dist: trusty - python: '3.5' - - os: linux - dist: trusty - python: '3.6' - - os: linux - dist: xenial - sudo: true - python: '3.7' - - os: linux - dist: trusty - python: 'nightly' - - os: linux - dist: trusty - python: 'pypy' - - os: linux - dist: trusty - python: 'pypy3' + - python: '2.7' + - python: '3.5' + - python: '3.6' + - python: '3.7' + - python: '3.8' + - python: 'nightly' + - python: 'pypy' + - python: 'pypy3' install: - pip install codecov - pip install -r requirements.txt -r devel-requirements.txt - pip install -e . script: - PYTHONPATH=.:$PYTHONPATH python tests/__main__.py @@ -39,8 +13,7 @@ install: - pip install codecov - pip install -r requirements.txt -r devel-requirements.txt - pip install -e . script: - PYTHONPATH=.:$PYTHONPATH python tests/__main__.py - - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then (make -C docs html); fi - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then (make -C docs html); fi @@ -46,6 +19,4 @@ - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then (make -C docs html); fi - - if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then (make -C docs html); fi - - if [[ $TRAVIS_PYTHON_VERSION == '3.4' ]]; then (make -C docs html); fi - if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then (make -C docs html); fi - if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then (make -C docs html); fi - if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then (make -C docs html); fi @@ -49,6 +20,7 @@ - if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then (make -C docs html); fi - if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then (make -C docs html); fi - if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then (make -C docs html); fi + - if [[ $TRAVIS_PYTHON_VERSION == '3.8' ]]; then (make -C docs html); fi - if [[ $TRAVIS_PYTHON_VERSION == 'nightly' ]]; then (make -C docs html); fi after_success: - PYTHONPATH=.:$PYTHONPATH coverage run --omit=*test* tests/__main__.py diff --git a/CHANGES.rst b/CHANGES.rst index 65de8a2953280582c6af173dcc2391a82631b4ab_Q0hBTkdFUy5yc3Q=..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_Q0hBTkdFUy5yc3Q= 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,7 @@ - Refactor BER/CER/DER decoder into a coroutine. - The goal of this change is to make the decoder stopping on input + The goal of this change is to make the decoder yielding on input data starvation and resuming from where it stopped whenever the caller decides to try again (hopefully making sure that some more input becomes available). @@ -22,7 +22,13 @@ `StreamingDecoder` class. Previously published API is implemented as a thin wrapper on top of that ensuring backward compatibility. -Revision 0.4.8, released XX-09-2019 +Revision 0.4.9, released XX-11-2019 +----------------------------------- + +- Added support for Python 3.8. +- Removed support for EOL Pythons 2.4, 2.5, 2.6, 3.2, 3.3 and 3.4. + +Revision 0.4.8, released 16-11-2019 ----------------------------------- - Added ability of combining `SingleValueConstraint` and diff --git a/README.md b/README.md index 65de8a2953280582c6af173dcc2391a82631b4ab_UkVBRE1FLm1k..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_UkVBRE1FLm1k 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ * Standards compliant BER/CER/DER codecs * Can operate on streams of serialized data * Dumps/loads ASN.1 structures from Python types -* 100% Python, works with Python 2.4 up to Python 3.7 +* 100% Python, works with Python 2.7 and 3.5+ * MT-safe * Contributed ASN.1 compiler [Asn1ate](https://github.com/kimgr/asn1ate) diff --git a/docs/source/download.rst b/docs/source/download.rst index 65de8a2953280582c6af173dcc2391a82631b4ab_ZG9jcy9zb3VyY2UvZG93bmxvYWQucnN0..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_ZG9jcy9zb3VyY2UvZG93bmxvYWQucnN0 100644 --- a/docs/source/download.rst +++ b/docs/source/download.rst @@ -3,10 +3,7 @@ ================== The *pyasn1* library is a pure-Python package with no external -dependencies. Considering how much industrial or finance software -can be stuck with an old platform (think RHEL 5), we struggle to -maintain its compatibility back to the very pre-historic Python -(which is 2.4!). +dependencies. It works with Python 2.7 and 3.4+. The best way to obtain PyASN1 is by running `pip`: diff --git a/docs/source/pyasn1/contents.rst b/docs/source/pyasn1/contents.rst index 65de8a2953280582c6af173dcc2391a82631b4ab_ZG9jcy9zb3VyY2UvcHlhc24xL2NvbnRlbnRzLnJzdA==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_ZG9jcy9zb3VyY2UvcHlhc24xL2NvbnRlbnRzLnJzdA== 100644 --- a/docs/source/pyasn1/contents.rst +++ b/docs/source/pyasn1/contents.rst @@ -20,7 +20,7 @@ Both `pyasn1 <https://github.com/etingof/pyasn1>`_ and `pyasn1-modules <https://github.com/etingof/pyasn1-modules>`_ libraries -can be used out-of-the-box with Python versions 2.4 through 3.7. +can be used out-of-the-box with Python versions 2.7 and 3.4+. No external dependencies required. .. _pyasn1-types: diff --git a/pyasn1/__init__.py b/pyasn1/__init__.py index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL19faW5pdF9fLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_cHlhc24xL19faW5pdF9fLnB5 100644 --- a/pyasn1/__init__.py +++ b/pyasn1/__init__.py @@ -1,5 +1,5 @@ import sys # https://www.python.org/dev/peps/pep-0396/ -__version__ = '0.4.8' +__version__ = '0.4.9' @@ -5,3 +5,3 @@ -if sys.version_info[:2] < (2, 4): - raise RuntimeError('PyASN1 requires Python 2.4 or later') +if sys.version_info[:2] < (2, 7): + raise RuntimeError('PyASN1 requires Python 2.7 or later') diff --git a/pyasn1/codec/native/encoder.py b/pyasn1/codec/native/encoder.py index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL2NvZGVjL25hdGl2ZS9lbmNvZGVyLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_cHlhc24xL2NvZGVjL25hdGl2ZS9lbmNvZGVyLnB5 100644 --- a/pyasn1/codec/native/encoder.py +++ b/pyasn1/codec/native/encoder.py @@ -4,11 +4,7 @@ # Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pyasn1/license.html # -try: - from collections import OrderedDict - -except ImportError: - OrderedDict = dict +from collections import OrderedDict from pyasn1 import debug from pyasn1 import error @@ -242,8 +238,7 @@ #: of those. #: #: One exception is that instead of :py:class:`dict`, the :py:class:`OrderedDict` -#: can be produced (whenever available) to preserve ordering of the components -#: in ASN.1 SEQUENCE. +#: is used to preserve ordering of the components in ASN.1 SEQUENCE. #: #: Parameters #: ---------- diff --git a/pyasn1/compat/binary.py b/pyasn1/compat/binary.py deleted file mode 100644 index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL2NvbXBhdC9iaW5hcnkucHk=..0000000000000000000000000000000000000000 --- a/pyasn1/compat/binary.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# This file is part of pyasn1 software. -# -# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> -# License: http://snmplabs.com/pyasn1/license.html -# -from sys import version_info - -if version_info[0:2] < (2, 6): - def bin(value): - bitstring = [] - - if value > 0: - prefix = '0b' - elif value < 0: - prefix = '-0b' - value = abs(value) - else: - prefix = '0b0' - - while value: - if value & 1 == 1: - bitstring.append('1') - else: - bitstring.append('0') - - value >>= 1 - - bitstring.reverse() - - return prefix + ''.join(bitstring) -else: - bin = bin diff --git a/pyasn1/compat/calling.py b/pyasn1/compat/calling.py deleted file mode 100644 index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL2NvbXBhdC9jYWxsaW5nLnB5..0000000000000000000000000000000000000000 --- a/pyasn1/compat/calling.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# This file is part of pyasn1 software. -# -# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> -# License: http://snmplabs.com/pyasn1/license.html -# -from sys import version_info - -__all__ = ['callable'] - - -if (2, 7) < version_info[:2] < (3, 2): - import collections - - def callable(x): - return isinstance(x, collections.Callable) - -else: - - callable = callable diff --git a/pyasn1/compat/dateandtime.py b/pyasn1/compat/dateandtime.py deleted file mode 100644 index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL2NvbXBhdC9kYXRlYW5kdGltZS5weQ==..0000000000000000000000000000000000000000 --- a/pyasn1/compat/dateandtime.py +++ /dev/null @@ -1,22 +0,0 @@ -# -# This file is part of pyasn1 software. -# -# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> -# License: http://snmplabs.com/pyasn1/license.html -# -import time -from datetime import datetime -from sys import version_info - -__all__ = ['strptime'] - - -if version_info[:2] <= (2, 4): - - def strptime(text, dateFormat): - return datetime(*(time.strptime(text, dateFormat)[0:6])) - -else: - - def strptime(text, dateFormat): - return datetime.strptime(text, dateFormat) diff --git a/pyasn1/compat/integer.py b/pyasn1/compat/integer.py index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL2NvbXBhdC9pbnRlZ2VyLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_cHlhc24xL2NvbXBhdC9pbnRlZ2VyLnB5 100644 --- a/pyasn1/compat/integer.py +++ b/pyasn1/compat/integer.py @@ -5,14 +5,7 @@ # License: http://snmplabs.com/pyasn1/license.html # import sys - -try: - import platform - - implementation = platform.python_implementation() - -except (ImportError, AttributeError): - implementation = 'CPython' +import platform from pyasn1.compat.octets import oct2int, null, ensureString @@ -16,6 +9,6 @@ from pyasn1.compat.octets import oct2int, null, ensureString -if sys.version_info[0:2] < (3, 2) or implementation != 'CPython': - from binascii import a2b_hex, b2a_hex + +implementation = platform.python_implementation() @@ -21,6 +14,6 @@ - if sys.version_info[0] > 2: - long = int +if sys.version_info[0] < 3 or implementation != 'CPython': + from binascii import a2b_hex, b2a_hex def from_bytes(octets, signed=False): if not octets: diff --git a/pyasn1/compat/string.py b/pyasn1/compat/string.py deleted file mode 100644 index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL2NvbXBhdC9zdHJpbmcucHk=..0000000000000000000000000000000000000000 --- a/pyasn1/compat/string.py +++ /dev/null @@ -1,26 +0,0 @@ -# -# This file is part of pyasn1 software. -# -# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> -# License: http://snmplabs.com/pyasn1/license.html -# -from sys import version_info - -if version_info[:2] <= (2, 5): - - def partition(string, sep): - try: - a, c = string.split(sep, 1) - - except ValueError: - a, b, c = string, '', '' - - else: - b = sep - - return a, b, c - -else: - - def partition(string, sep): - return string.partition(sep) diff --git a/pyasn1/debug.py b/pyasn1/debug.py index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL2RlYnVnLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_cHlhc24xL2RlYnVnLnB5 100644 --- a/pyasn1/debug.py +++ b/pyasn1/debug.py @@ -55,16 +55,6 @@ return '<python logging>' -if hasattr(logging, 'NullHandler'): - NullHandler = logging.NullHandler - -else: - # Python 2.6 and older - class NullHandler(logging.Handler): - def emit(self, record): - pass - - class Debug(object): defaultPrinter = Printer() @@ -75,7 +65,7 @@ # route our logs to parent logger self._printer = Printer( logger=logging.getLogger(options['loggerName']), - handler=NullHandler() + handler=logging.NullHandler() ) elif 'printer' in options: diff --git a/pyasn1/type/base.py b/pyasn1/type/base.py index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL3R5cGUvYmFzZS5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_cHlhc24xL3R5cGUvYmFzZS5weQ== 100644 --- a/pyasn1/type/base.py +++ b/pyasn1/type/base.py @@ -7,7 +7,6 @@ import sys from pyasn1 import error -from pyasn1.compat import calling from pyasn1.type import constraint from pyasn1.type import tag from pyasn1.type import tagmap @@ -179,31 +178,31 @@ Any operation attempted on the *noValue* object will raise the *PyAsn1Error* exception. """ - skipMethods = set( - ('__slots__', - # attributes - '__getattribute__', - '__getattr__', - '__setattr__', - '__delattr__', - # class instance - '__class__', - '__init__', - '__del__', - '__new__', - '__repr__', - '__qualname__', - '__objclass__', - 'im_class', - '__sizeof__', - # pickle protocol - '__reduce__', - '__reduce_ex__', - '__getnewargs__', - '__getinitargs__', - '__getstate__', - '__setstate__') - ) + skipMethods = { + '__slots__', + # attributes + '__getattribute__', + '__getattr__', + '__setattr__', + '__delattr__', + # class instance + '__class__', + '__init__', + '__del__', + '__new__', + '__repr__', + '__qualname__', + '__objclass__', + 'im_class', + '__sizeof__', + # pickle protocol + '__reduce__', + '__reduce_ex__', + '__getnewargs__', + '__getinitargs__', + '__getstate__', + '__setstate__', + } _instance = None @@ -220,7 +219,7 @@ if (name not in cls.skipMethods and name.startswith('__') and name.endswith('__') and - calling.callable(getattr(typ, name)))] + callable(getattr(typ, name)))] for name in set(op_names): setattr(cls, name, getPlug(name)) diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL3R5cGUvdW5pdi5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_cHlhc24xL3R5cGUvdW5pdi5weQ== 100644 --- a/pyasn1/type/univ.py +++ b/pyasn1/type/univ.py @@ -9,7 +9,6 @@ from pyasn1 import error from pyasn1.codec.ber import eoo -from pyasn1.compat import binary from pyasn1.compat import integer from pyasn1.compat import octets from pyasn1.type import base @@ -231,9 +230,8 @@ def __ceil__(self): return math.ceil(self._value) - if sys.version_info[0:2] > (2, 5): - def __trunc__(self): - return self.clone(math.trunc(self._value)) + def __trunc__(self): + return self.clone(math.trunc(self._value)) def __lt__(self, value): return self._value < value @@ -586,7 +584,7 @@ def asBinary(self): """Get |ASN.1| value as a text string of bits. """ - binString = binary.bin(self._value)[2:] + binString = bin(self._value)[2:] return '0' * (len(self._value) - len(binString)) + binString @classmethod @@ -719,19 +717,6 @@ ) -try: - # noinspection PyStatementEffect - all - -except NameError: # Python 2.4 - # noinspection PyShadowingBuiltins - def all(iterable): - for element in iterable: - if not element: - return False - return True - - class OctetString(base.SimpleAsn1Type): """Create |ASN.1| schema or value object. @@ -1499,9 +1484,8 @@ def __ceil__(self): return self.clone(math.ceil(float(self))) - if sys.version_info[0:2] > (2, 5): - def __trunc__(self): - return self.clone(math.trunc(float(self))) + def __trunc__(self): + return self.clone(math.trunc(float(self))) def __lt__(self, value): return float(self) < value diff --git a/pyasn1/type/useful.py b/pyasn1/type/useful.py index 65de8a2953280582c6af173dcc2391a82631b4ab_cHlhc24xL3R5cGUvdXNlZnVsLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_cHlhc24xL3R5cGUvdXNlZnVsLnB5 100644 --- a/pyasn1/type/useful.py +++ b/pyasn1/type/useful.py @@ -7,8 +7,6 @@ import datetime from pyasn1 import error -from pyasn1.compat import dateandtime -from pyasn1.compat import string from pyasn1.type import char from pyasn1.type import tag from pyasn1.type import univ @@ -74,5 +72,5 @@ elif '-' in text or '+' in text: if '+' in text: - text, plusminus, tz = string.partition(text, '+') + text, plusminus, tz = text.partition('+') else: @@ -78,5 +76,5 @@ else: - text, plusminus, tz = string.partition(text, '-') + text, plusminus, tz = text.partition('-') if self._shortTZ and len(tz) == 2: tz += '00' @@ -99,5 +97,5 @@ if '.' in text or ',' in text: if '.' in text: - text, _, ms = string.partition(text, '.') + text, _, ms = text.partition('.') else: @@ -103,5 +101,5 @@ else: - text, _, ms = string.partition(text, ',') + text, _, ms = text.partition(',') try: ms = int(ms) * 1000 @@ -118,7 +116,7 @@ text += '00' try: - dt = dateandtime.strptime(text, self._yearsDigits == 4 and '%Y%m%d%H%M%S' or '%y%m%d%H%M%S') + dt = datetime.datetime.strptime(text, self._yearsDigits == 4 and '%Y%m%d%H%M%S' or '%y%m%d%H%M%S') except ValueError: raise error.PyAsn1Error('malformed datetime format %s' % self) diff --git a/setup.py b/setup.py index 65de8a2953280582c6af173dcc2391a82631b4ab_c2V0dXAucHk=..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_c2V0dXAucHk= 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ # import os import sys +import unittest classifiers = """\ Development Status :: 5 - Production/Stable @@ -20,8 +21,5 @@ Natural Language :: English Operating System :: OS Independent Programming Language :: Python :: 2 -Programming Language :: Python :: 2.4 -Programming Language :: Python :: 2.5 -Programming Language :: Python :: 2.6 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 @@ -26,8 +24,5 @@ Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 -Programming Language :: Python :: 3.2 -Programming Language :: Python :: 3.3 -Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 @@ -31,6 +26,7 @@ Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 +Programming Language :: Python :: 3.8 Topic :: Communications Topic :: Software Development :: Libraries :: Python Modules """ @@ -49,8 +45,8 @@ """) -if sys.version_info[:2] < (2, 4): - print("ERROR: this package requires Python 2.4 or later!") +if sys.version_info[:2] < (2, 7): + print("ERROR: this package requires Python 2.7 or later!") sys.exit(1) try: @@ -88,13 +84,8 @@ 'pyasn1.codec.ber', 'pyasn1.codec.cer', 'pyasn1.codec.der', - 'pyasn1.codec.native']}) - -# handle unittest discovery feature -try: - import unittest2 as unittest -except ImportError: - import unittest + 'pyasn1.codec.native'], + 'python_requires': '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*'}) class PyTest(Command): diff --git a/tests/__main__.py b/tests/__main__.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvX19tYWluX18ucHk=..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvX19tYWluX18ucHk= 100644 --- a/tests/__main__.py +++ b/tests/__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.test_debug.suite', diff --git a/tests/base.py b/tests/base.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvYmFzZS5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvYmFzZS5weQ== 100644 --- a/tests/base.py +++ b/tests/base.py @@ -4,12 +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 from pyasn1 import debug diff --git a/tests/codec/__main__.py b/tests/codec/__main__.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvX19tYWluX18ucHk=..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvX19tYWluX18ucHk= 100644 --- a/tests/codec/__main__.py +++ b/tests/codec/__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.codec.test_streaming.suite', diff --git a/tests/codec/ber/__main__.py b/tests/codec/ber/__main__.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvYmVyL19fbWFpbl9fLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvYmVyL19fbWFpbl9fLnB5 100644 --- a/tests/codec/ber/__main__.py +++ b/tests/codec/ber/__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.codec.ber.test_encoder.suite', diff --git a/tests/codec/ber/test_decoder.py b/tests/codec/ber/test_decoder.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvYmVyL3Rlc3RfZGVjb2Rlci5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvYmVyL3Rlc3RfZGVjb2Rlci5weQ== 100644 --- a/tests/codec/ber/test_decoder.py +++ b/tests/codec/ber/test_decoder.py @@ -9,4 +9,5 @@ import os import sys import tempfile +import unittest import zipfile @@ -12,9 +13,4 @@ import zipfile -try: - import unittest2 as unittest - -except ImportError: - import unittest from tests.base import BaseTestCase @@ -488,10 +484,9 @@ assert 0, 'accepted too-short real' -if sys.version_info[0:2] > (2, 5): - class UniversalStringDecoderTestCase(BaseTestCase): - def testDecoder(self): - assert decoder.decode(ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99))) == (char.UniversalString(sys.version_info[0] >= 3 and 'abc' or unicode('abc')), null) +class UniversalStringDecoderTestCase(BaseTestCase): + def testDecoder(self): + assert decoder.decode(ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99))) == (char.UniversalString(sys.version_info[0] >= 3 and 'abc' or unicode('abc')), null) class BMPStringDecoderTestCase(BaseTestCase): diff --git a/tests/codec/ber/test_encoder.py b/tests/codec/ber/test_encoder.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvYmVyL3Rlc3RfZW5jb2Rlci5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvYmVyL3Rlc3RfZW5jb2Rlci5weQ== 100644 --- a/tests/codec/ber/test_encoder.py +++ b/tests/codec/ber/test_encoder.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 @@ -433,10 +428,9 @@ ) == ints2octs((9, 7, 3, 49, 50, 51, 69, 49, 49)) -if sys.version_info[0:2] > (2, 5): - class UniversalStringEncoderTestCase(BaseTestCase): - def testEncoding(self): - assert encoder.encode(char.UniversalString(sys.version_info[0] >= 3 and 'abc' or unicode('abc'))) == ints2octs( - (28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99)), 'Incorrect encoding' +class UniversalStringEncoderTestCase(BaseTestCase): + def testEncoding(self): + assert encoder.encode(char.UniversalString(sys.version_info[0] >= 3 and 'abc' or unicode('abc'))) == ints2octs( + (28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99)), 'Incorrect encoding' @@ -441,10 +435,10 @@ - class UniversalStringEncoderWithSchemaTestCase(BaseTestCase): - def testEncoding(self): - assert encoder.encode( - sys.version_info[0] >= 3 and 'abc' or unicode('abc'), asn1Spec=char.UniversalString() - ) == ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99)), 'Incorrect encoding' +class UniversalStringEncoderWithSchemaTestCase(BaseTestCase): + def testEncoding(self): + assert encoder.encode( + sys.version_info[0] >= 3 and 'abc' or unicode('abc'), asn1Spec=char.UniversalString() + ) == ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99)), 'Incorrect encoding' class BMPStringEncoderTestCase(BaseTestCase): diff --git a/tests/codec/cer/__main__.py b/tests/codec/cer/__main__.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvY2VyL19fbWFpbl9fLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvY2VyL19fbWFpbl9fLnB5 100644 --- a/tests/codec/cer/__main__.py +++ b/tests/codec/cer/__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.codec.cer.test_encoder.suite', diff --git a/tests/codec/cer/test_decoder.py b/tests/codec/cer/test_decoder.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvY2VyL3Rlc3RfZGVjb2Rlci5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvY2VyL3Rlc3RfZGVjb2Rlci5weQ== 100644 --- a/tests/codec/cer/test_decoder.py +++ b/tests/codec/cer/test_decoder.py @@ -5,11 +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/codec/cer/test_encoder.py b/tests/codec/cer/test_encoder.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvY2VyL3Rlc3RfZW5jb2Rlci5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvY2VyL3Rlc3RfZW5jb2Rlci5weQ== 100644 --- a/tests/codec/cer/test_encoder.py +++ b/tests/codec/cer/test_encoder.py @@ -5,11 +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/codec/der/__main__.py b/tests/codec/der/__main__.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvZGVyL19fbWFpbl9fLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvZGVyL19fbWFpbl9fLnB5 100644 --- a/tests/codec/der/__main__.py +++ b/tests/codec/der/__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.codec.der.test_encoder.suite', diff --git a/tests/codec/der/test_decoder.py b/tests/codec/der/test_decoder.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvZGVyL3Rlc3RfZGVjb2Rlci5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvZGVyL3Rlc3RfZGVjb2Rlci5weQ== 100644 --- a/tests/codec/der/test_decoder.py +++ b/tests/codec/der/test_decoder.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/codec/der/test_encoder.py b/tests/codec/der/test_encoder.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvZGVyL3Rlc3RfZW5jb2Rlci5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvZGVyL3Rlc3RfZW5jb2Rlci5weQ== 100644 --- a/tests/codec/der/test_encoder.py +++ b/tests/codec/der/test_encoder.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/codec/native/__main__.py b/tests/codec/native/__main__.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvbmF0aXZlL19fbWFpbl9fLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvbmF0aXZlL19fbWFpbl9fLnB5 100644 --- a/tests/codec/native/__main__.py +++ b/tests/codec/native/__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.codec.native.test_encoder.suite', diff --git a/tests/codec/native/test_decoder.py b/tests/codec/native/test_decoder.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvbmF0aXZlL3Rlc3RfZGVjb2Rlci5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvbmF0aXZlL3Rlc3RfZGVjb2Rlci5weQ== 100644 --- a/tests/codec/native/test_decoder.py +++ b/tests/codec/native/test_decoder.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/codec/native/test_encoder.py b/tests/codec/native/test_encoder.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29kZWMvbmF0aXZlL3Rlc3RfZW5jb2Rlci5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29kZWMvbmF0aXZlL3Rlc3RfZW5jb2Rlci5weQ== 100644 --- a/tests/codec/native/test_encoder.py +++ b/tests/codec/native/test_encoder.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/compat/__main__.py b/tests/compat/__main__.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29tcGF0L19fbWFpbl9fLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29tcGF0L19fbWFpbl9fLnB5 100644 --- a/tests/compat/__main__.py +++ b/tests/compat/__main__.py @@ -4,10 +4,6 @@ # 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( @@ -12,7 +8,6 @@ suite = unittest.TestLoader().loadTestsFromNames( - ['tests.compat.test_binary.suite', - 'tests.compat.test_integer.suite', + ['tests.compat.test_integer.suite', 'tests.compat.test_octets.suite'] ) diff --git a/tests/compat/test_binary.py b/tests/compat/test_binary.py deleted file mode 100644 index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29tcGF0L3Rlc3RfYmluYXJ5LnB5..0000000000000000000000000000000000000000 --- a/tests/compat/test_binary.py +++ /dev/null @@ -1,56 +0,0 @@ -# -# This file is part of pyasn1 software. -# -# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> -# License: http://snmplabs.com/pyasn1/license.html -# -import sys - -try: - import unittest2 as unittest -except ImportError: - import unittest - -from tests.base import BaseTestCase - -from pyasn1.compat import binary - - -class BinaryTestCase(BaseTestCase): - - def test_bin_zero(self): - assert '0b0' == binary.bin(0) - - - def test_bin_noarg(self): - try: - binary.bin() - - except TypeError: - pass - - except: - assert 0, 'bin() tolerates no arguments' - - - def test_bin_allones(self): - assert '0b1111111111111111111111111111111111111111111111111111111111111111' == binary.bin(0xffffffffffffffff) - - - def test_bin_allzeros(self): - assert '0b0' == binary.bin(0x0000000) - - - - def test_bin_pos(self): - assert '0b1000000010000000100000001' == binary.bin(0x01010101) - - - def test_bin_neg(self): - assert '-0b1000000010000000100000001' == binary.bin(-0x01010101) - - -suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__]) - -if __name__ == '__main__': - unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/tests/compat/test_integer.py b/tests/compat/test_integer.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29tcGF0L3Rlc3RfaW50ZWdlci5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29tcGF0L3Rlc3RfaW50ZWdlci5weQ== 100644 --- a/tests/compat/test_integer.py +++ b/tests/compat/test_integer.py @@ -5,11 +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/compat/test_octets.py b/tests/compat/test_octets.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvY29tcGF0L3Rlc3Rfb2N0ZXRzLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvY29tcGF0L3Rlc3Rfb2N0ZXRzLnB5 100644 --- a/tests/compat/test_octets.py +++ b/tests/compat/test_octets.py @@ -5,11 +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/test_debug.py b/tests/test_debug.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdGVzdF9kZWJ1Zy5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdGVzdF9kZWJ1Zy5weQ== 100644 --- a/tests/test_debug.py +++ b/tests/test_debug.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/__main__.py b/tests/type/__main__.py index 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdHlwZS9fX21haW5fXy5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdHlwZS9fX21haW5fXy5weQ== 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 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdHlwZS90ZXN0X2NoYXIucHk=..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdHlwZS90ZXN0X2NoYXIucHk= 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 @@ 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 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdHlwZS90ZXN0X2NvbnN0cmFpbnQucHk=..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdHlwZS90ZXN0X2NvbnN0cmFpbnQucHk= 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 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdHlwZS90ZXN0X25hbWVkdHlwZS5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdHlwZS90ZXN0X25hbWVkdHlwZS5weQ== 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 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdHlwZS90ZXN0X25hbWVkdmFsLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdHlwZS90ZXN0X25hbWVkdmFsLnB5 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 @@ 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 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdHlwZS90ZXN0X29wZW50eXBlLnB5..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdHlwZS90ZXN0X29wZW50eXBlLnB5 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 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdHlwZS90ZXN0X3RhZy5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdHlwZS90ZXN0X3RhZy5weQ== 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 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdHlwZS90ZXN0X3VuaXYucHk=..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdHlwZS90ZXN0X3VuaXYucHk= 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,13 +143,8 @@ 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' @@ -157,12 +147,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 65de8a2953280582c6af173dcc2391a82631b4ab_dGVzdHMvdHlwZS90ZXN0X3VzZWZ1bC5weQ==..a3aeaf68c824374fa4b250f11c9e75f7e56dc5c8_dGVzdHMvdHlwZS90ZXN0X3VzZWZ1bC5weQ== 100644 --- a/tests/type/test_useful.py +++ b/tests/type/test_useful.py @@ -8,12 +8,7 @@ import pickle import sys from copy import deepcopy - -try: - import unittest2 as unittest - -except ImportError: - import unittest +import unittest from tests.base import BaseTestCase