From 6c74c994a19e7c69bb67fa3e8ebcf975ef082f73 Mon Sep 17 00:00:00 2001 From: Tiago Albineli Motta Date: Fri, 17 Feb 2023 09:15:27 -0300 Subject: [PATCH] Fixed mostly tests with non existent async def setUp --- itests/easyqueue/test_connection.py | 4 ++-- itests/easyqueue/test_queue.py | 2 +- itests/test_json_queue.py | 2 +- itests/test_rabbitmq_consumer.py | 4 ++-- tests/easyqueue/test_async_queue.py | 4 ++-- tests/http/test_http_decorators.py | 2 +- tests/http/test_metrics_endpoint.py | 2 +- tests/http/test_pathparam_type.py | 2 +- tests/metrics/test_http_metrics.py | 2 +- tests/signals/handlers/test_http.py | 2 +- tests/signals/handlers/test_rabbitmq.py | 2 +- tests/signals/test_base.py | 2 +- tests/task_runners/test_scheduled.py | 2 +- tests/test_app.py | 2 +- tests/test_connections.py | 2 +- tests/test_decorators.py | 2 +- tests/test_test_utils.py | 4 ++-- tests/types/test_registry.py | 2 +- tests/typing/test_typing_functions.py | 3 --- 19 files changed, 22 insertions(+), 25 deletions(-) diff --git a/itests/easyqueue/test_connection.py b/itests/easyqueue/test_connection.py index a9f90f5f..75c40f72 100644 --- a/itests/easyqueue/test_connection.py +++ b/itests/easyqueue/test_connection.py @@ -6,10 +6,10 @@ class ConnectionTest(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.conn = AMQPConnection("127.0.0.1", "guest", "guest") - async def tearDown(self): + async def asyncTearDown(self): await self.conn.close() async def test_can_call_close_multiple_times(self): diff --git a/itests/easyqueue/test_queue.py b/itests/easyqueue/test_queue.py index 9ae9a5dc..9422de97 100644 --- a/itests/easyqueue/test_queue.py +++ b/itests/easyqueue/test_queue.py @@ -10,7 +10,7 @@ class EnsureConnectedTest(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.queue = JsonQueue( host="127.0.0.1", username="guest", password="guest" ) diff --git a/itests/test_json_queue.py b/itests/test_json_queue.py index 2e5ae8d8..957bec65 100644 --- a/itests/test_json_queue.py +++ b/itests/test_json_queue.py @@ -18,7 +18,7 @@ async def on_queue_message(self, msg: AMQPMessage[Any]): class JsonQueueTest(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.queue = JsonQueue( "127.0.0.1", "guest", "guest", delegate=DumbConsumer() ) diff --git a/itests/test_rabbitmq_consumer.py b/itests/test_rabbitmq_consumer.py index c860a83e..218c3407 100644 --- a/itests/test_rabbitmq_consumer.py +++ b/itests/test_rabbitmq_consumer.py @@ -15,7 +15,7 @@ class RabbitMQConsumerTest(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.queue_name = "test" self.connection = AMQPConnection( hostname="127.0.0.1", username="guest", password="guest", prefetch=1 @@ -125,7 +125,7 @@ async def callback(*args, **kwargs): class AMQPConsumerTestWithAdditionalParameters(IsolatedAsyncioTestCase): maxDiff = None - async def setUp(self): + async def asyncSetUp(self): from aiohttp import ClientSession, BasicAuth client = ClientSession() diff --git a/tests/easyqueue/test_async_queue.py b/tests/easyqueue/test_async_queue.py index 569700ad..eef5d82f 100644 --- a/tests/easyqueue/test_async_queue.py +++ b/tests/easyqueue/test_async_queue.py @@ -448,7 +448,7 @@ class AsyncQueueConsumerHandlerMethodsTests( def get_consumer(self): return Mock(spec=QueueConsumerDelegate) - async def setUp(self): + async def asyncSetUp(self): super().setUp() self.properties = Mock(name="Properties") self.delegate = Mock(spec=QueueConsumerDelegate) @@ -525,7 +525,7 @@ async def test_it_calls_on_message_handle_error_if_message_handler_raises_an_err class EnsureConnectedDecoratorTests(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.seconds = 666 self.queue = JsonQueue( "127.0.0.1", diff --git a/tests/http/test_http_decorators.py b/tests/http/test_http_decorators.py index b19c48a5..5342c431 100644 --- a/tests/http/test_http_decorators.py +++ b/tests/http/test_http_decorators.py @@ -14,7 +14,7 @@ class HTTPDecoratorsTest(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.app = App() @self.app.http.post(["/get_by_id/{_id}"]) diff --git a/tests/http/test_metrics_endpoint.py b/tests/http/test_metrics_endpoint.py index 2a85c105..b31373d4 100644 --- a/tests/http/test_metrics_endpoint.py +++ b/tests/http/test_metrics_endpoint.py @@ -21,7 +21,7 @@ class MetricsEndpointTest(IsolatedAsyncioTestCase): use_default_loop = True maxDiff = None - async def setUp(self): + def setUp(self): self.METRICS_PATH = "/metrics-2" self.app = App() self.app.http.get([self.METRICS_PATH])(metrics_route_handler) diff --git a/tests/http/test_pathparam_type.py b/tests/http/test_pathparam_type.py index 9c00677f..b96ba854 100644 --- a/tests/http/test_pathparam_type.py +++ b/tests/http/test_pathparam_type.py @@ -18,7 +18,7 @@ class TestPathParamTypeHint(IsolatedAsyncioTestCase): maxDiff = None - async def setUp(self): + def setUp(self): self.app = App() async def test_parse_simple_int(self): diff --git a/tests/metrics/test_http_metrics.py b/tests/metrics/test_http_metrics.py index 18c1c684..5261bd7d 100644 --- a/tests/metrics/test_http_metrics.py +++ b/tests/metrics/test_http_metrics.py @@ -17,7 +17,7 @@ class HTTPMetricsTests(IsolatedAsyncioTestCase): app_url = f"http://{settings.HTTP_HOST}:{settings.HTTP_PORT}" - async def setUp(self): + async def asyncSetUp(self): self.app = App() self.client = ClientSession() diff --git a/tests/signals/handlers/test_http.py b/tests/signals/handlers/test_http.py index 526dbafb..41d535dd 100644 --- a/tests/signals/handlers/test_http.py +++ b/tests/signals/handlers/test_http.py @@ -19,7 +19,7 @@ class HTTPServerTests(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.signal_handler = HTTPServer() handler1 = Mock(return_value=AsyncMock()) diff --git a/tests/signals/handlers/test_rabbitmq.py b/tests/signals/handlers/test_rabbitmq.py index 403362c6..fd3ead6b 100644 --- a/tests/signals/handlers/test_rabbitmq.py +++ b/tests/signals/handlers/test_rabbitmq.py @@ -11,7 +11,7 @@ class AMQPTests(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.signal_handler = RabbitMQ() handler1 = Mock(return_value=AsyncMock()) diff --git a/tests/signals/test_base.py b/tests/signals/test_base.py index 3abfe294..3248d9e9 100644 --- a/tests/signals/test_base.py +++ b/tests/signals/test_base.py @@ -5,7 +5,7 @@ class SignalTests(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.owner = Mock(freeze=AsyncMock()) self.signal = Signal(self.owner) diff --git a/tests/task_runners/test_scheduled.py b/tests/task_runners/test_scheduled.py index 0209f5e2..47a5444e 100644 --- a/tests/task_runners/test_scheduled.py +++ b/tests/task_runners/test_scheduled.py @@ -11,7 +11,7 @@ class ScheduledTaskRunnerTests(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): reload(task_runners) self.task = AsyncMock() self.app = Mock(spec=App) diff --git a/tests/test_app.py b/tests/test_app.py index d2b5d6be..ba5a6566 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -18,7 +18,7 @@ class AppTests(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): class MyApp(App): handlers = ( Mock(startup=AsyncMock(), shutdown=AsyncMock()), diff --git a/tests/test_connections.py b/tests/test_connections.py index c6d6a739..950c3867 100644 --- a/tests/test_connections.py +++ b/tests/test_connections.py @@ -5,7 +5,7 @@ class ConnectionsMappingTest(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.connection = AMQPConnection( hostname="localhost", username="guest", password="pwd" ) diff --git a/tests/test_decorators.py b/tests/test_decorators.py index 15040b60..bae9adab 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -38,7 +38,7 @@ async def _wrapper(other: str, flag: bool): class TestWrapsDecorator(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.registry = TypesRegistry() self.resolver = ArgResolver(registry=self.registry) diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index 280e8d44..6e187e27 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -19,7 +19,7 @@ async def _h(): class HttpClientTestCaseDecoratorTest(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.app = App() async def test_client_is_passed_to_test(self): @@ -81,7 +81,7 @@ async def other_method(http_client): class HttpClientContextManagerTest(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.app = App() async def test_client_can_perform_requests(self): diff --git a/tests/types/test_registry.py b/tests/types/test_registry.py index 9253cc28..161d5486 100644 --- a/tests/types/test_registry.py +++ b/tests/types/test_registry.py @@ -8,7 +8,7 @@ class TypesRegistryTest(IsolatedAsyncioTestCase): - async def setUp(self): + def setUp(self): self.registry = TypesRegistry() async def test_simple_set_get_object(self): diff --git a/tests/typing/test_typing_functions.py b/tests/typing/test_typing_functions.py index b21c399e..1347556e 100644 --- a/tests/typing/test_typing_functions.py +++ b/tests/typing/test_typing_functions.py @@ -28,9 +28,6 @@ class MyObject: class TestTypingFunctions(IsolatedAsyncioTestCase): - async def setUp(self): - pass - async def test_get_args_generic_type(self): self.assertEqual((MyObject,), get_args(MyGeneric[MyObject])) self.assertEqual(