Last active
May 10, 2016 08:23
-
-
Save cyberbikepunk/9640a3585d1400cb9a9dc4a5130edb46 to your computer and use it in GitHub Desktop.
StackOverflow Question 37124766
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 pytest import mark | |
items = [ | |
{ | |
'text': 'bla bla', | |
'fields': [('bla', 0), ('foo', -1)] | |
}, | |
{ | |
'text': 'foo bar', | |
'fields': [('bla', -1), ('foo', 0), ('bar', 4)] | |
} | |
] | |
def make_item_iterator(): | |
for item in items: | |
for field in item['fields']: | |
yield (item['text'], *field) | |
# noinspection PyShadowingNames | |
@mark.parametrize('haystack, needle, index', make_item_iterator()) | |
def test_parser(haystack, needle, index): | |
assert haystack.find(needle) == index |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment