From 798737a159c9430e139045b54cfaf0d7a7bef0ff Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Sun, 11 May 2025 22:40:00 +0200 Subject: [PATCH 1/3] snapshottest: 0.6.0 > 1.0.0a1 0.6.0 uses `imp` which has been deprecated in Py 3.12 and removed in 3.13. Newest snapshottest fixes the deprecation --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 22546eec..8bf18718 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -6,4 +6,4 @@ flake8==7.1.0 pytest==8.2.2 pytest-xdist==3.6.1 pytype==2024.4.11 -snapshottest==0.6.0 +snapshottest==1.0.0a1 From 92c0c5d0d31dd9a33380aa84de52685e6bb3d6cc Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Sun, 11 May 2025 20:48:45 +0000 Subject: [PATCH 2/3] Fix initialization test called_once_with -> assert_called_once_with This test was silently failing as it was using an outdated mock method --- tests/unit_tests/bot_test.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit_tests/bot_test.py b/tests/unit_tests/bot_test.py index 97a1d59d..12adf337 100644 --- a/tests/unit_tests/bot_test.py +++ b/tests/unit_tests/bot_test.py @@ -27,9 +27,10 @@ def test_init(self, login): for plugin in plugins: plugin.initialize = mock.MagicMock() + settings = Settings(MATTERMOST_URL="test_url.org", BOT_TOKEN="random_token") # Create a bot and verify that it gets initialized correctly bot = Bot( - settings=Settings(MATTERMOST_URL="test_url.org", BOT_TOKEN="random_token"), + settings=settings, plugins=plugins, ) assert bot.driver.options["url"] == "test_url.org" @@ -40,7 +41,9 @@ def test_init(self, login): # Verify that all of the passed plugins were initialized for plugin in plugins: - assert plugin.initialize.called_once_with(bot.driver) + plugin.initialize.assert_called_once_with( + bot.driver, bot.plugin_manager, settings + ) @mock.patch.multiple("mmpy_bot.Plugin", on_start=mock.DEFAULT, on_stop=mock.DEFAULT) def test_run(self, bot, **mocks): From 89ebc943e8e095f24ba0109d8913a882d3a9a90d Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Sun, 11 May 2025 21:17:26 +0000 Subject: [PATCH 3/3] Python 3.13 changed how leading space is parsed in docstrings --- tests/unit_tests/plugin_manager_test.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/unit_tests/plugin_manager_test.py b/tests/unit_tests/plugin_manager_test.py index 72bfebb2..c00f7b54 100644 --- a/tests/unit_tests/plugin_manager_test.py +++ b/tests/unit_tests/plugin_manager_test.py @@ -1,4 +1,5 @@ import re +import sys from unittest import mock import click @@ -145,13 +146,14 @@ def test_get_help(self): for hlp in self.plugin_manager.get_help(): assert hlp.location == "FakePlugin" - assert ( - hlp.function.plugin.__doc__ - == """Hello FakePlugin. + if sys.version_info >= (3, 13): + test_doc = "Hello FakePlugin.\n\nThis is a plugin level docstring\n" + else: + test_doc = """Hello FakePlugin. This is a plugin level docstring """ - ) + assert hlp.function.plugin.__doc__ == test_doc assert hlp.is_click == hlp.function.is_click_function assert hlp.docfull.startswith(hlp.function.__doc__)