Skip to content

Commit 3a9ae69

Browse files
Add a hypothesis test case with an expected failure (#652)
* Actives the strict mode of xfail * Creates a hypothesis test with a wrong class implementation that should fail
1 parent 8c8820b commit 3a9ae69

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ strictness = long
9696
# ignores some directories:
9797
norecursedirs = *.egg .eggs dist build docs .tox .git __pycache__
9898

99+
# Active the strict mode of xfail
100+
xfail_strict = true
101+
99102
# Adds these options to each `pytest` run:
100103
addopts =
101104
--doctest-modules
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from typing import Callable, TypeVar
2+
3+
import pytest
4+
5+
from returns.contrib.hypothesis.laws import check_all_laws
6+
from returns.interfaces import mappable
7+
from returns.primitives.container import BaseContainer
8+
from returns.primitives.hkt import SupportsKind1
9+
10+
pytestmark = pytest.mark.xfail
11+
12+
_ValueType = TypeVar('_ValueType')
13+
_NewValueType = TypeVar('_NewValueType')
14+
15+
16+
class _Wrapper(
17+
BaseContainer,
18+
SupportsKind1['_Wrapper', _ValueType],
19+
mappable.Mappable1[_ValueType],
20+
):
21+
_inner_value: _ValueType
22+
23+
def __init__(self, inner_value: _ValueType) -> None:
24+
super().__init__(inner_value)
25+
26+
def map( # noqa: WPS125
27+
self,
28+
function: Callable[[_ValueType], _NewValueType],
29+
) -> '_Wrapper[_NewValueType]':
30+
return _Wrapper(
31+
'wrong-{0}'.format(function(self._inner_value)), # type: ignore
32+
)
33+
34+
35+
check_all_laws(_Wrapper, use_init=True)

0 commit comments

Comments
 (0)