Give meaningful names to tests derived from examples.
This commit is contained in:
committed by
Julio Castillo
parent
cf423998f0
commit
56da26620a
@@ -34,6 +34,7 @@ def pytest_generate_tests(metafunc):
|
||||
continue
|
||||
doc = marko.parse(readme.read_text())
|
||||
index = 0
|
||||
last_header = None
|
||||
for child in doc.children:
|
||||
if isinstance(child, marko.block.FencedCode) and child.lang == 'hcl':
|
||||
index += 1
|
||||
@@ -41,6 +42,12 @@ def pytest_generate_tests(metafunc):
|
||||
if 'tftest skip' in code:
|
||||
continue
|
||||
examples.append(code)
|
||||
ids.append(f'{module.stem}:example{index}')
|
||||
name = f'{module.stem}:{last_header}'
|
||||
if index > 1:
|
||||
name += f' {index}'
|
||||
ids.append(name)
|
||||
elif isinstance(child, marko.block.Heading):
|
||||
last_header = child.children[0].children
|
||||
index = 0
|
||||
|
||||
metafunc.parametrize('example', examples, ids=ids)
|
||||
|
||||
Reference in New Issue
Block a user