test: add test for _get_wrapped_function
This commit is contained in:
parent
6c4682cb07
commit
a412a90e5d
|
@ -1216,9 +1216,11 @@ class FixtureFunctionDefinition:
|
|||
)
|
||||
fail(message, pytrace=False)
|
||||
|
||||
def _get_wrapped_function(self):
|
||||
def _get_wrapped_function(self) -> Callable[..., Any]:
|
||||
if self._instance is not None:
|
||||
return self._fixture_function.__get__(self._instance)
|
||||
return cast(
|
||||
Callable[..., Any], self._fixture_function.__get__(self._instance)
|
||||
)
|
||||
return self._fixture_function
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import inspect
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
@ -3295,6 +3296,33 @@ class TestFixtureMarker:
|
|||
assert output1 == output2
|
||||
|
||||
|
||||
class FixtureFunctionDefTestClass:
|
||||
def __init__(self) -> None:
|
||||
self.i = 10
|
||||
|
||||
@pytest.fixture
|
||||
def fixture_function_def_test_method(self):
|
||||
return self.i
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fixture_function_def_test_func():
|
||||
return 9
|
||||
|
||||
|
||||
def test_get_wrapped_func_returns_method():
|
||||
obj = FixtureFunctionDefTestClass()
|
||||
wrapped_function_result = (
|
||||
obj.fixture_function_def_test_method._get_wrapped_function()
|
||||
)
|
||||
assert inspect.ismethod(wrapped_function_result)
|
||||
assert wrapped_function_result() == 10
|
||||
|
||||
|
||||
def test_get_wrapped_func_returns_function():
|
||||
assert fixture_function_def_test_func._get_wrapped_function()() == 9
|
||||
|
||||
|
||||
class TestRequestScopeAccess:
|
||||
pytestmark = pytest.mark.parametrize(
|
||||
("scope", "ok", "error"),
|
||||
|
|
Loading…
Reference in New Issue