Last active
July 26, 2023 20:39
-
-
Save franciellyferreira/972db6326ecd6b68b6c57c15ad5c784c to your computer and use it in GitHub Desktop.
Pytest - Test Parametrize Using Fixture
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
from enum import Enum | |
class TeamEnum(Enum): | |
TEAM_CHICAGO = 'chicago_bulls' |
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 projeto.enum import TeamEnum | |
class TestTeamEnum: | |
@pytest.fixture | |
def team(self): | |
return 'chicago_bulls' | |
@pytest.mark.parametrize( | |
'team_enum,team_name', | |
[ | |
( | |
TeamEnum.TEAM_CHICAGO, | |
'team' | |
) | |
] | |
) | |
def test_should_return_correct_team_name( | |
self, | |
team_enum, | |
team_name, | |
request | |
): | |
team_value = request.getfixturevalue(team_name) | |
assert team_value == team_enum.value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment