From a40a84f46938fc7ff3dc4a449d862690efb690d2 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Sat, 4 Aug 2018 07:11:33 +0200 Subject: Support for Python 3.7 --- src/tests/documentation.py | 24 +++++++++++++----------- src/tests/test.py | 15 +++++++++------ 2 files changed, 22 insertions(+), 17 deletions(-) (limited to 'src/tests') diff --git a/src/tests/documentation.py b/src/tests/documentation.py index b496660..35224cb 100644 --- a/src/tests/documentation.py +++ b/src/tests/documentation.py @@ -1,4 +1,16 @@ from __future__ import print_function +import sys +import threading +import time +import functools +import itertools +import collections +try: + import collections.abc as c +except ImportError: + c = collections +from decorator import (decorator, decorate, FunctionMaker, contextmanager, + dispatch_on, __version__) doc = r"""\ The ``decorator`` module @@ -6,7 +18,7 @@ The ``decorator`` module :Author: Michele Simionato :E-mail: michele.simionato@gmail.com :Version: $VERSION ($DATE) -:Supports: Python 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6 +:Supports: Python 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7 :Download page: http://pypi.python.org/pypi/decorator/$VERSION :Installation: ``pip install decorator`` :License: BSD license @@ -1363,16 +1375,6 @@ Another attribute copied from the original function is ``__qualname__``, the qualified name. This attribute was introduced in Python 3.3. """ -import sys -import threading -import time -import functools -import itertools -import collections -import collections as c -from decorator import (decorator, decorate, FunctionMaker, contextmanager, - dispatch_on, __version__) - if sys.version < '3': function_annotations = '' diff --git a/src/tests/test.py b/src/tests/test.py index b42d062..6d4d210 100644 --- a/src/tests/test.py +++ b/src/tests/test.py @@ -6,10 +6,15 @@ import decimal import inspect import functools import collections +from collections import defaultdict +try: + c = collections.abc +except AttributeError: + c = collections from decorator import dispatch_on, contextmanager, decorator try: from . import documentation as doc -except: +except ImportError: import documentation as doc @@ -23,6 +28,7 @@ def assertRaises(etype): else: raise Exception('Expected %s' % etype.__name__) + if sys.version >= '3.5': exec('''from asyncio import get_event_loop @@ -237,7 +243,6 @@ class TestSingleDispatch(unittest.TestCase): self.assertEqual(g(rnd), ("Number got rounded",)) def test_register_abc(self): - c = collections d = {"a": "b"} l = [1, 2, 3] s = set([object(), None]) @@ -348,8 +353,6 @@ class TestSingleDispatch(unittest.TestCase): self.assertEqual(g(t), "tuple") def test_mro_conflicts(self): - c = collections - @singledispatch def g(obj): return "base" @@ -410,9 +413,9 @@ class TestSingleDispatch(unittest.TestCase): # MutableMapping's bases implicit as well from defaultdict's # perspective. with assertRaises(RuntimeError): - self.assertEqual(h(c.defaultdict(lambda: 0)), "sized") + self.assertEqual(h(defaultdict(lambda: 0)), "sized") - class R(c.defaultdict): + class R(defaultdict): pass c.MutableSequence.register(R) -- cgit v1.2.1