diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 609feec..785fbfb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.10"] # Ensure that all flavours are run to completion even if an other flavor failed fail-fast: false diff --git a/pytest-testslide/requirements.txt b/pytest-testslide/requirements.txt index b69b75d..a846a97 100644 --- a/pytest-testslide/requirements.txt +++ b/pytest-testslide/requirements.txt @@ -1,2 +1,2 @@ -pytest~=7.3 +pytest>=9.0.3 pytest-asyncio>=0.14.0 diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..0fb60a7 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +pythonpath = . pytest-testslide diff --git a/tests/cli_unittest.py b/tests/cli_unittest.py index 38ad955..2ed1c91 100644 --- a/tests/cli_unittest.py +++ b/tests/cli_unittest.py @@ -285,10 +285,10 @@ def test_prints_exceptions_with_cause(self): expected_return_code=1, expected_in_stdout=( ' File \x1b[36m"tests/sample_tests.py"\x1b[39;49;00m, line \x1b[94m76\x1b[39;49;00m, in test_failing\x1b[37m\x1b[39;49;00m\r\n' - ' \x1b[37m \x1b[39;49;00m\x1b[94mraise\x1b[39;49;00m \x1b[36mAssertionError\x1b[39;49;00m(\x1b[33m"\x1b[39;49;00m\x1b[33mThird\x1b[39;49;00m\x1b[33m"\x1b[39;49;00m) \x1b[94mfrom\x1b[39;49;00m \x1b[04m\x1b[36mcause\x1b[39;49;00m\x1b[37m\x1b[39;49;00m\r\n' + ' \x1b[37m \x1b[39;49;00m\x1b[94mraise\x1b[39;49;00m \x1b[36mAssertionError\x1b[39;49;00m(\x1b[33m"\x1b[39;49;00m\x1b[33mThird\x1b[39;49;00m\x1b[33m"\x1b[39;49;00m) \x1b[94mfrom\x1b[39;49;00m\x1b[37m \x1b[39;49;00m\x1b[04m\x1b[36mcause\x1b[39;49;00m\x1b[37m\x1b[39;49;00m\r\n' "\x1b[0m\x1b[31m Caused by \x1b[0m\x1b[0m\x1b[31mAssertionError: Second\x1b[0m\r\n" ' File \x1b[36m"tests/sample_tests.py"\x1b[39;49;00m, line \x1b[94m74\x1b[39;49;00m, in test_failing\x1b[37m\x1b[39;49;00m\r\n' - ' \x1b[37m \x1b[39;49;00m\x1b[94mraise\x1b[39;49;00m \x1b[36mAssertionError\x1b[39;49;00m(\x1b[33m"\x1b[39;49;00m\x1b[33mSecond\x1b[39;49;00m\x1b[33m"\x1b[39;49;00m) \x1b[94mfrom\x1b[39;49;00m \x1b[04m\x1b[36mcause\x1b[39;49;00m\x1b[37m\x1b[39;49;00m\r\n' + ' \x1b[37m \x1b[39;49;00m\x1b[94mraise\x1b[39;49;00m \x1b[36mAssertionError\x1b[39;49;00m(\x1b[33m"\x1b[39;49;00m\x1b[33mSecond\x1b[39;49;00m\x1b[33m"\x1b[39;49;00m) \x1b[94mfrom\x1b[39;49;00m\x1b[37m \x1b[39;49;00m\x1b[04m\x1b[36mcause\x1b[39;49;00m\x1b[37m\x1b[39;49;00m\r\n' "\x1b[0m\x1b[31m Caused by \x1b[0m\x1b[0m\x1b[31mAssertionError: First\x1b[0m\r\n" ' File \x1b[36m"tests/sample_tests.py"\x1b[39;49;00m, line \x1b[94m72\x1b[39;49;00m, in test_failing\x1b[37m\x1b[39;49;00m\r\n' ' \x1b[37m \x1b[39;49;00m\x1b[94mraise\x1b[39;49;00m \x1b[36mAssertionError\x1b[39;49;00m(\x1b[33m"\x1b[39;49;00m\x1b[33mFirst\x1b[39;49;00m\x1b[33m"\x1b[39;49;00m)\x1b[37m\x1b[39;49;00m\r\n' diff --git a/tests/mock_async_callable_testslide.py b/tests/mock_async_callable_testslide.py index 18c1ed9..161ee4a 100644 --- a/tests/mock_async_callable_testslide.py +++ b/tests/mock_async_callable_testslide.py @@ -176,7 +176,7 @@ async def raises_TypeCheckError_when_returning_coroutine_instance(self): with self.assertRaisesRegex( TypeCheckError, - r"^type of return must be typing.List\[str\]; got .+(asyncio|coroutine)", + r"^type of return must be list\[str\]; got .+(asyncio|coroutine)", ): await self.callable_target(*self.call_args, **self.call_kwargs) diff --git a/testslide/bdd/lib.py b/testslide/bdd/lib.py index 6583d94..be72e67 100644 --- a/testslide/bdd/lib.py +++ b/testslide/bdd/lib.py @@ -9,7 +9,6 @@ import inspect import os import re -import sys import time import types import unittest diff --git a/testslide/core/__init__.py b/testslide/core/__init__.py index 1706ee9..89c1d1f 100644 --- a/testslide/core/__init__.py +++ b/testslide/core/__init__.py @@ -13,7 +13,6 @@ coverage.process_startup() import os -import sys import unittest from typing import Any diff --git a/testslide/core/lib.py b/testslide/core/lib.py index b6ba14f..57fe61d 100644 --- a/testslide/core/lib.py +++ b/testslide/core/lib.py @@ -14,7 +14,7 @@ from functools import wraps from inspect import Traceback from types import FrameType -from typing import Any, TYPE_CHECKING, Union +from typing import Any, cast, TYPE_CHECKING, Union from unittest.mock import Mock import typeguard @@ -95,7 +95,7 @@ def _extract_mock_template( template = None for mock_class, extract_mock_template in MOCK_TEMPLATE_EXTRACTORS.items(): if isinstance(mock, mock_class): - template = extract_mock_template(mock) + template = extract_mock_template(cast(Mock, mock)) return template diff --git a/testslide/core/mock_callable.py b/testslide/core/mock_callable.py index 2948c00..0a1073a 100644 --- a/testslide/core/mock_callable.py +++ b/testslide/core/mock_callable.py @@ -98,12 +98,7 @@ def unpatch_all_callable_mocks() -> None: This method must be called after every test unconditionally to remove all active mock_callable() patches. """ - global \ - register_assertion, \ - _default_register_assertion, \ - _call_order_assertion_registered, \ - _received_ordered_calls, \ - _expected_ordered_calls + global register_assertion, _default_register_assertion, _call_order_assertion_registered, _received_ordered_calls, _expected_ordered_calls # noqa: F824 register_assertion = _default_register_assertion _call_order_assertion_registered = False @@ -122,7 +117,7 @@ def unpatch_all_callable_mocks() -> None: def _is_setup() -> bool: - global register_assertion, _default_register_assertion + global register_assertion, _default_register_assertion # noqa: F824 return register_assertion is not _default_register_assertion @@ -232,7 +227,7 @@ def __init__( self._accept_partial_call = False def register_call(self, *args: Any, **kwargs: Any) -> None: - global _received_ordered_calls + global _received_ordered_calls # noqa: F824 if self._has_order_assertion: _received_ordered_calls.append((self.target, self.method, self)) @@ -367,10 +362,7 @@ def assertion() -> None: register_assertion(assertion) def add_call_order_assertion(self) -> None: - global \ - _call_order_assertion_registered, \ - _received_ordered_calls, \ - _expected_ordered_calls + global _call_order_assertion_registered, _received_ordered_calls, _expected_ordered_calls # noqa: F824 if not _call_order_assertion_registered: