From 5e5749f0767ce30474d3022eda1e1dc5baf63659 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Tue, 12 Dec 2023 09:47:12 +0100 Subject: [PATCH] Fix for Python 3.12 --- .github/workflows/test.yml | 2 +- pyproject.toml | 2 ++ tests/conftest.py | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d4807e6..64cf8b56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,7 +85,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.8", "3.11"] + python-version: ["3.8", "3.12"] # PyPy is not supported because we use the file_id_manager. See: # https://github.com/jupyter-server/jupyter_server_fileid/issues/44 #include: diff --git a/pyproject.toml b/pyproject.toml index f501a189..a3cdb4b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -141,6 +141,8 @@ filterwarnings = [ "module:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning", # 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:", ] [tool.mypy] diff --git a/tests/conftest.py b/tests/conftest.py index 234dbb3c..0ef243d1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,12 +16,30 @@ 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 {