Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pytest-testslide/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pytest~=7.3
pytest>=9.0.3
pytest-asyncio>=0.14.0
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
pythonpath = . pytest-testslide
4 changes: 2 additions & 2 deletions tests/cli_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_async_callable_testslide.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion testslide/bdd/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import inspect
import os
import re
import sys
import time
import types
import unittest
Expand Down
1 change: 0 additions & 1 deletion testslide/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
coverage.process_startup()

import os
import sys
import unittest
from typing import Any

Expand Down
4 changes: 2 additions & 2 deletions testslide/core/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down
16 changes: 4 additions & 12 deletions testslide/core/mock_callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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:

Expand Down
Loading