compat: Replace (int, long) with compat.integer_types
This commit is contained in:
parent
7e2d77ce0e
commit
0c059b85b1
@ -29,6 +29,7 @@ if PY2:
|
||||
|
||||
urllib = fake_python3_urllib_module()
|
||||
|
||||
integer_types = (int, long)
|
||||
string_types = basestring
|
||||
text_type = unicode
|
||||
|
||||
@ -43,6 +44,7 @@ else:
|
||||
import _thread as thread # noqa
|
||||
import urllib # noqa
|
||||
|
||||
integer_types = (int,)
|
||||
string_types = (str,)
|
||||
text_type = str
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ def check_instances(arg, cls, msg='Expected a list of {name}, not {arg!r}'):
|
||||
|
||||
|
||||
def check_integer(arg, min=None, max=None):
|
||||
if not isinstance(arg, (int, long)):
|
||||
if not isinstance(arg, compat.integer_types):
|
||||
raise exceptions.ValidationError('Expected an integer, not %r' % arg)
|
||||
elif min is not None and arg < min:
|
||||
raise exceptions.ValidationError(
|
||||
|
||||
@ -121,7 +121,8 @@ class Integer(Field):
|
||||
def __init__(self, default=None, min=None, max=None):
|
||||
self._min = min
|
||||
self._max = max
|
||||
super(Integer, self).__init__(type=(int, long), default=default)
|
||||
super(Integer, self).__init__(
|
||||
type=compat.integer_types, default=default)
|
||||
|
||||
def validate(self, value):
|
||||
value = super(Integer, self).validate(value)
|
||||
|
||||
@ -32,6 +32,6 @@ class IsA(object):
|
||||
return str(self.klass)
|
||||
|
||||
|
||||
any_int = IsA((int, long))
|
||||
any_int = IsA(compat.integer_types)
|
||||
any_str = IsA(compat.string_types)
|
||||
any_unicode = IsA(compat.text_type)
|
||||
|
||||
@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
|
||||
from mopidy import compat
|
||||
from mopidy.core import HistoryController
|
||||
from mopidy.models import Artist, Track
|
||||
|
||||
@ -40,7 +41,7 @@ class PlaybackHistoryTest(unittest.TestCase):
|
||||
result = self.history.get_history()
|
||||
(timestamp, ref) = result[0]
|
||||
|
||||
self.assertIsInstance(timestamp, (int, long))
|
||||
self.assertIsInstance(timestamp, compat.integer_types)
|
||||
self.assertEqual(track.uri, ref.uri)
|
||||
self.assertIn(track.name, ref.name)
|
||||
for artist in track.artists:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user