From ee3d0d9e0be48d0133c988189a7896f1daad21fd Mon Sep 17 00:00:00 2001 From: Russell Martin Date: Fri, 14 Jun 2024 11:33:51 -0400 Subject: [PATCH 1/4] Use latest dependencies for Testbed testing - Recent versions of pytest-asyncio introduced a lot of breaking changes. Notably, a session-wide event loop can no longer be specified via the ``event_loop()`` fixture. However, an event loop policy can be specified via the ``event_loop_policy()`` fixture. - As such, this introduces a simple event loop policy that defers to the existing event loop proxy. --- changes/2382.misc.rst | 1 + testbed/pyproject.toml | 6 +++--- testbed/tests/conftest.py | 20 ++++++++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 changes/2382.misc.rst diff --git a/changes/2382.misc.rst b/changes/2382.misc.rst new file mode 100644 index 0000000000..38ad904859 --- /dev/null +++ b/changes/2382.misc.rst @@ -0,0 +1 @@ +The Testbed tests were updated to use the latest testing dependencies. diff --git a/testbed/pyproject.toml b/testbed/pyproject.toml index c8e4a114e3..fdacec755c 100644 --- a/testbed/pyproject.toml +++ b/testbed/pyproject.toml @@ -22,9 +22,9 @@ requires = [ "../core", ] test_requires = [ - "coverage==7.2.0", - "pytest==7.2.0", - "pytest-asyncio==0.20.3", + "coverage==7.5.3", + "pytest==8.2.2", + "pytest-asyncio==0.23.7", "pillow==9.2.0", ] diff --git a/testbed/tests/conftest.py b/testbed/tests/conftest.py index 9f92531791..057d4175d3 100644 --- a/testbed/tests/conftest.py +++ b/testbed/tests/conftest.py @@ -69,14 +69,22 @@ async def main_window_probe(app, main_window): # Controls the event loop used by pytest-asyncio. @fixture(scope="session") -def event_loop(app): - loop = ProxyEventLoop(app._impl.loop) - yield loop - loop.close() +def event_loop_policy(app): + yield ProxyEventLoopPolicy(ProxyEventLoop(app._impl.loop)) -# Proxy which forwards all tasks to another event loop in a thread-safe manner. It -# implements only the methods used by pytest-asyncio. +# Loop policy that ensures proxy loop is always used. +class ProxyEventLoopPolicy(asyncio.DefaultEventLoopPolicy): + def __init__(self, proxy_loop: "ProxyEventLoop"): + super().__init__() + self._proxy_loop = proxy_loop + + def new_event_loop(self): + return self._proxy_loop + + +# Proxy which forwards all tasks to another event loop in a thread-safe manner. +# It implements only the methods used by pytest-asyncio. @dataclass class ProxyEventLoop(asyncio.AbstractEventLoop): loop: object From ef41da1ca271247d07dfbe479f12beea28ec028d Mon Sep 17 00:00:00 2001 From: Russell Martin Date: Fri, 14 Jun 2024 17:51:20 -0400 Subject: [PATCH 2/4] Allow Dependabot to manage testbed's dependencies --- .github/dependabot.yml | 11 +++++++++++ testbed/pyproject.toml | 28 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f11176abf5..a917719b4f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -72,3 +72,14 @@ updates: interval: "weekly" day: "sunday" time: "20:00" + + - package-ecosystem: "pip" + directory: "/testbed" + ignore: + # pin PIL for Android and iOS + - dependency-name: "pillow" + schedule: + # Check for updates on Sunday, 8PM UTC + interval: "weekly" + day: "sunday" + time: "20:00" diff --git a/testbed/pyproject.toml b/testbed/pyproject.toml index fdacec755c..f7ab0e174a 100644 --- a/testbed/pyproject.toml +++ b/testbed/pyproject.toml @@ -1,8 +1,20 @@ -# This project was generated using template: https://github.com/beeware/briefcase-template and branch: v0.3.12 +[project] +name = "testbed" +version = "0.0.1" +dependencies = ["../core"] + +[project.optional-dependencies] +test = [ + "coverage==7.5.3", + "fonttools==4.53.0", + "pillow==9.2.0", + "pytest==8.2.2", + "pytest-asyncio==0.23.7", +] + [tool.briefcase] project_name = "Toga Testbed" bundle = "org.beeware.toga" -version = "0.0.1" url = "https://beeware.org" license.file = "LICENSE" author = "Tiberius Yak" @@ -18,15 +30,6 @@ sources = [ test_sources = [ "tests", ] -requires = [ - "../core", -] -test_requires = [ - "coverage==7.5.3", - "pytest==8.2.2", - "pytest-asyncio==0.23.7", - "pillow==9.2.0", -] permission.camera = "The testbed needs to exercise Camera APIs" permission.fine_location = "The testbed needs to exercise fine-grained geolocation services." @@ -76,9 +79,6 @@ test_sources = [ requires = [ "../android", ] -test_requires = [ - "fonttools==4.42.1", -] base_theme = "Theme.MaterialComponents.Light.DarkActionBar" From 94597f270f32ea5a4a876a32950331dcd8673a80 Mon Sep 17 00:00:00 2001 From: Russell Martin Date: Fri, 14 Jun 2024 21:06:56 -0400 Subject: [PATCH 3/4] Limit testbed `fonttools` dependency to Android (and Linux for now) Co-authored-by: Russell Keith-Magee --- testbed/pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testbed/pyproject.toml b/testbed/pyproject.toml index f7ab0e174a..200cac5a9a 100644 --- a/testbed/pyproject.toml +++ b/testbed/pyproject.toml @@ -6,7 +6,10 @@ dependencies = ["../core"] [project.optional-dependencies] test = [ "coverage==7.5.3", - "fonttools==4.53.0", + # fonttools is only needed by Android, but we need to use + # sys.platform == 'linux' as there's no dependency identifier + # that can target Android exclusively until 3.13 lands. + "fonttools==4.53.0 ; sys.platform == 'linux'", "pillow==9.2.0", "pytest==8.2.2", "pytest-asyncio==0.23.7", From 21921a9a5394f2d472f6c3a563db0ac690166b0e Mon Sep 17 00:00:00 2001 From: Russell Martin Date: Fri, 14 Jun 2024 21:11:34 -0400 Subject: [PATCH 4/4] Fix pre-commit errors from commit in GitHub --- testbed/pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testbed/pyproject.toml b/testbed/pyproject.toml index 200cac5a9a..b2f928bfc5 100644 --- a/testbed/pyproject.toml +++ b/testbed/pyproject.toml @@ -6,9 +6,9 @@ dependencies = ["../core"] [project.optional-dependencies] test = [ "coverage==7.5.3", - # fonttools is only needed by Android, but we need to use + # fonttools is only needed by Android, but we need to use # sys.platform == 'linux' as there's no dependency identifier - # that can target Android exclusively until 3.13 lands. + # that can target Android exclusively until 3.13 lands. "fonttools==4.53.0 ; sys.platform == 'linux'", "pillow==9.2.0", "pytest==8.2.2",