Created
February 5, 2025 19:57
-
-
Save jangia/2c50b02a23f647dc9782e6e0a52eabb9 to your computer and use it in GitHub Desktop.
Parametrize tests using pytest - abuse
This file contains hidden or 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 email_validator import is_valid_email | |
| @pytest.mark.parametrize( | |
| "email,is_valid", | |
| [ | |
| ("[email protected]", True), | |
| ("gqehtjwyeumi,", False), | |
| ] | |
| ) | |
| def test_is_valid_email(email: str, is_valid: bool): | |
| assert is_valid_email(email) == is_valid | |
| @pytest.mark.parametrize( | |
| "email,is_valid", | |
| [ | |
| ("[email protected]", True), | |
| ("gqehtjwyeumi,", False), | |
| ] | |
| ) | |
| def test_is_valid_email(email: str, is_valid: bool): | |
| if is_valid: | |
| assert is_valid_email(email) is True | |
| else: | |
| assert is_valid_email(email) is False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment