Created
October 30, 2018 14:30
-
-
Save jdevera/6e5aed88ad7a5d159df68efb2c581f69 to your computer and use it in GitHub Desktop.
Example of Pytest parameterization of tests
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 re | |
import pytest | |
def camel_to_snake(string): | |
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', string) | |
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | |
CASES = [ | |
('ISeeALittle', 'i_see_a_little'), | |
('iSeeALittle', 'i_see_a_little'), | |
('NotInventedHere', 'not_invented_here'), | |
('notInventedHere', 'not_invented_here'), | |
('JKRowling', 'j_k_rowling'), | |
('URRight', 'u_r_right') | |
] | |
@pytest.mark.parametrize("orig,expected", CASES) | |
def test(orig, expected): | |
assert camel_to_snake(orig) == expected |
Author
jdevera
commented
Oct 30, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment