Skip to content

Commit

Permalink
bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Nov 7, 2024
1 parent b4cb895 commit 1d7bff3
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 52 deletions.
17 changes: 9 additions & 8 deletions pytest_robotframework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pathlib import Path
from traceback import format_stack
from types import TracebackType
from typing import TYPE_CHECKING, Callable, TypeVar, Union, cast, overload
from typing import TYPE_CHECKING, Callable, TypeVar, Union, cast, final, overload

from basedtyping import Function, P, T
from pytest import StashKey
Expand Down Expand Up @@ -189,10 +189,10 @@ def __init__(
doc: str | None = None,
) -> None:
super().__init__()
self._name = name
self._tags = tags or ()
self._module = module
self._doc = doc
self._name: str | None = name
self._tags: tuple[str, ...] = tags or ()
self._module: str | None = module
self._doc: str | None = doc

@staticmethod
def _save_status_reporter_failure(exception: BaseException):
Expand Down Expand Up @@ -357,6 +357,7 @@ def inner(
) -> T:
T_WrappedContextManager = TypeVar("T_WrappedContextManager")

@final
class WrappedContextManager(AbstractContextManager[object]):
"""defers exiting the status reporter until after the wrapped context
manager is finished"""
Expand Down Expand Up @@ -652,7 +653,7 @@ def __init__(
fail_message: str | None = None,
) -> None:
super().__init__()
self.log_pass = log_pass
self.log_pass: bool | None = log_pass
"""whether to display the assertion as a keyword in the robot log when it passes.
by default, a passing `assert` statement will display in the robot log as long as the
Expand Down Expand Up @@ -683,13 +684,13 @@ def __init__(
assert foo == bar
"""

self.description = description
self.description: str | None = description
"""normally, the asserted expression as it was written is displayed as the argument to the
`assert` keyword in the robot log, but setting this value will display a custom message
instead. when a custom description is used, the original expression is logged inside the
keyword instead."""

self.fail_message = fail_message
self.fail_message: str | None = fail_message
"""optional description for the `assert` statement that will be included in the
`AssertionError` message if the assertion fails. equivalent to a normal `assert` statement's
second argument"""
Expand Down
7 changes: 5 additions & 2 deletions pytest_robotframework/_internal/pytest/robot_file_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import dataclasses
from contextlib import contextmanager
from typing import TYPE_CHECKING, Callable, cast
from typing import TYPE_CHECKING, Callable, cast, final

from _pytest._code.code import ReprFileLocation, TerminalRepr
from pytest import Config, ExceptionInfo, File, Item, MarkDecorator, Session, StashKey, mark, skip
Expand Down Expand Up @@ -69,7 +69,10 @@ def collect(self) -> Iterable[Item]:
)


class RobotItem(Item):
@final
# some internal deprecated pytest thing is causing this false positive, but apparently it will be
# removed in the future
class RobotItem(Item): # pyright:ignore[reportUninitializedInstanceVariable]
def __init__(
self,
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from inspect import getdoc
from re import sub
from types import MethodType
from typing import TYPE_CHECKING, Callable, Final, Literal, Optional, TypeVar, cast
from typing import TYPE_CHECKING, Callable, Final, Literal, Optional, TypeVar, cast, final

from _pytest import runner
from _pytest.python import PyobjMixin
Expand Down Expand Up @@ -78,6 +78,7 @@ def _create_running_keyword(
return running.Keyword(name=f"{fn.__module__}.{fn.__name__}", args=args, type=keyword_type)


@final
class PythonParser(Parser):
"""custom robot "parser" for python files. doesn't actually do any parsing, but instead relies
on pytest collection already being run, so it can use the collected items to populate a robot
Expand Down Expand Up @@ -197,6 +198,7 @@ def __init__(self) -> None:


@catch_errors
@final
class RobotSuiteCollector(SuiteVisitor):
"""used when running robot during collection to collect it the suites from `.robot` files so
that pytest items can be created from them in `_internal.pytest.robot_file_support`"""
Expand All @@ -220,6 +222,7 @@ def end_suite(self, suite: ModelTestSuite):


@catch_errors
@final
class RobotTestFilterer(SuiteVisitor):
"""
does the following to prepare the tests for execution:
Expand Down Expand Up @@ -263,6 +266,7 @@ def end_suite(self, suite: ModelTestSuite):


@catch_errors
@final
class PytestRuntestProtocolInjector(SuiteVisitor):
"""injects the setup, call and teardown hooks from `_pytest.runner.pytest_runtest_protocol` into
the robot test suite. this replaces any existing setup/body/teardown with said hooks, which may
Expand Down Expand Up @@ -324,6 +328,7 @@ def start_suite(self, suite: ModelTestSuite):


@catch_errors
@final
class PytestRuntestProtocolHooks(ListenerV3):
"""runs the `pytest_runtest_logstart` and `pytest_runtest_logfinish` hooks from
`pytest_runtest_protocol`. since all the other parts of `_pytest.runner.runtestprotocol` are
Expand Down Expand Up @@ -495,6 +500,7 @@ def end_test(


@catch_errors
@final
class ErrorDetector(ListenerV3):
"""since errors logged by robot don't raise an exception and therefore won't cause the pytest
test to fail (or even the robot test unless `--exitonerror` is enabled), we need to listen for
Expand Down Expand Up @@ -544,6 +550,7 @@ def log_message(self, message: model.Message):


@catch_errors
@final
class AnsiLogger(ListenerV3):
esc = "\N{ESCAPE}"

Expand Down
3 changes: 2 additions & 1 deletion pytest_robotframework/_internal/robot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
TypedDict,
Union,
cast,
final,
)

from basedtyping import T
Expand Down Expand Up @@ -150,11 +151,11 @@ class RobotOptions(TypedDict):
"""robot arguments that are not allowed because they conflict with pytest and/or this plugin"""


@final
class Cloaked(Generic[T]):
"""allows you to pass arguments to robot keywords without them appearing in the log"""

def __init__(self, value: T):
super().__init__()
self.value = value

@override
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from shutil import copy, copytree
from types import ModuleType
from typing import TYPE_CHECKING, Literal, cast, overload
from typing import TYPE_CHECKING, Literal, cast, final, overload

from lxml.etree import (
XML,
Expand Down Expand Up @@ -134,6 +134,7 @@ def _is_element_list(xpath_object: _XPathObject) -> TypeGuard[list[_Element]]:
return result


@final
class _XmlElement(Iterable["_XmlElement"]):
def __init__(self, element: _Element) -> None:
super().__init__()
Expand Down Expand Up @@ -219,6 +220,7 @@ def assert_robot_total_stats(*, passed: int = 0, skipped: int = 0, failed: int =
assert result == {"pass": str(passed), "fail": str(failed), "skip": str(skipped)}


@final
class PytestRobotTester:
def __init__(self, *, pytester: PytesterDir, xdist: int | None):
super().__init__()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, final

from robot.api.interfaces import ListenerV3
from typing_extensions import override
Expand All @@ -11,6 +11,7 @@
from pytest_robotframework import RobotOptions


@final
class Foo(ListenerV3):
def __init__(self):
super().__init__()
Expand Down
Loading

0 comments on commit 1d7bff3

Please sign in to comment.