Repository: rucio/rucio

Issue:
Configure slack notifications for travis
Motivation
----------

https://docs.travis-ci.com/user/notifications/#Configuring-slack-notifications




Discussion:

Resolving patch:
diff --git a/lib/rucio/client/downloadclient.py b/lib/rucio/client/downloadclient.py
--- a/lib/rucio/client/downloadclient.py
+++ b/lib/rucio/client/downloadclient.py
@@ -477,7 +477,7 @@ def send_trace(self, trace, trace_endpoint, user_agent, retries=5, threadnb=None
             else:
                 logger.debug('sending trace')
 
-        for dummy in xrange(retries):
+        for dummy in range(retries):
             try:
                 requests.post(trace_endpoint + '/traces/', verify=False, data=json.dumps(trace))
                 return 0
diff --git a/lib/rucio/common/utils.py b/lib/rucio/common/utils.py
--- a/lib/rucio/common/utils.py
+++ b/lib/rucio/common/utils.py
@@ -344,7 +344,7 @@ def chunks(l, n):
     """
     Yield successive n-sized chunks from l.
     """
-    for i in xrange(0, len(l), n):
+    for i in range(0, len(l), n):
         yield l[i:i + n]
 
 
@@ -677,7 +677,7 @@ def send_trace(trace, trace_endpoint, user_agent, retries=5, logger=None, log_pr
         logger.debug('%spilot detected - not sending trace' % log_prefix)
         return 0
     logger.debug('%ssending trace' % log_prefix)
-    for dummy in xrange(retries):
+    for dummy in range(retries):
         try:
             requests.post(trace_endpoint + '/traces/', verify=False, data=json.dumps(trace))
             return 0
diff --git a/lib/rucio/rse/protocols/webdav.py b/lib/rucio/rse/protocols/webdav.py
--- a/lib/rucio/rse/protocols/webdav.py
+++ b/lib/rucio/rse/protocols/webdav.py
@@ -308,7 +308,7 @@ def put(self, source, target, source_dir=None, progressbar=False):
                 raise exception.FileReplicaAlreadyExists()
             else:
                 # Create the directories before issuing the PUT
-                for directory_level in reversed(range(1, 4)):
+                for directory_level in reversed(list(range(1, 4))):
                     upper_directory = "/".join(directories[:-directory_level])
                     self.mkdir(upper_directory)
                 try:
@@ -358,7 +358,7 @@ def rename(self, pfn, new_pfn):
                 raise exception.SourceNotFound()
             else:
                 # Create the directories before issuing the MOVE
-                for directory_level in reversed(range(1, 4)):
+                for directory_level in reversed(list(range(1, 4))):
                     upper_directory = "/".join(directories[:-directory_level])
                     self.mkdir(upper_directory)
                 try:


Test patch:
diff --git a/lib/rucio/tests/common.py b/lib/rucio/tests/common.py
--- a/lib/rucio/tests/common.py
+++ b/lib/rucio/tests/common.py
@@ -102,7 +102,7 @@ def rse_name_generator(size=10):
 
     :returns: A random RSE name
     """
-    return 'MOCK_' + ''.join(choice(ascii_uppercase) for x in xrange(size))
+    return 'MOCK_' + ''.join(choice(ascii_uppercase) for x in range(size))
 
 
 def file_generator(size=2, namelen=10):
@@ -110,7 +110,7 @@ def file_generator(size=2, namelen=10):
     :param size: size in bytes
     :returns: The name of the generated file.
     """
-    fn = '/tmp/file_' + ''.join(choice(ascii_uppercase) for x in xrange(namelen))
+    fn = '/tmp/file_' + ''.join(choice(ascii_uppercase) for x in range(namelen))
     execute('dd if=/dev/urandom of={0} count={1} bs=1'.format(fn, size))
     return fn
 
diff --git a/lib/rucio/tests/test_account.py b/lib/rucio/tests/test_account.py
--- a/lib/rucio/tests/test_account.py
+++ b/lib/rucio/tests/test_account.py
@@ -284,7 +284,7 @@ def test_get_account_notfound(self):
     def test_list_accounts(self):
         """ ACCOUNT (CLIENTS): get list of all accounts."""
         dn = config_get('bootstrap', 'x509_identity')
-        acc_list = [account_name_generator() for _ in xrange(5)]
+        acc_list = [account_name_generator() for _ in range(5)]
         for account in acc_list:
             self.client.add_account(account, 'USER', 'rucio@email.com')
 
diff --git a/lib/rucio/tests/test_archive.py b/lib/rucio/tests/test_archive.py
--- a/lib/rucio/tests/test_archive.py
+++ b/lib/rucio/tests/test_archive.py
@@ -29,7 +29,7 @@ def test_add_and_list_archive(self):
         scope, rse = 'mock', 'MOCK'
         archive_file = 'file_' + generate_uuid() + '.zip'
         files = []
-        for i in xrange(10):
+        for i in range(10):
             files.append({'scope': scope, 'name': 'lfn.%s' % str(generate_uuid()),
                           'bytes': 724963570L,
                           'adler32': '0cc737eb',
diff --git a/lib/rucio/tests/test_counter.py b/lib/rucio/tests/test_counter.py
--- a/lib/rucio/tests/test_counter.py
+++ b/lib/rucio/tests/test_counter.py
@@ -30,7 +30,7 @@ def test_inc_dec_get_counter(self):
         assert_equal(cnt, {'files': 0, 'bytes': 0})
 
         count, sum = 0, 0
-        for i in xrange(10):
+        for i in range(10):
             rse_counter.increase(rse_id=rse_id, files=1, bytes=2.147e+9)
             rse_update(once=True)
             count += 1
@@ -39,7 +39,7 @@ def test_inc_dec_get_counter(self):
             del cnt['updated_at']
             assert_equal(cnt, {'files': count, 'bytes': sum})
 
-        for i in xrange(4):
+        for i in range(4):
             rse_counter.decrease(rse_id=rse_id, files=1, bytes=2.147e+9)
             rse_update(once=True)
             count -= 1
@@ -48,7 +48,7 @@ def test_inc_dec_get_counter(self):
             del cnt['updated_at']
             assert_equal(cnt, {'files': count, 'bytes': sum})
 
-        for i in xrange(5):
+        for i in range(5):
             rse_counter.increase(rse_id=rse_id, files=1, bytes=2.147e+9)
             rse_update(once=True)
             count += 1
@@ -57,7 +57,7 @@ def test_inc_dec_get_counter(self):
             del cnt['updated_at']
             assert_equal(cnt, {'files': count, 'bytes': sum})
 
-        for i in xrange(8):
+        for i in range(8):
             rse_counter.decrease(rse_id=rse_id, files=1, bytes=2.147e+9)
             rse_update(once=True)
             count -= 1
@@ -81,7 +81,7 @@ def test_inc_dec_get_counter(self):
         assert_equal(cnt, {'files': 0, 'bytes': 0})
 
         count, sum = 0, 0
-        for i in xrange(10):
+        for i in range(10):
             account_counter.increase(rse_id=rse_id, account=account, files=1, bytes=2.147e+9)
             account_update(once=True)
             count += 1
@@ -90,7 +90,7 @@ def test_inc_dec_get_counter(self):
             del cnt['updated_at']
             assert_equal(cnt, {'files': count, 'bytes': sum})
 
-        for i in xrange(4):
+        for i in range(4):
             account_counter.decrease(rse_id=rse_id, account=account, files=1, bytes=2.147e+9)
             account_update(once=True)
             count -= 1
@@ -99,7 +99,7 @@ def test_inc_dec_get_counter(self):
             del cnt['updated_at']
             assert_equal(cnt, {'files': count, 'bytes': sum})
 
-        for i in xrange(5):
+        for i in range(5):
             account_counter.increase(rse_id=rse_id, account=account, files=1, bytes=2.147e+9)
             account_update(once=True)
             count += 1
@@ -108,7 +108,7 @@ def test_inc_dec_get_counter(self):
             del cnt['updated_at']
             assert_equal(cnt, {'files': count, 'bytes': sum})
 
-        for i in xrange(8):
+        for i in range(8):
             account_counter.decrease(rse_id=rse_id, account=account, files=1, bytes=2.147e+9)
             account_update(once=True)
             count -= 1
diff --git a/lib/rucio/tests/test_did.py b/lib/rucio/tests/test_did.py
--- a/lib/rucio/tests/test_did.py
+++ b/lib/rucio/tests/test_did.py
@@ -56,7 +56,7 @@ def test_delete_dids(self):
         dsns = [{'name': 'dsn_%s' % generate_uuid(),
                  'scope': tmp_scope,
                  'purge_replicas': False,
-                 'did_type': DIDType.DATASET} for i in xrange(5)]
+                 'did_type': DIDType.DATASET} for i in range(5)]
         for dsn in dsns:
             add_did(scope=tmp_scope, name=dsn['name'], type='DATASET', account='root')
         delete_dids(dids=dsns, account='root')
@@ -91,7 +91,7 @@ def test_touch_dids_access_cnt(self):
         assert_equal(None, get_did_access_cnt(scope=tmp_scope, name=tmp_dsn1))
         assert_equal(None, get_did_access_cnt(scope=tmp_scope, name=tmp_dsn2))
 
-        for i in xrange(100):
+        for i in range(100):
             touch_dids(dids=[{'scope': tmp_scope, 'name': tmp_dsn1, 'type': DIDType.DATASET}])
         assert_equal(100, get_did_access_cnt(scope=tmp_scope, name=tmp_dsn1))
         assert_equal(None, get_did_access_cnt(scope=tmp_scope, name=tmp_dsn2))
@@ -144,7 +144,7 @@ def test_list_new_dids(self):
         tmp_scope = scope_name_generator()
         tmp_dsn = 'dsn_%s' % generate_uuid()
         scope.add_scope(tmp_scope, 'jdoe', 'jdoe')
-        for i in xrange(0, 5):
+        for i in range(0, 5):
             did.add_did(scope=tmp_scope, name='%s-%i' % (tmp_dsn, i), type='DATASET', issuer='root')
         for i in did.list_new_dids('DATASET'):
             assert_not_equal(i, {})
@@ -160,7 +160,7 @@ def test_update_new_dids(self):
         tmp_dsn = 'dsn_%s' % generate_uuid()
         scope.add_scope(tmp_scope, 'jdoe', 'jdoe')
         dids = []
-        for i in xrange(0, 5):
+        for i in range(0, 5):
             d = {'scope': tmp_scope, 'name': '%s-%i' % (tmp_dsn, i), 'did_type': DIDType.DATASET}
             did.add_did(scope=tmp_scope, name='%s-%i' % (tmp_dsn, i), type='DATASET', issuer='root')
             dids.append(d)
@@ -300,7 +300,7 @@ def test_add_did(self):
             self.did_client.add_files_to_dataset(scope=tmp_scope, name=tmp_dsn, files=files)
 
         files = []
-        for i in xrange(5):
+        for i in range(5):
             lfn = 'lfn.%(tmp_dsn)s.' % locals() + str(generate_uuid())
             pfn = 'mock://localhost/tmp/rucio_rse/%(project)s/%(version)s/%(prod_step)s' % dataset_meta
             # it doesn't work with mock: TBF
@@ -323,7 +323,7 @@ def test_add_did(self):
             self.did_client.add_dataset(scope=tmp_scope, name=tmp_dsn, files=files, rse=tmp_rse)
 
         files = []
-        for i in xrange(5):
+        for i in range(5):
             lfn = '%(tmp_dsn)s.' % locals() + str(generate_uuid())
             pfn = 'mock://localhost/tmp/rucio_rse/%(project)s/%(version)s/%(prod_step)s' % dataset_meta
             # it doesn't work with mock: TBF
@@ -356,13 +356,13 @@ def test_attach_dids_to_dids(self):
         attachments, dsns = list(), list()
         guid_to_query = None
         dsn = {}
-        for i in xrange(nb_datasets):
+        for i in range(nb_datasets):
             attachment = {}
             attachment['scope'] = tmp_scope
             attachment['name'] = 'dsn.%s' % str(generate_uuid())
             attachment['rse'] = tmp_rse
             files = []
-            for i in xrange(nb_files):
+            for i in range(nb_files):
                 files.append({'scope': tmp_scope, 'name': 'lfn.%s' % str(generate_uuid()),
                               'bytes': 724963570L, 'adler32': '0cc737eb',
                               'meta': {'guid': str(generate_uuid()), 'events': 100}})
@@ -391,7 +391,7 @@ def test_add_files_to_datasets(self):
         dsn2 = 'dsn.%s' % str(generate_uuid())
         meta = {'transient': True}
         files1, files2, nb_files = [], [], 5
-        for i in xrange(nb_files):
+        for i in range(nb_files):
             files1.append({'scope': tmp_scope, 'name': 'lfn.%s' % str(generate_uuid()),
                            'bytes': 724963570L, 'adler32': '0cc737eb',
                            'meta': {'guid': str(generate_uuid()), 'events': 100}})
@@ -416,7 +416,7 @@ def test_add_files_to_datasets(self):
             self.did_client.add_files_to_datasets(attachments)
 
         for attachment in attachments:
-            for i in xrange(nb_files):
+            for i in range(nb_files):
                 attachment['dids'].append({'scope': tmp_scope,
                                            'name': 'lfn.%s' % str(generate_uuid()),
                                            'bytes': 724963570L,
@@ -458,7 +458,7 @@ def test_add_datasets(self):
         """ DATA IDENTIFIERS (CLIENT): Bulk add datasets """
         tmp_scope = 'mock'
         dsns = list()
-        for i in xrange(500):
+        for i in range(500):
             tmp_dsn = {'name': 'dsn_%s' % generate_uuid(), 'scope': tmp_scope, 'meta': {'project': 'data13_hip'}}
             dsns.append(tmp_dsn)
         self.did_client.add_datasets(dsns)
@@ -579,35 +579,35 @@ def test_scope_list(self):
         """ DATA IDENTIFIERS (CLIENT): Add, aggregate, and list data identifiers in a scope """
 
         # create some dummy data
-        self.tmp_accounts = ['jdoe' for i in xrange(3)]
-        self.tmp_scopes = [scope_name_generator() for i in xrange(3)]
-        self.tmp_rses = [rse_name_generator() for i in xrange(3)]
-        self.tmp_files = ['file_%s' % generate_uuid() for i in xrange(3)]
-        self.tmp_datasets = ['dataset_%s' % generate_uuid() for i in xrange(3)]
-        self.tmp_containers = ['container_%s' % generate_uuid() for i in xrange(3)]
+        self.tmp_accounts = ['jdoe' for i in range(3)]
+        self.tmp_scopes = [scope_name_generator() for i in range(3)]
+        self.tmp_rses = [rse_name_generator() for i in range(3)]
+        self.tmp_files = ['file_%s' % generate_uuid() for i in range(3)]
+        self.tmp_datasets = ['dataset_%s' % generate_uuid() for i in range(3)]
+        self.tmp_containers = ['container_%s' % generate_uuid() for i in range(3)]
 
         # add dummy data to the catalogue
-        for i in xrange(3):
+        for i in range(3):
             self.scope_client.add_scope(self.tmp_accounts[i], self.tmp_scopes[i])
             self.rse_client.add_rse(self.tmp_rses[i])
             self.replica_client.add_replica(self.tmp_rses[i], self.tmp_scopes[i], self.tmp_files[i], 1L, '0cc737eb')
 
         # put files in datasets
-        for i in xrange(3):
-            for j in xrange(3):
+        for i in range(3):
+            for j in range(3):
                 files = [{'scope': self.tmp_scopes[j], 'name': self.tmp_files[j], 'bytes': 1L, 'adler32': '0cc737eb'}]
                 self.did_client.add_dataset(self.tmp_scopes[i], self.tmp_datasets[j])
                 self.did_client.add_files_to_dataset(self.tmp_scopes[i], self.tmp_datasets[j], files)
 
         # put datasets in containers
-        for i in xrange(3):
-            for j in xrange(3):
+        for i in range(3):
+            for j in range(3):
                 datasets = [{'scope': self.tmp_scopes[j], 'name': self.tmp_datasets[j]}]
                 self.did_client.add_container(self.tmp_scopes[i], self.tmp_containers[j])
                 self.did_client.add_datasets_to_container(self.tmp_scopes[i], self.tmp_containers[j], datasets)
 
         # reverse check if everything is in order
-        for i in xrange(3):
+        for i in range(3):
             result = self.did_client.scope_list(self.tmp_scopes[i], recursive=True)
 
             r_topdids = []
@@ -621,7 +621,7 @@ def test_scope_list(self):
                     r_otherscopedids.append(r['scope'] + ':' + r['name'])
                     assert_in(r['level'], [1, 2])
 
-            for j in xrange(3):
+            for j in range(3):
                 assert_equal(self.tmp_scopes[i], r_scope[j])
                 if j != i:
                     assert_in(self.tmp_scopes[j] + ':' + self.tmp_files[j], r_otherscopedids)
@@ -654,12 +654,12 @@ def test_get_meta(self):
         values = ['data13_hip', 12345678]
 
         self.replica_client.add_replica(rse, scope, file, 1L, '0cc737eb')
-        for i in xrange(2):
+        for i in range(2):
             self.did_client.set_metadata(scope, file, keys[i], values[i])
 
         meta = self.did_client.get_metadata(scope, file)
 
-        for i in xrange(2):
+        for i in range(2):
             assert_equal(meta[keys[i]], values[i])
 
     def test_list_content(self):
@@ -670,8 +670,8 @@ def test_list_content(self):
         dataset1 = generate_uuid()
         dataset2 = generate_uuid()
         container = generate_uuid()
-        files1 = [{'scope': scope, 'name': generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb'} for i in xrange(nbfiles)]
-        files2 = [{'scope': scope, 'name': generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb'} for i in xrange(nbfiles)]
+        files1 = [{'scope': scope, 'name': generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb'} for i in range(nbfiles)]
+        files2 = [{'scope': scope, 'name': generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb'} for i in range(nbfiles)]
 
         self.did_client.add_dataset(scope, dataset1)
 
@@ -702,11 +702,11 @@ def test_list_files(self):
         container = generate_uuid()
         files1 = []
         files2 = []
-        for i in xrange(10):
+        for i in range(10):
             files1.append({'scope': scope, 'name': generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb'})
             files2.append({'scope': scope, 'name': generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb'})
 
-        for i in xrange(10):
+        for i in range(10):
             self.replica_client.add_replica(rse, scope, files1[i]['name'], 1L, '0cc737eb')
             self.replica_client.add_replica(rse, scope, files2[i]['name'], 1L, '0cc737eb')
 
@@ -742,7 +742,7 @@ def test_list_replicas(self):
         cnt = generate_uuid()
         files1 = []
         files2 = []
-        for i in xrange(10):
+        for i in range(10):
             files1.append({'scope': scope, 'name': generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb'})
             files2.append({'scope': scope, 'name': generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb'})
 
diff --git a/lib/rucio/tests/test_heartbeat.py b/lib/rucio/tests/test_heartbeat.py
--- a/lib/rucio/tests/test_heartbeat.py
+++ b/lib/rucio/tests/test_heartbeat.py
@@ -41,8 +41,8 @@ def test_heartbeat_0(self):
     def test_heartbeat_1(self):
         """ HEARTBEAT (CORE): Multiple instance """
 
-        pids = [self.__pid() for _ in xrange(4)]
-        threads = [self.__thread() for _ in xrange(4)]
+        pids = [self.__pid() for _ in range(4)]
+        threads = [self.__thread() for _ in range(4)]
         assert_equal(live('test0', 'host0', pids[0], threads[0]), {'assign_thread': 0, 'nr_threads': 1})
         assert_equal(live('test0', 'host1', pids[1], threads[1]), {'assign_thread': 1, 'nr_threads': 2})
         assert_equal(live('test0', 'host0', pids[0], threads[0]), {'assign_thread': 0, 'nr_threads': 2})
@@ -56,8 +56,8 @@ def test_heartbeat_1(self):
     def test_heartbeat_2(self):
         """ HEARTBEAT (CORE): Multiple instance with removal"""
 
-        pids = [self.__pid() for _ in xrange(4)]
-        threads = [self.__thread() for _ in xrange(4)]
+        pids = [self.__pid() for _ in range(4)]
+        threads = [self.__thread() for _ in range(4)]
         assert_equal(live('test0', 'host0', pids[0], threads[0]), {'assign_thread': 0, 'nr_threads': 1})
         assert_equal(live('test0', 'host1', pids[1], threads[1]), {'assign_thread': 1, 'nr_threads': 2})
         assert_equal(live('test0', 'host0', pids[0], threads[0]), {'assign_thread': 0, 'nr_threads': 2})
diff --git a/lib/rucio/tests/test_hermes.py b/lib/rucio/tests/test_hermes.py
--- a/lib/rucio/tests/test_hermes.py
+++ b/lib/rucio/tests/test_hermes.py
@@ -23,7 +23,7 @@ class TestHermes(object):
 
     def test_hermes(self):
         ''' HERMES (DAEMON): Test the messaging daemon. '''
-        for i in xrange(1, 4):
+        for i in range(1, 4):
             add_message('test-type_%i' % i, {'test': i})
             add_message('email', {'to': config_get('messaging-hermes', 'email_test').split(','),
                                   'subject': 'Half-Life %i' % i,
diff --git a/lib/rucio/tests/test_judge_injector.py b/lib/rucio/tests/test_judge_injector.py
--- a/lib/rucio/tests/test_judge_injector.py
+++ b/lib/rucio/tests/test_judge_injector.py
@@ -129,7 +129,7 @@ def test_add_rule_with_r2d2_container_treating(self):
         container = 'asdf.r2d2_request.2016-04-01-15-00-00.ads.' + str(uuid())
         add_did(scope, container, DIDType.from_sym('CONTAINER'), 'jdoe')
         datasets = []
-        for i in xrange(3):
+        for i in range(3):
             files = create_files(3, scope, self.rse1)
             dataset = 'dataset_' + str(uuid())
             datasets.append(dataset)
@@ -152,7 +152,7 @@ def test_add_rule_with_r2d2_container_treating_and_duplicate_rule(self):
         container = 'asdf.r2d2_request.2016-04-01-15-00-00.ads.' + str(uuid())
         add_did(scope, container, DIDType.from_sym('CONTAINER'), 'jdoe')
         datasets = []
-        for i in xrange(3):
+        for i in range(3):
             files = create_files(3, scope, self.rse1)
             dataset = 'dataset_' + str(uuid())
             datasets.append(dataset)
diff --git a/lib/rucio/tests/test_message.py b/lib/rucio/tests/test_message.py
--- a/lib/rucio/tests/test_message.py
+++ b/lib/rucio/tests/test_message.py
@@ -38,7 +38,7 @@ def test_pop_messages(self):
         """ MESSAGE (CORE): Test retrieve and delete messages """
 
         truncate_messages()
-        for i in xrange(10):
+        for i in range(10):
             add_message(event_type='TEST', payload={'foo': True,
                                                     'monty': 'python',
                                                     'number': i})
@@ -49,7 +49,7 @@ def test_pop_messages(self):
             assert_is_instance(i['payload'], dict)
             assert_equal(i['payload']['foo'], True)
             assert_equal(i['payload']['monty'], 'python')
-            assert_in(i['payload']['number'], xrange(100))
+            assert_in(i['payload']['number'], range(100))
             to_delete.append({'id': i['id'],
                               'created_at': i['created_at'],
                               'updated_at': i['created_at'],
diff --git a/lib/rucio/tests/test_quarantined_replica.py b/lib/rucio/tests/test_quarantined_replica.py
--- a/lib/rucio/tests/test_quarantined_replica.py
+++ b/lib/rucio/tests/test_quarantined_replica.py
@@ -26,7 +26,7 @@ def test_quarantined_replicas():
 
     nbreplicas = 5
 
-    replicas = [{'path': '/path/' + generate_uuid()} for _ in xrange(nbreplicas)]
+    replicas = [{'path': '/path/' + generate_uuid()} for _ in range(nbreplicas)]
 
     add_quarantined_replicas(rse='MOCK', replicas=replicas)
 
diff --git a/lib/rucio/tests/test_reaper.py b/lib/rucio/tests/test_reaper.py
--- a/lib/rucio/tests/test_reaper.py
+++ b/lib/rucio/tests/test_reaper.py
@@ -19,7 +19,7 @@ def test_reaper():
     """ REAPER (DAEMON): Test the reaper daemon."""
     nb_files = 30
     file_size = 2147483648L  # 2G
-    for i in xrange(nb_files):
+    for i in range(nb_files):
         replica_core.add_replica(rse='MOCK', scope='data13_hip', name='lfn' + generate_uuid(), bytes=file_size, account='root', adler32=None, md5=None)
 
     rse_core.set_rse_usage(rse='MOCK', source='srm', used=nb_files * file_size, free=800L)
diff --git a/lib/rucio/tests/test_replica.py b/lib/rucio/tests/test_replica.py
--- a/lib/rucio/tests/test_replica.py
+++ b/lib/rucio/tests/test_replica.py
@@ -57,7 +57,7 @@ def test_update_replicas_paths(self):
                   'adler32': '0cc737eb',
                   'meta': {'events': 10},
                   'rse_id': rse_info['id'],
-                  'path': '/does/not/really/matter/where'} for i in xrange(nbfiles)]
+                  'path': '/does/not/really/matter/where'} for i in range(nbfiles)]
         add_replicas(rse='MOCK2', files=files, account='root', ignore_availability=True)
         update_replicas_paths(files)
         for replica in list_replicas(dids=[{'scope': f['scope'],
@@ -72,7 +72,7 @@ def test_add_list_bad_replicas(self):
         tmp_scope = 'mock'
         nbfiles = 5
         # Adding replicas to deterministic RSE
-        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         rse_info = rsemgr.get_rse_info('MOCK')
         rse_id1 = rse_info['id']
         add_replicas(rse='MOCK', files=files, account='root', ignore_availability=True)
@@ -96,7 +96,7 @@ def test_add_list_bad_replicas(self):
 
         # Adding replicas to non-deterministic RSE
         files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb',
-                  'pfn': 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/%s/%s' % (tmp_scope, generate_uuid()), 'meta': {'events': 10}} for i in xrange(nbfiles)]
+                  'pfn': 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/%s/%s' % (tmp_scope, generate_uuid()), 'meta': {'events': 10}} for i in range(nbfiles)]
         rse_info = rsemgr.get_rse_info('MOCK2')
         rse_id2 = rse_info['id']
         add_replicas(rse='MOCK2', files=files, account='root', ignore_availability=True)
@@ -128,7 +128,7 @@ def test_add_list_replicas(self):
         """ REPLICA (CORE): Add and list file replicas """
         tmp_scope = 'mock'
         nbfiles = 13
-        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         rses = ['MOCK', 'MOCK3']
         for rse in rses:
             add_replicas(rse=rse, files=files, account='root', ignore_availability=True)
@@ -143,10 +143,10 @@ def test_delete_replicas(self):
         """ REPLICA (CORE): Delete replicas """
         tmp_scope = 'mock'
         nbfiles = 5
-        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         add_replicas(rse='MOCK', files=files1, account='root', ignore_availability=True)
 
-        files2 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files2 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         add_replicas(rse='MOCK', files=files2, account='root', ignore_availability=True)
         add_replicas(rse='MOCK3', files=files2, account='root', ignore_availability=True)
 
@@ -165,7 +165,7 @@ def test_delete_replicas_from_datasets(self):
         tmp_dsn1 = 'dsn_%s' % generate_uuid()
         tmp_dsn2 = 'dsn_%s' % generate_uuid()
         nbfiles = 5
-        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
 
         add_did(scope=tmp_scope, name=tmp_dsn1, type=DIDType.DATASET, account='root')
         add_did(scope=tmp_scope, name=tmp_dsn2, type=DIDType.DATASET, account='root')
@@ -205,8 +205,8 @@ def test_touch_replicas(self):
         """ REPLICA (CORE): Touch replicas accessed_at timestamp"""
         tmp_scope = 'mock'
         nbfiles = 5
-        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
-        files2 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
+        files2 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         files2.append(files1[0])
         add_replicas(rse='MOCK', files=files1, account='root', ignore_availability=True)
         add_replicas(rse='MOCK', files=files2, account='root', ignore_availability=True)
@@ -234,7 +234,7 @@ def test_list_replicas_all_states(self):
         """ REPLICA (CORE): list file replicas with all_states"""
         tmp_scope = 'mock'
         nbfiles = 13
-        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         rses = ['MOCK', 'MOCK3']
         for rse in rses:
             add_replicas(rse=rse, files=files, account='root', ignore_availability=True)
@@ -289,7 +289,7 @@ def test_list_replica_with_domain(self):
                   'name': 'file_%s' % generate_uuid(),
                   'bytes': 1234L,
                   'adler32': '01234567',
-                  'meta': {'events': 1234}} for i in xrange(nbfiles)]
+                  'meta': {'events': 1234}} for i in range(nbfiles)]
 
         add_replicas(rse=tmp_rse, files=files, account='root', ignore_availability=True)
 
@@ -344,7 +344,7 @@ def test_add_list_bad_replicas(self):
         tmp_scope = 'mock'
         nbfiles = 5
         # Adding replicas to deterministic RSE
-        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         rse_info = rsemgr.get_rse_info('MOCK')
         rse_id1 = rse_info['id']
         self.replica_client.add_replicas(rse='MOCK', files=files)
@@ -376,7 +376,7 @@ def test_add_list_bad_replicas(self):
 
         # Adding replicas to non-deterministic RSE
         files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb',
-                  'pfn': 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/%s/%s' % (tmp_scope, generate_uuid()), 'meta': {'events': 10}} for i in xrange(nbfiles)]
+                  'pfn': 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/%s/%s' % (tmp_scope, generate_uuid()), 'meta': {'events': 10}} for i in range(nbfiles)]
         rse_info = rsemgr.get_rse_info('MOCK2')
         rse_id2 = rse_info['id']
         self.replica_client.add_replicas(rse='MOCK2', files=files)
@@ -410,7 +410,7 @@ def test_add_suspicious_replicas(self):
         tmp_scope = 'mock'
         nbfiles = 5
         # Adding replicas to deterministic RSE
-        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         self.replica_client.add_replicas(rse='MOCK', files=files)
 
         # Listing replicas on deterministic RSE
@@ -424,7 +424,7 @@ def test_add_suspicious_replicas(self):
 
         # Adding replicas to non-deterministic RSE
         files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb',
-                  'pfn': 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/%s/%s' % (tmp_scope, generate_uuid()), 'meta': {'events': 10}} for i in xrange(nbfiles)]
+                  'pfn': 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/%s/%s' % (tmp_scope, generate_uuid()), 'meta': {'events': 10}} for i in range(nbfiles)]
         self.replica_client.add_replicas(rse='MOCK2', files=files)
 
         # Listing replicas on non-deterministic RSE
@@ -506,10 +506,10 @@ def test_add_list_replicas(self):
         tmp_scope = 'mock'
         nbfiles = 5
 
-        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         self.replica_client.add_replicas(rse='MOCK', files=files1)
 
-        files2 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files2 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         self.replica_client.add_replicas(rse='MOCK3', files=files2)
 
         replicas = [r for r in self.replica_client.list_replicas(dids=[{'scope': i['scope'], 'name': i['name']} for i in files1])]
@@ -521,10 +521,10 @@ def test_add_list_replicas(self):
         replicas = [r for r in self.replica_client.list_replicas(dids=[{'scope': i['scope'], 'name': i['name']} for i in files2], schemes=['srm'])]
         assert_equal(len(replicas), 5)
 
-        files3 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'state': 'U', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files3 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'state': 'U', 'meta': {'events': 10}} for i in range(nbfiles)]
         self.replica_client.add_replicas(rse='MOCK3', files=files3)
         replicas = [r for r in self.replica_client.list_replicas(dids=[{'scope': i['scope'], 'name': i['name']} for i in files3], schemes=['file'])]
-        for i in xrange(nbfiles):
+        for i in range(nbfiles):
             assert_equal(replicas[i]['rses'], {})
         files4 = []
         for file in files3:
@@ -533,14 +533,14 @@ def test_add_list_replicas(self):
         self.replica_client.update_replicas_states('MOCK3', files=files4)
         replicas = [r for r in self.replica_client.list_replicas(dids=[{'scope': i['scope'], 'name': i['name']} for i in files3], schemes=['file'], unavailable=True)]
         assert_equal(len(replicas), 5)
-        for i in xrange(nbfiles):
+        for i in range(nbfiles):
             assert_in('MOCK3', replicas[i]['rses'])
 
     def test_delete_replicas(self):
         """ REPLICA (CLIENT): Add and delete file replicas """
         tmp_scope = 'mock'
         nbfiles = 5
-        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         self.replica_client.add_replicas(rse='MOCK', files=files)
         with assert_raises(AccessDenied):
             self.replica_client.delete_replicas(rse='MOCK', files=files)
@@ -589,7 +589,7 @@ def test_get_did_from_pfns_nondeterministic(self):
         rse_info = rsemgr.get_rse_info(rse)
         assert_equal(rse_info['deterministic'], False)
         files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb',
-                  'pfn': 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/%s/%s' % (tmp_scope, generate_uuid()), 'meta': {'events': 10}} for i in xrange(nbfiles)]
+                  'pfn': 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/%s/%s' % (tmp_scope, generate_uuid()), 'meta': {'events': 10}} for i in range(nbfiles)]
         for f in files:
             input[f['pfn']] = {'scope': f['scope'], 'name': f['name']}
         add_replicas(rse=rse, files=files, account='root', ignore_availability=True)
@@ -609,7 +609,7 @@ def test_get_did_from_pfns_deterministic(self):
         input = {}
         rse_info = rsemgr.get_rse_info(rse)
         assert_equal(rse_info['deterministic'], True)
-        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         p = rsemgr.create_protocol(rse_info, 'read', scheme='srm')
         for f in files:
             pfn = p.lfns2pfns(lfns={'scope': f['scope'], 'name': f['name']}).values()[0]
diff --git a/lib/rucio/tests/test_root_proxy.py b/lib/rucio/tests/test_root_proxy.py
--- a/lib/rucio/tests/test_root_proxy.py
+++ b/lib/rucio/tests/test_root_proxy.py
@@ -53,7 +53,7 @@ def setup(self):
                        'name': 'half-life_%s' % i,
                        'bytes': 1234L,
                        'adler32': 'deadbeef',
-                       'meta': {'events': 666}} for i in xrange(1, 4)]
+                       'meta': {'events': 666}} for i in range(1, 4)]
         for rse in [self.rse_with_proxy, self.rse_without_proxy]:
             add_replicas(rse=rse,
                          files=self.files,
diff --git a/lib/rucio/tests/test_rse.py b/lib/rucio/tests/test_rse.py
--- a/lib/rucio/tests/test_rse.py
+++ b/lib/rucio/tests/test_rse.py
@@ -219,7 +219,7 @@ def test_update_rse(self):
 
         tmp_scope = 'mock'
         nbfiles = 5
-        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files1 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         replica_client = ReplicaClient()
         replica_client.add_replicas(rse=renamed_rse, files=files1)
 
@@ -229,13 +229,13 @@ def test_update_rse(self):
         assert_equal(dict2['availability_write'], False)
         assert_equal(dict2['availability_delete'], False)
 
-        files2 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in xrange(nbfiles)]
+        files2 = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'meta': {'events': 10}} for i in range(nbfiles)]
         with assert_raises(ResourceTemporaryUnavailable):
             replica_client.add_replicas(rse=renamed_rse, files=files2, ignore_availability=False)
 
     def test_list_rses(self):
         """ RSE (CLIENTS): try to list rses."""
-        rse_list = [rse_name_generator() for i in xrange(5)]
+        rse_list = [rse_name_generator() for i in range(5)]
         for rse in rse_list:
             self.client.add_rse(rse)
 
diff --git a/lib/rucio/tests/test_rse_expression_parser.py b/lib/rucio/tests/test_rse_expression_parser.py
--- a/lib/rucio/tests/test_rse_expression_parser.py
+++ b/lib/rucio/tests/test_rse_expression_parser.py
@@ -20,15 +20,15 @@
 
 
 def rse_name_generator(size=10):
-    return 'MOCK_' + ''.join(choice(ascii_uppercase) for x in xrange(size))
+    return 'MOCK_' + ''.join(choice(ascii_uppercase) for x in range(size))
 
 
 def tag_generator(size_s=10, size_d=2):
-    return ''.join(choice(ascii_uppercase) for x in xrange(size_s)).join(choice(digits) for x in xrange(size_d))
+    return ''.join(choice(ascii_uppercase) for x in range(size_s)).join(choice(digits) for x in range(size_d))
 
 
 def attribute_name_generator(size=10):
-    return ''.join(choice(ascii_uppercase)).join(choice(ascii_lowercase) for x in xrange(size - 1))
+    return ''.join(choice(ascii_uppercase)).join(choice(ascii_lowercase) for x in range(size - 1))
 
 
 class TestRSEExpressionParserCore(object):
diff --git a/lib/rucio/tests/test_rule.py b/lib/rucio/tests/test_rule.py
--- a/lib/rucio/tests/test_rule.py
+++ b/lib/rucio/tests/test_rule.py
@@ -58,7 +58,7 @@ def create_files(nrfiles, scope, rse, bytes=1):
     :returns:        List of dict
     """
     files = []
-    for i in xrange(nrfiles):
+    for i in range(nrfiles):
         file = 'file_%s' % uuid()
         if isinstance(rse, list):
             for r in rse:
@@ -219,7 +219,7 @@ def test_add_rule_container_none(self):
         container = 'container_' + str(uuid())
         add_did(scope, container, DIDType.from_sym('CONTAINER'), 'jdoe')
         all_files = []
-        for i in xrange(3):
+        for i in range(3):
             files = create_files(3, scope, self.rse1)
             all_files.extend(files)
             dataset = 'dataset_' + str(uuid())
@@ -264,7 +264,7 @@ def test_add_rule_container_all(self):
         container = 'container_' + str(uuid())
         add_did(scope, container, DIDType.from_sym('CONTAINER'), 'jdoe')
         all_files = []
-        for i in xrange(3):
+        for i in range(3):
             files = create_files(3, scope, self.rse1)
             all_files.extend(files)
             dataset = 'dataset_' + str(uuid())
@@ -328,7 +328,7 @@ def test_add_rule_container_dataset(self):
         add_did(scope, container, DIDType.from_sym('CONTAINER'), 'jdoe')
         all_files = []
         dataset_files = []
-        for i in xrange(3):
+        for i in range(3):
             files = create_files(3, scope, self.rse1)
             all_files.extend(files)
             dataset = 'dataset_' + str(uuid())
@@ -373,7 +373,7 @@ def test_add_rule_container_dataset_with_weights(self):
         add_did(scope, container, DIDType.from_sym('CONTAINER'), 'jdoe')
         all_files = []
         dataset_files = []
-        for i in xrange(3):
+        for i in range(3):
             files = create_files(3, scope, self.rse1)
             all_files.extend(files)
             dataset = 'dataset_' + str(uuid())
diff --git a/lib/rucio/tests/test_scope.py b/lib/rucio/tests/test_scope.py
--- a/lib/rucio/tests/test_scope.py
+++ b/lib/rucio/tests/test_scope.py
@@ -218,7 +218,7 @@ def test_create_scope_duplicate(self):
     def test_list_scopes(self):
         """ SCOPE (CLIENTS): try to list scopes for an account."""
         account = 'jdoe'
-        scope_list = [scope_name_generator() for _ in xrange(5)]
+        scope_list = [scope_name_generator() for _ in range(5)]
         for scope in scope_list:
             self.scope_client.add_scope(account, scope)
 
diff --git a/lib/rucio/tests/test_temporary_did.py b/lib/rucio/tests/test_temporary_did.py
--- a/lib/rucio/tests/test_temporary_did.py
+++ b/lib/rucio/tests/test_temporary_did.py
@@ -22,7 +22,7 @@ def test_core_temporary_dids():
     """ TMP DATA IDENTIFIERS (CORE): """
 
     temporary_dids = []
-    for _ in xrange(10):
+    for _ in range(10):
         temporary_dids.append({'scope': 'mock',
                                'name': 'object_%s' % generate_uuid(),
                                'rse': 'MOCK',
@@ -47,7 +47,7 @@ def test_client_temporary_dids():
     """ TMP DATA IDENTIFIERS (CLIENT): """
     client = DIDClient()
     temporary_dids = []
-    for _ in xrange(10):
+    for _ in range(10):
         temporary_dids.append({'scope': 'mock',
                                'name': 'object_%s' % generate_uuid(),
                                'rse': 'MOCK',
diff --git a/lib/rucio/tests/test_undertaker.py b/lib/rucio/tests/test_undertaker.py
--- a/lib/rucio/tests/test_undertaker.py
+++ b/lib/rucio/tests/test_undertaker.py
@@ -36,7 +36,7 @@ def test_undertaker(self):
         dsns1 = [{'name': 'dsn_%s' % generate_uuid(),
                   'scope': tmp_scope,
                   'type': 'DATASET',
-                  'lifetime': -1} for i in xrange(nbdatasets)]
+                  'lifetime': -1} for i in range(nbdatasets)]
 
         dsns2 = [{'name': 'dsn_%s' % generate_uuid(),
                   'scope': tmp_scope,
@@ -44,13 +44,13 @@ def test_undertaker(self):
                   'lifetime': -1,
                   'rules': [{'account': 'jdoe', 'copies': 1,
                              'rse_expression': 'MOCK',
-                             'grouping': 'DATASET'}]} for i in xrange(nbdatasets)]
+                             'grouping': 'DATASET'}]} for i in range(nbdatasets)]
 
         add_dids(dids=dsns1 + dsns2, account='root')
 
         replicas = list()
         for dsn in dsns1 + dsns2:
-            files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'tombstone': datetime.utcnow() + timedelta(weeks=2), 'meta': {'events': 10}} for i in xrange(nbfiles)]
+            files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'tombstone': datetime.utcnow() + timedelta(weeks=2), 'meta': {'events': 10}} for i in range(nbfiles)]
             attach_dids(scope=tmp_scope, name=dsn['name'], rse='MOCK', dids=files, account='root')
             replicas += files
 
@@ -99,13 +99,13 @@ def test_atlas_archival_policy(self):
                   'lifetime': -1,
                   'rules': [{'account': 'jdoe', 'copies': 1,
                              'rse_expression': rse,
-                             'grouping': 'DATASET'}]} for i in xrange(nbdatasets)]
+                             'grouping': 'DATASET'}]} for i in range(nbdatasets)]
 
         add_dids(dids=dsns2, account='root')
 
         replicas = list()
         for dsn in dsns2:
-            files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'tombstone': datetime.utcnow() + timedelta(weeks=2), 'meta': {'events': 10}} for i in xrange(nbfiles)]
+            files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1L, 'adler32': '0cc737eb', 'tombstone': datetime.utcnow() + timedelta(weeks=2), 'meta': {'events': 10}} for i in range(nbfiles)]
             attach_dids(scope=tmp_scope, name=dsn['name'], rse=rse, dids=files, account='root')
             replicas += files