aboutsummaryrefslogtreecommitdiff
path: root/tests/conftest.py
blob: 85d2ec3d972b33c39fc413722ea2afe315a5c9f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import Any, Callable, TypeVar

import pytest
from mypy_extensions import KwArg

from poker.constants import Suit, Value
from poker.models import Card

T = TypeVar("T")
Factory = Callable[[KwArg(Any)], T]


@pytest.fixture(scope="session")
def card_factory() -> Factory[Card]:
    """Get Card object factory."""
    default = {
        "suit": Suit.CLUBS,
        "value": Value.ACE,
    }

    def factory(**kwargs: Any) -> Card:
        return Card(**(default | kwargs))

    return factory