Skip to content

Instantly share code, notes, and snippets.

@cyberbikepunk
Last active May 10, 2016 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyberbikepunk/9640a3585d1400cb9a9dc4a5130edb46 to your computer and use it in GitHub Desktop.
Save cyberbikepunk/9640a3585d1400cb9a9dc4a5130edb46 to your computer and use it in GitHub Desktop.
StackOverflow Question 37124766
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