commit python-pytest-jupyter for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-pytest-jupyter for openSUSE:Factory checked in at 2024-04-02 16:37:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-jupyter (Old) and /work/SRC/openSUSE:Factory/.python-pytest-jupyter.new.1905 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-pytest-jupyter" Tue Apr 2 16:37:40 2024 rev:6 rq:1163583 version:0.9.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-jupyter/python-pytest-jupyter.changes 2024-03-06 23:03:09.346320276 +0100 +++ /work/SRC/openSUSE:Factory/.python-pytest-jupyter.new.1905/python-pytest-jupyter.changes 2024-04-02 16:37:46.466975921 +0200 @@ -1,0 +2,7 @@ +Fri Mar 29 19:05:45 UTC 2024 - Ben Greiner <code@bnavigator.de> + +- Update to 0.9.1 + * Update event loop handling #75 (@blink1073) + * Maintenance and upkeep improvements + +------------------------------------------------------------------- Old: ---- pytest_jupyter-0.8.0.tar.gz New: ---- pytest_jupyter-0.9.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-jupyter.spec ++++++ --- /var/tmp/diff_new_pack.nTCCKF/_old 2024-04-02 16:37:47.535015280 +0200 +++ /var/tmp/diff_new_pack.nTCCKF/_new 2024-04-02 16:37:47.539015428 +0200 @@ -30,7 +30,7 @@ %bcond_with ringdisabled %define skip_python39 1 Name: python-pytest-jupyter%{psuffix} -Version: 0.8.0 +Version: 0.9.1 Release: 0 Summary: A pytest plugin for testing Jupyter libraries and extensions License: BSD-3-Clause AND MIT @@ -41,7 +41,7 @@ BuildRequires: %{python_module pip} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-jupyter_core +Requires: python-jupyter_core >= 5.7 Requires: python-pytest BuildArch: noarch %if %{with test} ++++++ pytest_jupyter-0.8.0.tar.gz -> pytest_jupyter-0.9.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest_jupyter-0.8.0/PKG-INFO new/pytest_jupyter-0.9.1/PKG-INFO --- old/pytest_jupyter-0.8.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/pytest_jupyter-0.9.1/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pytest-jupyter -Version: 0.8.0 +Version: 0.9.1 Summary: A pytest plugin for testing Jupyter libraries and extensions. Project-URL: Homepage, http://jupyter.org Project-URL: Funding, https://numfocus.org/donate @@ -102,7 +102,7 @@ Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Requires-Python: >=3.8 -Requires-Dist: jupyter-core +Requires-Dist: jupyter-core>=5.7 Requires-Dist: pytest Provides-Extra: client Requires-Dist: ipykernel>=6.14; extra == 'client' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest_jupyter-0.8.0/pyproject.toml new/pytest_jupyter-0.9.1/pyproject.toml --- old/pytest_jupyter-0.8.0/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 +++ new/pytest_jupyter-0.9.1/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 @@ -28,7 +28,7 @@ ] dependencies = [ "pytest", - "jupyter_core" + "jupyter_core>=5.7" ] requires-python = ">=3.8" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest_jupyter-0.8.0/pytest_jupyter/_version.py new/pytest_jupyter-0.9.1/pytest_jupyter/_version.py --- old/pytest_jupyter-0.8.0/pytest_jupyter/_version.py 2020-02-02 01:00:00.000000000 +0100 +++ new/pytest_jupyter-0.9.1/pytest_jupyter/_version.py 2020-02-02 01:00:00.000000000 +0100 @@ -2,4 +2,4 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -__version__ = "0.8.0" +__version__ = "0.9.1" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest_jupyter-0.8.0/pytest_jupyter/jupyter_client.py new/pytest_jupyter-0.9.1/pytest_jupyter/jupyter_client.py --- old/pytest_jupyter-0.8.0/pytest_jupyter/jupyter_client.py 2020-02-02 01:00:00.000000000 +0100 +++ new/pytest_jupyter-0.9.1/pytest_jupyter/jupyter_client.py 2020-02-02 01:00:00.000000000 +0100 @@ -21,7 +21,6 @@ # Bring in local plugins. from pytest_jupyter.jupyter_core import * # noqa: F403 -from pytest_jupyter.pytest_tornasync import * # noqa: F403 @pytest.fixture() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest_jupyter-0.8.0/pytest_jupyter/jupyter_core.py new/pytest_jupyter-0.9.1/pytest_jupyter/jupyter_core.py --- old/pytest_jupyter-0.8.0/pytest_jupyter/jupyter_core.py 2020-02-02 01:00:00.000000000 +0100 +++ new/pytest_jupyter-0.9.1/pytest_jupyter/jupyter_core.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,15 +1,15 @@ """Fixtures for use with jupyter core and downstream.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -import asyncio import json import os import sys -import typing +from inspect import iscoroutinefunction from pathlib import Path import jupyter_core import pytest +from jupyter_core.utils import ensure_event_loop from .utils import mkdir @@ -35,34 +35,35 @@ resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard)) -@pytest.fixture() +@pytest.fixture(autouse=True) def jp_asyncio_loop(): """Get an asyncio loop.""" - if os.name == "nt": - asyncio.set_event_loop_policy( - asyncio.WindowsSelectorEventLoopPolicy() # type:ignore[attr-defined] - ) - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) + loop = ensure_event_loop(prefer_selector_loop=True) yield loop loop.close() -@pytest.fixture(autouse=True) -def io_loop(jp_asyncio_loop): - """Override the io_loop for pytest_tornasync. This is a no-op - if tornado is not installed.""" - - async def get_tornado_loop() -> typing.Any: - """Asynchronously get a tornado loop.""" - try: - from tornado.ioloop import IOLoop - - return IOLoop.current() - except ImportError: - pass - - return jp_asyncio_loop.run_until_complete(get_tornado_loop()) +@pytest.hookimpl(tryfirst=True) +def pytest_pycollect_makeitem(collector, name, obj): + """Custom pytest collection hook.""" + if collector.funcnamefilter(name) and iscoroutinefunction(obj): + return list(collector._genfunctions(name, obj)) + return None + + +@pytest.hookimpl(tryfirst=True) +def pytest_pyfunc_call(pyfuncitem): + """Custom pytest function call hook.""" + funcargs = pyfuncitem.funcargs + testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames} + + if not iscoroutinefunction(pyfuncitem.obj): + pyfuncitem.obj(**testargs) + return True + + loop = ensure_event_loop(prefer_selector_loop=True) + loop.run_until_complete(pyfuncitem.obj(**testargs)) + return True @pytest.fixture() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest_jupyter-0.8.0/pytest_jupyter/jupyter_server.py new/pytest_jupyter-0.9.1/pytest_jupyter/jupyter_server.py --- old/pytest_jupyter-0.8.0/pytest_jupyter/jupyter_server.py 2020-02-02 01:00:00.000000000 +0100 +++ new/pytest_jupyter-0.9.1/pytest_jupyter/jupyter_server.py 2020-02-02 01:00:00.000000000 +0100 @@ -3,7 +3,6 @@ # Distributed under the terms of the Modified BSD License. from __future__ import annotations -import asyncio import importlib import io import logging @@ -53,36 +52,6 @@ from pytest_jupyter.pytest_tornasync import * # noqa: F403 from pytest_jupyter.utils import mkdir -# Override some of the fixtures from pytest_tornasync -# The io_loop fixture is overridden in jupyter_core.py so it -# can be shared by other plugins that need it (e.g. jupyter_client.py). - - -@pytest.fixture() -def http_server(io_loop, http_server_port, jp_web_app): - """Start a tornado HTTP server that listens on all available interfaces.""" - - async def get_server(): - """Get a server asynchronously.""" - server = tornado.httpserver.HTTPServer(jp_web_app) - server.add_socket(http_server_port[0]) - return server - - server = io_loop.run_sync(get_server) - yield server - server.stop() - - if hasattr(server, "close_all_connections"): - try: - io_loop.run_sync(server.close_all_connections) - except asyncio.TimeoutError: - pass - - http_server_port[0].close() - - -# End pytest_tornasync overrides - @pytest.fixture() def jp_server_config(): @@ -177,7 +146,6 @@ jp_root_dir, jp_logging_stream, jp_asyncio_loop, - io_loop, ): """Starts a Jupyter Server instance based on the provided configuration values. @@ -207,7 +175,6 @@ environ=jp_environ, http_port=jp_http_port, tmp_path=tmp_path, - io_loop=io_loop, root_dir=jp_root_dir, **kwargs, ): @@ -345,7 +312,7 @@ ... """ - def client_fetch(*parts, headers=None, params=None, **kwargs): # noqa: ARG + def client_fetch(*parts, headers=None, params=None, **kwargs): if not headers: headers = {} if not params: @@ -414,6 +381,7 @@ code = r.code except HTTPClientError as err: code = err.code + print(f"HTTPClientError ({err.code}): {err}") # noqa: T201 else: if fetch is jp_ws_fetch: r.close() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest_jupyter-0.8.0/pytest_jupyter/pytest_tornasync.py new/pytest_jupyter-0.9.1/pytest_jupyter/pytest_tornasync.py --- old/pytest_jupyter-0.8.0/pytest_jupyter/pytest_tornasync.py 2020-02-02 01:00:00.000000000 +0100 +++ new/pytest_jupyter-0.9.1/pytest_jupyter/pytest_tornasync.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,8 +1,8 @@ """Vendored fork of pytest_tornasync from https://github.com/eukaryote/pytest-tornasync/blob/9f1bdeec3eb5816e0183f975c... """ +import asyncio from contextlib import closing -from inspect import iscoroutinefunction try: import tornado.ioloop @@ -14,33 +14,37 @@ import pytest # mypy: disable-error-code="no-untyped-call" +# Bring in local plugins. +from pytest_jupyter.jupyter_core import * # noqa: F403 -@pytest.hookimpl(tryfirst=True) -def pytest_pycollect_makeitem(collector, name, obj): - """Custom pytest collection hook.""" - if collector.funcnamefilter(name) and iscoroutinefunction(obj): - return list(collector._genfunctions(name, obj)) - return None - - -@pytest.hookimpl(tryfirst=True) -def pytest_pyfunc_call(pyfuncitem): - """Custom pytest function call hook.""" - funcargs = pyfuncitem.funcargs - testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames} - - if not iscoroutinefunction(pyfuncitem.obj): - pyfuncitem.obj(**testargs) - return True - - try: - loop = funcargs["io_loop"] - except KeyError: - loop = tornado.ioloop.IOLoop.current() +@pytest.fixture() +def io_loop(jp_asyncio_loop): + """Get the current tornado event loop.""" + return tornado.ioloop.IOLoop.current() + + +@pytest.fixture() +def http_server(jp_asyncio_loop, http_server_port, jp_web_app): + """Start a tornado HTTP server that listens on all available interfaces.""" + + async def get_server(): + """Get a server asynchronously.""" + server = tornado.httpserver.HTTPServer(jp_web_app) + server.add_socket(http_server_port[0]) + return server + + server = jp_asyncio_loop.run_until_complete(get_server()) + yield server + server.stop() + + if hasattr(server, "close_all_connections"): + try: + jp_asyncio_loop.run_until_complete(server.close_all_connections()) + except asyncio.TimeoutError: + pass - loop.run_sync(lambda: pyfuncitem.obj(**testargs)) - return True + http_server_port[0].close() @pytest.fixture() @@ -52,7 +56,7 @@ @pytest.fixture() -def http_server_client(http_server, io_loop): +def http_server_client(http_server, jp_asyncio_loop): """ Create an asynchronous HTTP client that can fetch from `http_server`. """ @@ -61,7 +65,7 @@ """Get a client.""" return AsyncHTTPServerClient(http_server=http_server) - client = io_loop.run_sync(get_client) + client = jp_asyncio_loop.run_until_complete(get_client()) with closing(client) as context: yield context diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest_jupyter-0.8.0/tests/test_jupyter_server.py new/pytest_jupyter-0.9.1/tests/test_jupyter_server.py --- old/pytest_jupyter-0.8.0/tests/test_jupyter_server.py 2020-02-02 01:00:00.000000000 +0100 +++ new/pytest_jupyter-0.9.1/tests/test_jupyter_server.py 2020-02-02 01:00:00.000000000 +0100 @@ -71,3 +71,7 @@ def test_extension_environ(jp_extension_environ): pass + + +def test_ioloop_fixture(io_loop): + pass
participants (1)
-
Source-Sync