rougail/tests/test_doc.py

40 lines
1,019 B
Python
Raw Normal View History

2023-10-12 08:17:30 +02:00
from os import listdir
from pathlib import Path
from pytest import fixture, raises
doc = Path('doc')
tmp = Path('test', 'tmp')
scripts = {}
for filename in doc.glob('*/*.md'):
scripts[filename] = []
with open(filename) as fh:
yaml = False
redefine = False
for line in fh.readlines():
if line == '```\n':
if redefine:
scripts[filename][-1].append(new_script)
else:
scripts[filename].append([new_script])
yaml = False
redefine = False
if yaml:
if line.strip() == 'redefine: true':
redefine = True
new_script += line
if line == '```yml\n':
yaml = True
new_script = ''
@fixture(scope="module", params=scripts)
def test_dir(request):
return [(request.param, scripts_) for scripts_ in scripts[request.param]]
def test_scripts(test_dir):
print(test_dir)