diff --git a/rq/compat/__init__.py b/rq/compat/__init__.py index 9514aff..81f4aff 100644 --- a/rq/compat/__init__.py +++ b/rq/compat/__init__.py @@ -13,10 +13,9 @@ def is_python_version(*versions): return False -# functools.total_ordering is only available from Python 2.7 and 3.2 -if is_python_version((2, 7), (3, 2)): +try: from functools import total_ordering -else: +except ImportError: def total_ordering(cls): # noqa """Class decorator that fills in missing ordering methods""" convert = { @@ -36,7 +35,7 @@ else: roots = set(dir(cls)) & set(convert) if not roots: raise ValueError('must define at least one ordering operation: < > <= >=') # noqa - root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__ + root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__ for opname, opfunc in convert[root]: if opname not in roots: opfunc.__name__ = str(opname) diff --git a/tests/__init__.py b/tests/__init__.py index c916a30..eacd7a8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -6,11 +6,10 @@ import logging from redis import Redis from rq import pop_connection, push_connection -from rq.compat import is_python_version -if is_python_version((2, 7), (3, 2)): +try: import unittest -else: +except ImportError: import unittest2 as unittest # noqa diff --git a/tests/test_cli.py b/tests/test_cli.py index c306c81..c7f56af 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function, from click.testing import CliRunner from rq import get_failed_queue, Queue -from rq.compat import is_python_version from rq.job import Job from rq.cli import main from rq.cli.helpers import read_config_file, CliConfig @@ -13,9 +12,9 @@ import pytest from tests import RQTestCase from tests.fixtures import div_by_zero -if is_python_version((2, 7), (3, 2)): +try: from unittest import TestCase -else: +except ImportError: from unittest2 import TestCase # noqa