Consolidate test fixtures

This commit is contained in:
Correl Roush 2018-10-12 17:02:17 -04:00 committed by Correl Roush
parent 8c18de5e6f
commit 8b00d44f39
6 changed files with 18 additions and 20 deletions

0
tests/__init__.py Normal file
View file

8
tests/fixtures.py Normal file
View 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

View file

@ -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)

View file

@ -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

View file

@ -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:

View file

@ -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