Browse Source

autopep8 on unit tests.

Omer Katz 7 years ago
parent
commit
4ce1f7f4d0

+ 1 - 1
t/unit/apps/test_multi.py

@@ -102,7 +102,7 @@ class test_multi_args:
         assert expand('%h') == '*P*jerry@*S*'
         assert expand('%n') == '*P*jerry'
         nodes2 = list(multi_args(p, cmd='COMMAND', append='',
-                      prefix='*P*', suffix='*S*'))
+                                 prefix='*P*', suffix='*S*'))
         assert nodes2[0].argv[-1] == '-- .disable_rate_limits=1'
 
         p2 = NamespacedOptionParser(['10', '-c:1', '5'])

+ 4 - 4
t/unit/backends/test_couchdb.py

@@ -30,10 +30,10 @@ class test_CouchBackend:
             module.pycouchdb = prev
 
     def test_get_container_exists(self):
-            self.backend._connection = sentinel._connection
-            connection = self.backend.connection
-            assert connection is sentinel._connection
-            self.Server.assert_not_called()
+        self.backend._connection = sentinel._connection
+        connection = self.backend.connection
+        assert connection is sentinel._connection
+        self.Server.assert_not_called()
 
     def test_get(self):
         """test_get

+ 25 - 25
t/unit/backends/test_dynamodb.py

@@ -42,37 +42,37 @@ class test_DynamoDBBackend:
             'celery.backends.dynamodb.DynamoDBBackend._get_or_create_table'
         with patch('boto3.client') as mock_boto_client, \
                 patch(table_creation_path):
-                backend = DynamoDBBackend(
-                    app=self.app,
-                    url='dynamodb://@localhost:8000'
-                )
-                client = backend._get_client()
-                assert backend.client is client
-                mock_boto_client.assert_called_once_with(
-                    'dynamodb',
-                    endpoint_url='http://localhost:8000',
-                    region_name='us-east-1'
-                )
-                assert backend.endpoint_url == 'http://localhost:8000'
+            backend = DynamoDBBackend(
+                app=self.app,
+                url='dynamodb://@localhost:8000'
+            )
+            client = backend._get_client()
+            assert backend.client is client
+            mock_boto_client.assert_called_once_with(
+                'dynamodb',
+                endpoint_url='http://localhost:8000',
+                region_name='us-east-1'
+            )
+            assert backend.endpoint_url == 'http://localhost:8000'
 
     def test_get_client_credentials(self):
         table_creation_path = \
             'celery.backends.dynamodb.DynamoDBBackend._get_or_create_table'
         with patch('boto3.client') as mock_boto_client, \
                 patch(table_creation_path):
-                backend = DynamoDBBackend(
-                    app=self.app,
-                    url='dynamodb://key:secret@test'
-                )
-                client = backend._get_client()
-                assert client is backend.client
-                mock_boto_client.assert_called_once_with(
-                    'dynamodb',
-                    aws_access_key_id='key',
-                    aws_secret_access_key='secret',
-                    region_name='test'
-                )
-                assert backend.aws_region == 'test'
+            backend = DynamoDBBackend(
+                app=self.app,
+                url='dynamodb://key:secret@test'
+            )
+            client = backend._get_client()
+            assert client is backend.client
+            mock_boto_client.assert_called_once_with(
+                'dynamodb',
+                aws_access_key_id='key',
+                aws_secret_access_key='secret',
+                region_name='test'
+            )
+            assert backend.aws_region == 'test'
 
     def test_get_or_create_table_not_exists(self):
         self.backend._client = MagicMock()

+ 2 - 0
t/unit/bin/test_events.py

@@ -31,6 +31,8 @@ class MockCommand(object):
 
 def proctitle(prog, info=None):
     proctitle.last = (prog, info)
+
+
 proctitle.last = ()  # noqa: E305
 
 

+ 1 - 1
t/unit/bin/test_worker.py

@@ -407,7 +407,7 @@ class test_funs:
         cmd = worker()
         cmd.app = self.app
         opts, args = cmd.parse_options('worker', ['--concurrency=512',
-                                       '--heartbeat-interval=10'])
+                                                  '--heartbeat-interval=10'])
         assert opts['concurrency'] == 512
         assert opts['heartbeat_interval'] == 10
 

+ 1 - 1
t/unit/events/test_state.py

@@ -161,7 +161,7 @@ class ev_snapshot(replay):
             worker = not i % 2 and 'utest2' or 'utest1'
             type = not i % 2 and 'task2' or 'task1'
             self.events.append(Event('task-received', name=type,
-                               uuid=uuid(), hostname=worker))
+                                     uuid=uuid(), hostname=worker))
 
 
 class test_Worker:

+ 16 - 16
t/unit/fixups/test_django.py

@@ -137,22 +137,22 @@ class test_DjangoWorkerFixup(FixupCase):
     def test_on_worker_process_init(self, patching):
         with self.fixup_context(self.app) as (f, _, _):
             with patch('celery.fixups.django._maybe_close_fd') as mcf:
-                    _all = f._db.connections.all = Mock()
-                    conns = _all.return_value = [
-                        Mock(), Mock(),
-                    ]
-                    conns[0].connection = None
-                    with patch.object(f, 'close_cache'):
-                        with patch.object(f, '_close_database'):
-                            f.on_worker_process_init()
-                            mcf.assert_called_with(conns[1].connection)
-                            f.close_cache.assert_called_with()
-                            f._close_database.assert_called_with()
-
-                            f.validate_models = Mock(name='validate_models')
-                            patching.setenv('FORKED_BY_MULTIPROCESSING', '1')
-                            f.on_worker_process_init()
-                            f.validate_models.assert_called_with()
+                _all = f._db.connections.all = Mock()
+                conns = _all.return_value = [
+                    Mock(), Mock(),
+                ]
+                conns[0].connection = None
+                with patch.object(f, 'close_cache'):
+                    with patch.object(f, '_close_database'):
+                        f.on_worker_process_init()
+                        mcf.assert_called_with(conns[1].connection)
+                        f.close_cache.assert_called_with()
+                        f._close_database.assert_called_with()
+
+                        f.validate_models = Mock(name='validate_models')
+                        patching.setenv('FORKED_BY_MULTIPROCESSING', '1')
+                        f.on_worker_process_init()
+                        f.validate_models.assert_called_with()
 
     def test_on_task_prerun(self):
         task = Mock()

+ 8 - 8
t/unit/tasks/test_result.py

@@ -543,17 +543,17 @@ class MockAsyncResultSuccess(AsyncResult):
 
 
 class SimpleBackend(SyncBackendMixin):
-        ids = []
+    ids = []
 
-        def __init__(self, ids=[]):
-            self.ids = ids
+    def __init__(self, ids=[]):
+        self.ids = ids
 
-        def _ensure_not_eager(self):
-            pass
+    def _ensure_not_eager(self):
+        pass
 
-        def get_many(self, *args, **kwargs):
-            return ((id, {'result': i, 'status': states.SUCCESS})
-                    for i, id in enumerate(self.ids))
+    def get_many(self, *args, **kwargs):
+        return ((id, {'result': i, 'status': states.SUCCESS})
+                for i, id in enumerate(self.ids))
 
 
 class test_GroupResult:

+ 1 - 1
t/unit/tasks/test_trace.py

@@ -87,7 +87,7 @@ class test_trace(TraceCase):
         einfo2.internal = True
         assert (get_log_policy(self.add, einfo2, KeyError()) is
                 log_policy_internal)
-        
+
     def test_get_task_name(self):
         assert get_task_name(Context({}), 'default') == 'default'
         assert get_task_name(Context({'shadow': None}), 'default') == 'default'

+ 2 - 2
t/unit/utils/test_utils.py

@@ -9,8 +9,8 @@ from celery.utils import chunks, cached_property
     (range(10), 2, [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]),
 ])
 def test_chunks(items, n, expected):
-        x = chunks(iter(list(items)), n)
-        assert list(x) == expected
+    x = chunks(iter(list(items)), n)
+    assert list(x) == expected
 
 
 def test_cached_property():