mirror of
https://github.com/correl/typesafe-monads.git
synced 2024-11-21 19:18:42 +00:00
Consolidate test fixtures
This commit is contained in:
parent
8c18de5e6f
commit
8b00d44f39
6 changed files with 18 additions and 20 deletions
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
8
tests/fixtures.py
Normal file
8
tests/fixtures.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
import pytest # type: ignore
|
||||
from typing import Type
|
||||
from monads import Maybe, Result
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", params=[Maybe, Result])
|
||||
def monad(request) -> Type:
|
||||
return request.param
|
|
@ -1,17 +1,13 @@
|
|||
import pytest # type: ignore
|
||||
from typing import Callable, Type, TypeVar
|
||||
from typing import Callable, TypeVar
|
||||
|
||||
from monads import Applicative, Functor, Maybe, Result
|
||||
from monads import Applicative
|
||||
from .fixtures import monad
|
||||
|
||||
T = TypeVar("T")
|
||||
S = TypeVar("S")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", params=[Maybe, Result])
|
||||
def monad(request) -> Type:
|
||||
return request.param
|
||||
|
||||
|
||||
def test_fmap_using_ap(monad) -> None:
|
||||
f: Callable[[int], int] = lambda x: x + 1
|
||||
m: Applicative[int] = monad.pure(3)
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
import pytest # type: ignore
|
||||
from typing import Callable, Type, TypeVar
|
||||
from monads import Functor, Maybe, Result
|
||||
from typing import Callable, TypeVar
|
||||
|
||||
from monads import Functor
|
||||
from .fixtures import monad
|
||||
|
||||
T = TypeVar("T")
|
||||
S = TypeVar("S")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", params=[Maybe, Result])
|
||||
def monad(request) -> Type:
|
||||
return request.param
|
||||
|
||||
|
||||
def test_identity(monad) -> None:
|
||||
m: Functor = monad.pure(3)
|
||||
identity: Callable[[T], T] = lambda x: x
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import pytest # type: ignore
|
||||
from typing import List, Type
|
||||
from monads import Monad, Maybe, Result
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", params=[Maybe, Result])
|
||||
def monad(request) -> Type:
|
||||
return request.param
|
||||
from monads import Monad
|
||||
from .fixtures import monad
|
||||
|
||||
|
||||
def test_bind(monad) -> None:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import pytest # type: ignore
|
||||
from typing import Any, Callable, Type
|
||||
|
||||
from monads.monoid import Monoid
|
||||
from monads.maybe import First, Last, Just
|
||||
|
||||
|
|
Loading…
Reference in a new issue