test-concurrency: Replace range with xrange

range in Python 3 does what xrange did in Python 2. This still works in
Python 2, it just uses a bit more memory.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1457
Approved by: cgwalters
This commit is contained in:
Simon McVittie 2018-01-17 14:42:20 +00:00 committed by Atomic Bot
parent 9933de2323
commit 02dc5e2dd4

View File

@ -34,7 +34,7 @@ def fatal(msg):
def mktree(dname, serial=0):
print('Creating tree', dname, file=sys.stderr)
os.mkdir(dname, 0o755)
for v in xrange(20):
for v in range(20):
with open('{}/{}'.format(dname, v), 'w') as f:
f.write('{} {} {}\n'.format(dname, serial, v))
@ -79,12 +79,12 @@ def run(n_committers, n_pruners):
print('n_committers', n_committers, 'n_pruners', n_pruners, file=sys.stderr)
n_trees = n_committers / 2
for v in xrange(n_trees):
for v in range(n_trees):
mktree('tree{}'.format(v))
for v in xrange(n_committers):
for v in range(n_committers):
committers.add(commit(v / 2))
for v in xrange(n_pruners):
for v in range(n_pruners):
pruners.add(prune())
failed = False
@ -97,7 +97,7 @@ def run(n_committers, n_pruners):
if failed:
fatal('A child process exited abnormally')
for v in xrange(n_trees):
for v in range(n_trees):
shutil.rmtree('tree{}'.format(v))
# No concurrent pruning