py3: Replace xrange() with range()

This commit is contained in:
Stein Magnus Jodal 2014-09-17 20:13:30 +02:00
parent cd3d44ff6d
commit f58fe9a192
3 changed files with 6 additions and 5 deletions

View File

@ -76,7 +76,7 @@ def parse_pls(data):
for section in cp.sections():
if section.lower() != 'playlist':
continue
for i in xrange(cp.getint(section, 'numberofentries')):
for i in range(cp.getint(section, 'numberofentries')):
yield cp.get(section, 'file%d' % (i+1))

View File

@ -25,10 +25,10 @@ def _levenshtein(a, b):
if n > m:
return _levenshtein(b, a)
current = xrange(n + 1)
for i in xrange(1, m + 1):
current = range(n + 1)
for i in range(1, m + 1):
previous, current = current, [i] + [0] * n
for j in xrange(1, n + 1):
for j in range(1, n + 1):
add, delete = previous[j] + 1, current[j - 1] + 1
change = previous[j - 1]
if a[j - 1] != b[i - 1]:

View File

@ -98,7 +98,8 @@ class StatusHandlerTest(unittest.TestCase):
def test_status_method_contains_playlist(self):
result = dict(status.status(self.context))
self.assertIn('playlist', result)
self.assertIn(int(result['playlist']), xrange(0, 2 ** 31 - 1))
self.assertGreaterEqual(int(result['playlist']), 0)
self.assertLessEqual(int(result['playlist']), 2 ** 31 - 1)
def test_status_method_contains_playlistlength(self):
result = dict(status.status(self.context))