Created
January 3, 2020 21:20
-
-
Save mrzechonek/4fb39304f7c24801cc419a9297f986f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from typing import NamedTuple | |
class SomeFixture(NamedTuple): | |
first_option: bool = False | |
second_option: bool = True | |
@pytest.fixture | |
def some_fixture(request): | |
marker = request.node.get_closest_marker('some_fixture') | |
return SomeFixture(*marker.args, **marker.kwargs) if marker else SomeFixture() | |
def test_default_options(some_fixture): | |
assert some_fixture.first_option is False | |
assert some_fixture.second_option is True | |
@pytest.mark.some_fixture(first_option=True, second_option=False) | |
def test_custom_options(some_fixture): | |
assert some_fixture.first_option is True | |
assert some_fixture.second_option is False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment