Skip to content

Commit

Permalink
[1.6.x] Replaced "not PY3" by "PY2", new in six 1.4.0.
Browse files Browse the repository at this point in the history
Conflicts:
	django/db/backends/oracle/base.py
	django/db/backends/sqlite3/base.py
	django/db/models/base.py

Backport of 365c3e8 from master.
  • Loading branch information
aaugustin committed Sep 3, 2013
1 parent 5001257 commit 1153180
Show file tree
Hide file tree
Showing 27 changed files with 48 additions and 50 deletions.
2 changes: 1 addition & 1 deletion django/contrib/auth/management/__init__.py
Expand Up @@ -141,7 +141,7 @@ def get_system_username():
# if there is no corresponding entry in the /etc/passwd file # if there is no corresponding entry in the /etc/passwd file
# (a very restricted chroot environment, for example). # (a very restricted chroot environment, for example).
return '' return ''
if not six.PY3: if six.PY2:
try: try:
result = result.decode(DEFAULT_LOCALE_ENCODING) result = result.decode(DEFAULT_LOCALE_ENCODING)
except UnicodeDecodeError: except UnicodeDecodeError:
Expand Down
4 changes: 2 additions & 2 deletions django/contrib/auth/tests/test_basic.py
Expand Up @@ -16,7 +16,7 @@
from django.test.utils import override_settings from django.test.utils import override_settings
from django.utils import translation from django.utils import translation
from django.utils.encoding import force_str from django.utils.encoding import force_str
from django.utils.six import binary_type, PY3, StringIO from django.utils.six import binary_type, PY2, StringIO




@receiver(setting_changed) @receiver(setting_changed)
Expand All @@ -39,7 +39,7 @@ def wrapped(*args):
class mock_getpass: class mock_getpass:
@staticmethod @staticmethod
def getpass(prompt=b'Password: ', stream=None): def getpass(prompt=b'Password: ', stream=None):
if not PY3: if PY2:
# getpass on Windows only supports prompt as bytestring (#19807) # getpass on Windows only supports prompt as bytestring (#19807)
assert isinstance(prompt, binary_type) assert isinstance(prompt, binary_type)
return inputs['password'] return inputs['password']
Expand Down
2 changes: 1 addition & 1 deletion django/core/mail/message.py
Expand Up @@ -322,7 +322,7 @@ def _create_attachment(self, filename, content, mimetype=None):
try: try:
filename.encode('ascii') filename.encode('ascii')
except UnicodeEncodeError: except UnicodeEncodeError:
if not six.PY3: if six.PY2:
filename = filename.encode('utf-8') filename = filename.encode('utf-8')
filename = ('utf-8', '', filename) filename = ('utf-8', '', filename)
attachment.add_header('Content-Disposition', 'attachment', attachment.add_header('Content-Disposition', 'attachment',
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/mysql/base.py
Expand Up @@ -409,7 +409,7 @@ def get_connection_params(self):
'conv': django_conversions, 'conv': django_conversions,
'charset': 'utf8', 'charset': 'utf8',
} }
if not six.PY3: if six.PY2:
kwargs['use_unicode'] = True kwargs['use_unicode'] = True
settings_dict = self.settings_dict settings_dict = self.settings_dict
if settings_dict['USER']: if settings_dict['USER']:
Expand Down
10 changes: 5 additions & 5 deletions django/db/backends/oracle/base.py
Expand Up @@ -267,7 +267,7 @@ def last_executed_query(self, cursor, sql, params):
# http://cx-oracle.sourceforge.net/html/cursor.html#Cursor.statement # http://cx-oracle.sourceforge.net/html/cursor.html#Cursor.statement
# The DB API definition does not define this attribute. # The DB API definition does not define this attribute.
statement = cursor.statement statement = cursor.statement
if statement and not six.PY3 and not isinstance(statement, unicode): if statement and six.PY2 and not isinstance(statement, unicode):
statement = statement.decode('utf-8') statement = statement.decode('utf-8')
# Unlike Psycopg's `query` and MySQLdb`'s `_last_executed`, CxOracle's # Unlike Psycopg's `query` and MySQLdb`'s `_last_executed`, CxOracle's
# `statement` doesn't contain the query parameters. refs #20010. # `statement` doesn't contain the query parameters. refs #20010.
Expand Down Expand Up @@ -576,7 +576,7 @@ def init_connection_state(self):
cursor.execute("SELECT 1 FROM DUAL WHERE DUMMY %s" cursor.execute("SELECT 1 FROM DUAL WHERE DUMMY %s"
% self._standard_operators['contains'], % self._standard_operators['contains'],
['X']) ['X'])
except DatabaseError: except DatabaseError:
self.operators = self._likec_operators self.operators = self._likec_operators
else: else:
self.operators = self._standard_operators self.operators = self._standard_operators
Expand Down Expand Up @@ -778,7 +778,7 @@ def _guess_input_sizes(self, params_list):
for i, value in enumerate(params): for i, value in enumerate(params):
if value.input_size: if value.input_size:
sizes[i] = value.input_size sizes[i] = value.input_size
self.setinputsizes(*sizes) self.setinputsizes(*sizes)


def _param_generator(self, params): def _param_generator(self, params):
# Try dict handling; if that fails, treat as sequence # Try dict handling; if that fails, treat as sequence
Expand Down Expand Up @@ -806,7 +806,7 @@ def _fix_for_params(self, query, params):
args = [(':arg%d' % i) for i in range(len(params))] args = [(':arg%d' % i) for i in range(len(params))]
query = convert_unicode(query % tuple(args), self.charset) query = convert_unicode(query % tuple(args), self.charset)
return query, self._format_params(params) return query, self._format_params(params)

def execute(self, query, params=None): def execute(self, query, params=None):
query, params = self._fix_for_params(query, params) query, params = self._fix_for_params(query, params)
self._guess_input_sizes([params]) self._guess_input_sizes([params])
Expand All @@ -825,7 +825,7 @@ def executemany(self, query, params=None):
# uniform treatment for sequences and iterables # uniform treatment for sequences and iterables
params_iter = iter(params) params_iter = iter(params)
query, firstparams = self._fix_for_params(query, next(params_iter)) query, firstparams = self._fix_for_params(query, next(params_iter))
# we build a list of formatted params; as we're going to traverse it # we build a list of formatted params; as we're going to traverse it
# more than once, we can't make it lazy by using a generator # more than once, we can't make it lazy by using a generator
formatted = [firstparams]+[self._format_params(p) for p in params_iter] formatted = [firstparams]+[self._format_params(p) for p in params_iter]
self._guess_input_sizes(formatted) self._guess_input_sizes(formatted)
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/sqlite3/base.py
Expand Up @@ -78,7 +78,7 @@ def decoder(conv_func):


Database.register_adapter(datetime.datetime, adapt_datetime_with_timezone_support) Database.register_adapter(datetime.datetime, adapt_datetime_with_timezone_support)
Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal) Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal)
if not six.PY3 and Database.version_info >= (2, 4, 1): if six.PY2 and Database.version_info >= (2, 4, 1):
# Starting in 2.4.1, the str type is not accepted anymore, therefore, # Starting in 2.4.1, the str type is not accepted anymore, therefore,
# we convert all str objects to Unicode # we convert all str objects to Unicode
# As registering a adapter for a primitive type causes a small # As registering a adapter for a primitive type causes a small
Expand Down
2 changes: 1 addition & 1 deletion django/db/models/base.py
Expand Up @@ -426,7 +426,7 @@ def __repr__(self):
return force_str('<%s: %s>' % (self.__class__.__name__, u)) return force_str('<%s: %s>' % (self.__class__.__name__, u))


def __str__(self): def __str__(self):
if not six.PY3 and hasattr(self, '__unicode__'): if six.PY2 and hasattr(self, '__unicode__'):
if type(self).__unicode__ == Model.__str__: if type(self).__unicode__ == Model.__str__:
klass_name = type(self).__name__ klass_name = type(self).__name__
raise RuntimeError("%s.__unicode__ is aliased to __str__. Did" raise RuntimeError("%s.__unicode__ is aliased to __str__. Did"
Expand Down
2 changes: 1 addition & 1 deletion django/http/cookie.py
Expand Up @@ -49,7 +49,7 @@ def value_encode(self, val):
if not _cookie_allows_colon_in_names: if not _cookie_allows_colon_in_names:
def load(self, rawdata): def load(self, rawdata):
self.bad_cookies = set() self.bad_cookies = set()
if not six.PY3 and isinstance(rawdata, six.text_type): if six.PY2 and isinstance(rawdata, six.text_type):
rawdata = force_str(rawdata) rawdata = force_str(rawdata)
super(SimpleCookie, self).load(rawdata) super(SimpleCookie, self).load(rawdata)
for key in self.bad_cookies: for key in self.bad_cookies:
Expand Down
4 changes: 2 additions & 2 deletions django/template/loaders/app_directories.py
Expand Up @@ -15,7 +15,7 @@
from django.utils import six from django.utils import six


# At compile time, cache the directories to search. # At compile time, cache the directories to search.
if not six.PY3: if six.PY2:
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
app_template_dirs = [] app_template_dirs = []
for app in settings.INSTALLED_APPS: for app in settings.INSTALLED_APPS:
Expand All @@ -25,7 +25,7 @@
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0])) raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates') template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
if os.path.isdir(template_dir): if os.path.isdir(template_dir):
if not six.PY3: if six.PY2:
template_dir = template_dir.decode(fs_encoding) template_dir = template_dir.decode(fs_encoding)
app_template_dirs.append(template_dir) app_template_dirs.append(template_dir)


Expand Down
2 changes: 1 addition & 1 deletion django/template/loaders/eggs.py
Expand Up @@ -27,7 +27,7 @@ def load_template_source(self, template_name, template_dirs=None):
resource = resource_string(app, pkg_name) resource = resource_string(app, pkg_name)
except Exception: except Exception:
continue continue
if not six.PY3: if six.PY2:
resource = resource.decode(settings.FILE_CHARSET) resource = resource.decode(settings.FILE_CHARSET)
return (resource, 'egg:%s:%s' % (app, pkg_name)) return (resource, 'egg:%s:%s' % (app, pkg_name))
raise TemplateDoesNotExist(template_name) raise TemplateDoesNotExist(template_name)
6 changes: 3 additions & 3 deletions django/utils/_os.py
Expand Up @@ -12,7 +12,7 @@
class WindowsError(Exception): class WindowsError(Exception):
pass pass


if not six.PY3: if six.PY2:
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()




Expand All @@ -38,7 +38,7 @@ def upath(path):
""" """
Always return a unicode path. Always return a unicode path.
""" """
if not six.PY3 and not isinstance(path, six.text_type): if six.PY2 and not isinstance(path, six.text_type):
return path.decode(fs_encoding) return path.decode(fs_encoding)
return path return path


Expand All @@ -47,7 +47,7 @@ def npath(path):
Always return a native path, that is unicode on Python 3 and bytestring on Always return a native path, that is unicode on Python 3 and bytestring on
Python 2. Python 2.
""" """
if not six.PY3 and not isinstance(path, bytes): if six.PY2 and not isinstance(path, bytes):
return path.encode(fs_encoding) return path.encode(fs_encoding)
return path return path


Expand Down
2 changes: 1 addition & 1 deletion django/utils/encoding.py
Expand Up @@ -54,7 +54,7 @@ def python_2_unicode_compatible(klass):
To support Python 2 and 3 with a single code base, define a __str__ method To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class. returning text and apply this decorator to the class.
""" """
if not six.PY3: if six.PY2:
klass.__unicode__ = klass.__str__ klass.__unicode__ = klass.__str__
klass.__str__ = lambda self: self.__unicode__().encode('utf-8') klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
return klass return klass
Expand Down
4 changes: 2 additions & 2 deletions django/utils/feedgenerator.py
Expand Up @@ -46,7 +46,7 @@ def rfc2822_date(date):
dow = days[date.weekday()] dow = days[date.weekday()]
month = months[date.month - 1] month = months[date.month - 1]
time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month)) time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month))
if not six.PY3: # strftime returns a byte string in Python 2 if six.PY2: # strftime returns a byte string in Python 2
time_str = time_str.decode('utf-8') time_str = time_str.decode('utf-8')
if is_aware(date): if is_aware(date):
offset = date.tzinfo.utcoffset(date) offset = date.tzinfo.utcoffset(date)
Expand All @@ -60,7 +60,7 @@ def rfc3339_date(date):
# Support datetime objects older than 1900 # Support datetime objects older than 1900
date = datetime_safe.new_datetime(date) date = datetime_safe.new_datetime(date)
time_str = date.strftime('%Y-%m-%dT%H:%M:%S') time_str = date.strftime('%Y-%m-%dT%H:%M:%S')
if not six.PY3: # strftime returns a byte string in Python 2 if six.PY2: # strftime returns a byte string in Python 2
time_str = time_str.decode('utf-8') time_str = time_str.decode('utf-8')
if is_aware(date): if is_aware(date):
offset = date.tzinfo.utcoffset(date) offset = date.tzinfo.utcoffset(date)
Expand Down
2 changes: 1 addition & 1 deletion django/utils/functional.py
Expand Up @@ -162,7 +162,7 @@ def __hash__(self):
return hash(self.__cast()) return hash(self.__cast())


def __mod__(self, rhs): def __mod__(self, rhs):
if self._delegate_bytes and not six.PY3: if self._delegate_bytes and six.PY2:
return bytes(self) % rhs return bytes(self) % rhs
elif self._delegate_text: elif self._delegate_text:
return six.text_type(self) % rhs return six.text_type(self) % rhs
Expand Down
4 changes: 2 additions & 2 deletions django/utils/http.py
Expand Up @@ -171,7 +171,7 @@ def base36_to_int(s):
value = int(s, 36) value = int(s, 36)
# ... then do a final check that the value will fit into an int to avoid # ... then do a final check that the value will fit into an int to avoid
# returning a long (#15067). The long type was removed in Python 3. # returning a long (#15067). The long type was removed in Python 3.
if not six.PY3 and value > sys.maxint: if six.PY2 and value > sys.maxint:
raise ValueError("Base36 input too large") raise ValueError("Base36 input too large")
return value return value


Expand All @@ -183,7 +183,7 @@ def int_to_base36(i):
factor = 0 factor = 0
if i < 0: if i < 0:
raise ValueError("Negative base36 conversion input.") raise ValueError("Negative base36 conversion input.")
if not six.PY3: if six.PY2:
if not isinstance(i, six.integer_types): if not isinstance(i, six.integer_types):
raise TypeError("Non-integer base36 conversion input.") raise TypeError("Non-integer base36 conversion input.")
if i > sys.maxint: if i > sys.maxint:
Expand Down
2 changes: 1 addition & 1 deletion django/utils/text.py
Expand Up @@ -12,7 +12,7 @@
from django.utils.translation import ugettext_lazy, ugettext as _, pgettext from django.utils.translation import ugettext_lazy, ugettext as _, pgettext
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe


if not six.PY3: if six.PY2:
# Import force_unicode even though this module doesn't use it, because some # Import force_unicode even though this module doesn't use it, because some
# people rely on it being here. # people rely on it being here.
from django.utils.encoding import force_unicode from django.utils.encoding import force_unicode
Expand Down
10 changes: 4 additions & 6 deletions docs/topics/python3.txt
Expand Up @@ -376,15 +376,13 @@ explicitly tries both locations, as follows::
except ImportError: # Python 2 except ImportError: # Python 2
from urlparse import urlparse, urlunparse from urlparse import urlparse, urlunparse


PY3 PY2
~~~ ~~~


If you need different code in Python 2 and Python 3, check :data:`six.PY3`:: If you need different code in Python 2 and Python 3, check :data:`six.PY2`::


if six.PY3: if six.PY2:
# do stuff Python 3-wise # compatibility code for Python 2
else:
# do stuff Python 2-wise


This is a last resort solution when :mod:`six` doesn't provide an appropriate This is a last resort solution when :mod:`six` doesn't provide an appropriate
function. function.
Expand Down
2 changes: 1 addition & 1 deletion tests/base/models.py
Expand Up @@ -19,7 +19,7 @@ class MyModel(six.with_metaclass(CustomBaseModel, models.Model)):
# This is done to ensure that for Python2 only, defining metaclasses # This is done to ensure that for Python2 only, defining metaclasses
# still does not fail to create the model. # still does not fail to create the model.


if not six.PY3: if six.PY2:
class MyModel(models.Model): class MyModel(models.Model):
"""Model subclass with a custom base using __metaclass__.""" """Model subclass with a custom base using __metaclass__."""
__metaclass__ = CustomBaseModel __metaclass__ = CustomBaseModel
2 changes: 1 addition & 1 deletion tests/basic/tests.py
Expand Up @@ -350,7 +350,7 @@ def test_object_creation(self):
"<Article: Third article>"]) "<Article: Third article>"])


# Slicing works with longs (Python 2 only -- Python 3 doesn't have longs). # Slicing works with longs (Python 2 only -- Python 3 doesn't have longs).
if not six.PY3: if six.PY2:
self.assertEqual(Article.objects.all()[long(0)], a) self.assertEqual(Article.objects.all()[long(0)], a)
self.assertQuerysetEqual(Article.objects.all()[long(1):long(3)], self.assertQuerysetEqual(Article.objects.all()[long(1):long(3)],
["<Article: Second article>", "<Article: Third article>"]) ["<Article: Second article>", "<Article: Third article>"])
Expand Down
2 changes: 1 addition & 1 deletion tests/defaultfilters/tests.py
Expand Up @@ -88,7 +88,7 @@ def test_floatformat_py2_fail(self):
# The test above fails because of Python 2's float handling. Floats with # The test above fails because of Python 2's float handling. Floats with
# many zeroes after the decimal point should be passed in as another type # many zeroes after the decimal point should be passed in as another type
# such as unicode or Decimal. # such as unicode or Decimal.
if not six.PY3: if six.PY2:
test_floatformat_py2_fail = unittest.expectedFailure(test_floatformat_py2_fail) test_floatformat_py2_fail = unittest.expectedFailure(test_floatformat_py2_fail)




Expand Down
14 changes: 7 additions & 7 deletions tests/httpwrappers/tests.py
Expand Up @@ -46,7 +46,7 @@ def test_immutable_get_with_default(self):
def test_immutable_basic_operations(self): def test_immutable_basic_operations(self):
q = QueryDict(str('')) q = QueryDict(str(''))
self.assertEqual(q.getlist('foo'), []) self.assertEqual(q.getlist('foo'), [])
if not six.PY3: if six.PY2:
self.assertEqual(q.has_key('foo'), False) self.assertEqual(q.has_key('foo'), False)
self.assertEqual('foo' in q, False) self.assertEqual('foo' in q, False)
self.assertEqual(list(six.iteritems(q)), []) self.assertEqual(list(six.iteritems(q)), [])
Expand All @@ -72,10 +72,10 @@ def test_single_key_value(self):
self.assertRaises(AttributeError, q.setlist, 'foo', ['bar']) self.assertRaises(AttributeError, q.setlist, 'foo', ['bar'])
self.assertRaises(AttributeError, q.appendlist, 'foo', ['bar']) self.assertRaises(AttributeError, q.appendlist, 'foo', ['bar'])


if not six.PY3: if six.PY2:
self.assertTrue(q.has_key('foo')) self.assertTrue(q.has_key('foo'))
self.assertTrue('foo' in q) self.assertTrue('foo' in q)
if not six.PY3: if six.PY2:
self.assertFalse(q.has_key('bar')) self.assertFalse(q.has_key('bar'))
self.assertFalse('bar' in q) self.assertFalse('bar' in q)


Expand Down Expand Up @@ -131,7 +131,7 @@ def test_basic_mutable_operations(self):
q.appendlist('foo', 'another') q.appendlist('foo', 'another')
self.assertEqual(q.getlist('foo'), ['bar', 'baz', 'another']) self.assertEqual(q.getlist('foo'), ['bar', 'baz', 'another'])
self.assertEqual(q['foo'], 'another') self.assertEqual(q['foo'], 'another')
if not six.PY3: if six.PY2:
self.assertTrue(q.has_key('foo')) self.assertTrue(q.has_key('foo'))
self.assertTrue('foo' in q) self.assertTrue('foo' in q)


Expand Down Expand Up @@ -176,10 +176,10 @@ def test_multiple_keys(self):
self.assertRaises(AttributeError, q.setlist, 'foo', ['bar', 'baz']) self.assertRaises(AttributeError, q.setlist, 'foo', ['bar', 'baz'])
self.assertRaises(AttributeError, q.appendlist, 'foo', ['bar']) self.assertRaises(AttributeError, q.appendlist, 'foo', ['bar'])


if not six.PY3: if six.PY2:
self.assertEqual(q.has_key('vote'), True) self.assertEqual(q.has_key('vote'), True)
self.assertEqual('vote' in q, True) self.assertEqual('vote' in q, True)
if not six.PY3: if six.PY2:
self.assertEqual(q.has_key('foo'), False) self.assertEqual(q.has_key('foo'), False)
self.assertEqual('foo' in q, False) self.assertEqual('foo' in q, False)
self.assertEqual(list(six.iteritems(q)), [('vote', 'no')]) self.assertEqual(list(six.iteritems(q)), [('vote', 'no')])
Expand All @@ -195,7 +195,7 @@ def test_multiple_keys(self):
self.assertRaises(AttributeError, q.setdefault, 'foo', 'bar') self.assertRaises(AttributeError, q.setdefault, 'foo', 'bar')
self.assertRaises(AttributeError, q.__delitem__, 'vote') self.assertRaises(AttributeError, q.__delitem__, 'vote')


if not six.PY3: if six.PY2:
def test_invalid_input_encoding(self): def test_invalid_input_encoding(self):
""" """
QueryDicts must be able to handle invalid input encoding (in this QueryDicts must be able to handle invalid input encoding (in this
Expand Down
2 changes: 1 addition & 1 deletion tests/i18n/tests.py
Expand Up @@ -89,7 +89,7 @@ def test_lazy_objects(self):
s4 = ugettext_lazy('Some other string') s4 = ugettext_lazy('Some other string')
self.assertEqual(False, s == s4) self.assertEqual(False, s == s4)


if not six.PY3: if six.PY2:
# On Python 2, gettext_lazy should not transform a bytestring to unicode # On Python 2, gettext_lazy should not transform a bytestring to unicode
self.assertEqual(gettext_lazy(b"test").upper(), b"TEST") self.assertEqual(gettext_lazy(b"test").upper(), b"TEST")


Expand Down
4 changes: 2 additions & 2 deletions tests/signing/tests.py
Expand Up @@ -48,7 +48,7 @@ def test_sign_unsign(self):
'jkw osanteuh ,rcuh nthu aou oauh ,ud du', 'jkw osanteuh ,rcuh nthu aou oauh ,ud du',
'\u2019', '\u2019',
] ]
if not six.PY3: if six.PY2:
examples.append(b'a byte string') examples.append(b'a byte string')
for example in examples: for example in examples:
signed = signer.sign(example) signed = signer.sign(example)
Expand Down Expand Up @@ -79,7 +79,7 @@ def test_dumps_loads(self):
'a unicode string \u2019', 'a unicode string \u2019',
{'a': 'dictionary'}, {'a': 'dictionary'},
] ]
if not six.PY3: if six.PY2:
objects.append(b'a byte string') objects.append(b'a byte string')
for o in objects: for o in objects:
self.assertNotEqual(o, signing.dumps(o)) self.assertNotEqual(o, signing.dumps(o))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils/doctest_output.py
Expand Up @@ -59,7 +59,7 @@
"""} """}


if not six.PY3: if six.PY2:
__test__["API_TEST"] += """ __test__["API_TEST"] += """
>>> def produce_long(): >>> def produce_long():
... return 42L ... return 42L
Expand Down
2 changes: 1 addition & 1 deletion tests/utils_tests/test_datastructures.py
Expand Up @@ -50,7 +50,7 @@ def test_delete_and_insert(self):
self.d2[7] = 'lucky number 7' self.d2[7] = 'lucky number 7'
self.assertEqual(list(six.iterkeys(self.d2)), [1, 9, 0, 7]) self.assertEqual(list(six.iterkeys(self.d2)), [1, 9, 0, 7])


if not six.PY3: if six.PY2:
def test_change_keys(self): def test_change_keys(self):
""" """
Changing the keys won't do anything, it's only a copy of the Changing the keys won't do anything, it's only a copy of the
Expand Down
4 changes: 2 additions & 2 deletions tests/utils_tests/test_http.py
Expand Up @@ -115,12 +115,12 @@ def test_base36(self):
# reciprocity works # reciprocity works
for n in [0, 1, 1000, 1000000]: for n in [0, 1, 1000, 1000000]:
self.assertEqual(n, http.base36_to_int(http.int_to_base36(n))) self.assertEqual(n, http.base36_to_int(http.int_to_base36(n)))
if not six.PY3: if six.PY2:
self.assertEqual(sys.maxint, http.base36_to_int(http.int_to_base36(sys.maxint))) self.assertEqual(sys.maxint, http.base36_to_int(http.int_to_base36(sys.maxint)))


# bad input # bad input
self.assertRaises(ValueError, http.int_to_base36, -1) self.assertRaises(ValueError, http.int_to_base36, -1)
if not six.PY3: if six.PY2:
self.assertRaises(ValueError, http.int_to_base36, sys.maxint + 1) self.assertRaises(ValueError, http.int_to_base36, sys.maxint + 1)
for n in ['1', 'foo', {1: 2}, (1, 2, 3), 3.141]: for n in ['1', 'foo', {1: 2}, (1, 2, 3), 3.141]:
self.assertRaises(TypeError, http.int_to_base36, n) self.assertRaises(TypeError, http.int_to_base36, n)
Expand Down

0 comments on commit 1153180

Please sign in to comment.