From 05eadc946e31f65aa5cf527014f0112e5f96bc53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20V=2E=20Treider?= Date: Sun, 13 Oct 2024 18:32:12 +0200 Subject: [PATCH] fix 3.13 test runners (#1976) --- .github/workflows/build.yml | 2 +- tests/tests_unit/test_data_classes/test_capabilities.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 406388f29..a6acbf686 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: with: extras: "-E pandas" - name: Linting and static code checks - run: pre-commit run --all-files + run: pre-commit run --all-files --show-diff-on-failure build_docs: runs-on: ubuntu-latest diff --git a/tests/tests_unit/test_data_classes/test_capabilities.py b/tests/tests_unit/test_data_classes/test_capabilities.py index ceb884d98..34d197e24 100644 --- a/tests/tests_unit/test_data_classes/test_capabilities.py +++ b/tests/tests_unit/test_data_classes/test_capabilities.py @@ -591,11 +591,12 @@ def test_idscopes_camel_case(): @pytest.mark.parametrize("capability", Capability.__subclasses__()) def test_show_example_usage(capability): + # This test ensures that the example usage given in error messages etc. works by executing it. if capability is UnknownAcl: assert not capability.show_example_usage() elif capability is capabilities_module.LegacyCapability: pytest.skip("LegacyCapability is abstract") else: - cmd = capability.show_example_usage()[15:] # TODO PY39: .removeprefix - exec(f"{capability.__name__} = capabilities_module.{capability.__name__}") + cmd = capability.show_example_usage().removeprefix("Example usage: ") + exec(f"{capability.__name__} = capabilities_module.{capability.__name__}", globals()) exec(cmd)