From a500f02577c604bbec06b0b258f35748b4aa32b7 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Tue, 17 Dec 2024 14:30:42 +0900 Subject: [PATCH] chore: remove juju.loop, deprecated before 3.0 --- debian/control | 6 ++---- juju/loop.py | 12 ------------ tests/unit/test_loop.py | 30 ------------------------------ 3 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 juju/loop.py delete mode 100644 tests/unit/test_loop.py diff --git a/debian/control b/debian/control index d00014b2e..e133c9072 100644 --- a/debian/control +++ b/debian/control @@ -67,10 +67,10 @@ Description: . #!/usr/bin/python3 . + import asyncio import logging import sys . - from juju import loop from juju.model import Model . . @@ -107,9 +107,7 @@ Description: ws_logger = logging.getLogger('websockets.protocol') ws_logger.setLevel(logging.INFO) . - # Run the deploy coroutine in an asyncio event loop, using a helper - # that abstracts loop creation and teardown. - loop.run(deploy()) + asyncio.run(deploy()) . . if __name__ == '__main__': diff --git a/juju/loop.py b/juju/loop.py deleted file mode 100644 index fa0da6d67..000000000 --- a/juju/loop.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2023 Canonical Ltd. -# Licensed under the Apache V2, see LICENCE file for details. - -from .jasyncio import * # noqa - -import warnings - -warnings.warn( - "juju.loop module is being deprecated by 3.0, use juju._jasyncio instead", - DeprecationWarning, - stacklevel=2, -) diff --git a/tests/unit/test_loop.py b/tests/unit/test_loop.py deleted file mode 100644 index ae63e7b35..000000000 --- a/tests/unit/test_loop.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2023 Canonical Ltd. -# Licensed under the Apache V2, see LICENCE file for details. - -import asyncio -import unittest - - -class TestLoop(unittest.TestCase): - def setUp(self): - # new event loop for each test - policy = asyncio.get_event_loop_policy() - self.loop = policy.new_event_loop() - policy.set_event_loop(self.loop) - - def tearDown(self): - self.loop.close() - - async def test_run(self): - assert asyncio.get_running_loop() == self.loop - - async def _test(): - return "success" - - self.assertEqual(asyncio.run(_test()), "success") - - async def test_run_exception(self): - async def _test(): - raise ValueError() - - self.assertRaises(ValueError, asyncio.run, _test())