Kaydet (Commit) b9b3e9f0 authored tarafından Alex Gaynor's avatar Alex Gaynor

Use Python's changed comparisons, which makes this a bit more readable.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17526 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 6072e108
...@@ -171,7 +171,7 @@ def int_to_base36(i): ...@@ -171,7 +171,7 @@ def int_to_base36(i):
""" """
digits = "0123456789abcdefghijklmnopqrstuvwxyz" digits = "0123456789abcdefghijklmnopqrstuvwxyz"
factor = 0 factor = 0
if (i < 0) or (i > sys.maxint): if not 0 <= i <= sys.maxint:
raise ValueError("Base36 conversion input too large or incorrect type.") raise ValueError("Base36 conversion input too large or incorrect type.")
# Find starting factor # Find starting factor
while True: while True:
......
...@@ -119,6 +119,6 @@ class TestUtilsHttp(unittest.TestCase): ...@@ -119,6 +119,6 @@ class TestUtilsHttp(unittest.TestCase):
self.assertRaises(TypeError, http.int_to_base36, 3.141) self.assertRaises(TypeError, http.int_to_base36, 3.141)
# more explicit output testing # more explicit output testing
for n, b36 in [(0,'0'), (1,'1'), (42,'16'), (818469960,'django')]: for n, b36 in [(0, '0'), (1, '1'), (42, '16'), (818469960, 'django')]:
self.assertEqual(http.int_to_base36(n), b36) self.assertEqual(http.int_to_base36(n), b36)
self.assertEqual(http.base36_to_int(b36), n) self.assertEqual(http.base36_to_int(b36), n)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment