From 2c17fab9e2b652a72c862c4a907f4904819d9361 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Tue, 12 Dec 2023 11:58:42 +0100 Subject: [PATCH] Remove use of pytest-asyncio --- pyproject.toml | 3 +-- tests/conftest.py | 18 ------------------ tests/test_loaders.py | 5 ----- tests/test_rooms.py | 8 -------- 4 files changed, 1 insertion(+), 33 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a3cdb4b9..e330b102 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,6 @@ test = [ "jupyter_server_fileid[test]", "pytest>=7.0", "pytest-cov", - "pytest-asyncio", "websockets" ] docs = [ @@ -142,7 +141,7 @@ filterwarnings = [ # In PyPy/Cython: see https://github.com/yaml/pyyaml/issues/688 "ignore:can't resolve package from __spec__ or __package__, falling back on __name__ and __path__:ImportWarning", # see https://github.com/dateutil/dateutil/issues/1314 - "ignore:.*datetime.utcfromtimestamp\\(\\) is deprecated.*:DeprecationWarning:", + # "ignore:.*datetime.utcfromtimestamp\\(\\) is deprecated.*:DeprecationWarning:", ] [tool.mypy] diff --git a/tests/conftest.py b/tests/conftest.py index 0ef243d1..234dbb3c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,30 +16,12 @@ from jupyter_collaboration.loaders import FileLoader from jupyter_collaboration.rooms import DocumentRoom from jupyter_collaboration.stores import SQLiteYStore -from jupyter_server.serverapp import ServerApp from .utils import FakeContentsManager, FakeEventLogger, FakeFileIDManager pytest_plugins = ["jupyter_server.pytest_plugin", "jupyter_server_fileid.pytest_plugin"] -@pytest.fixture(autouse=True) -def jp_server_cleanup(jp_asyncio_loop): # noqa: PT004 - """Automatically cleans up server resources.""" - yield - if jp_asyncio_loop.is_closed(): - return - - app: ServerApp = ServerApp.instance() - try: - jp_asyncio_loop.run_until_complete(app._cleanup()) - except (RuntimeError, SystemExit) as e: - print("ignoring cleanup error", e) # noqa: T201 - if hasattr(app, "kernel_manager"): - app.kernel_manager.context.destroy() - ServerApp.clear_instance() - - @pytest.fixture def jp_server_config(jp_root_dir, jp_server_config): return { diff --git a/tests/test_loaders.py b/tests/test_loaders.py index 6ee57648..483a2c80 100644 --- a/tests/test_loaders.py +++ b/tests/test_loaders.py @@ -6,14 +6,11 @@ import asyncio from datetime import datetime -import pytest - from jupyter_collaboration.loaders import FileLoader, FileLoaderMapping from .utils import FakeContentsManager, FakeFileIDManager -@pytest.mark.asyncio async def test_FileLoader_with_watcher(): id = "file-4567" path = "myfile.txt" @@ -46,7 +43,6 @@ async def trigger(*args): await loader.clean() -@pytest.mark.asyncio async def test_FileLoader_without_watcher(): id = "file-4567" path = "myfile.txt" @@ -78,7 +74,6 @@ async def trigger(*args): await loader.clean() -@pytest.mark.asyncio async def test_FileLoaderMapping_with_watcher(): id = "file-4567" path = "myfile.txt" diff --git a/tests/test_rooms.py b/tests/test_rooms.py index 7ecc5ccd..8f788687 100644 --- a/tests/test_rooms.py +++ b/tests/test_rooms.py @@ -6,13 +6,11 @@ import asyncio from datetime import datetime -import pytest from jupyter_ydoc import YUnicode from .utils import overite_msg, reload_msg -@pytest.mark.asyncio async def test_should_initialize_document_room_without_store(rtc_create_mock_document_room): content = "test" _, _, room = rtc_create_mock_document_room("test-id", "test.txt", content) @@ -21,7 +19,6 @@ async def test_should_initialize_document_room_without_store(rtc_create_mock_doc assert room._document.source == content -@pytest.mark.asyncio async def test_should_initialize_document_room_from_store( rtc_create_SQLite_store, rtc_create_mock_document_room ): @@ -38,7 +35,6 @@ async def test_should_initialize_document_room_from_store( assert room._document.source == content -@pytest.mark.asyncio async def test_should_overwrite_the_store(rtc_create_SQLite_store, rtc_create_mock_document_room): id = "test-id" content = "test" @@ -54,7 +50,6 @@ async def test_should_overwrite_the_store(rtc_create_SQLite_store, rtc_create_mo assert doc.source == content -@pytest.mark.asyncio async def test_defined_save_delay_should_save_content_after_document_change( rtc_create_mock_document_room, ): @@ -70,7 +65,6 @@ async def test_defined_save_delay_should_save_content_after_document_change( assert "save" in cm.actions -@pytest.mark.asyncio async def test_undefined_save_delay_should_not_save_content_after_document_change( rtc_create_mock_document_room, ): @@ -86,7 +80,6 @@ async def test_undefined_save_delay_should_not_save_content_after_document_chang assert "save" not in cm.actions -@pytest.mark.asyncio async def test_should_reload_content_from_disk(rtc_create_mock_document_room): content = "test" last_modified = datetime.now() @@ -109,7 +102,6 @@ async def test_should_reload_content_from_disk(rtc_create_mock_document_room): assert room._document.source == content -@pytest.mark.asyncio async def test_should_not_reload_content_from_disk(rtc_create_mock_document_room): content = "test" last_modified = datetime.now()