diff --git a/tests/doc_examples/conftest.py b/tests/doc_examples/conftest.py index 7ff815584..6289a5802 100644 --- a/tests/doc_examples/conftest.py +++ b/tests/doc_examples/conftest.py @@ -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)