Skip to content

Commit

Permalink
fixedbad dict lookup in test fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
cracked-machine committed Mar 13, 2024
1 parent 4bc1590 commit 4bbdd28
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions tests/fixtures/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pathlib
import pytest
import typing

examples_md_path = pathlib.Path("examples.md")

Expand All @@ -9,23 +10,26 @@ def init_examples_md_file():
fp.write("||\n")
fp.write("|-|\n")

def append_to_examples_md_file(file_path: str, test_desc: str):
if "docs/example" in file_path:
with open(examples_md_path, 'a', encoding='utf-8') as mdfp:
def append_to_examples_md_file(params: typing.Dict):
if 'file_path' in params and 'test_desc' in params:
file_path = params.get('file_path')
test_desc = params.get('test_desc')
if "docs/example" in file_path:
with open(examples_md_path, 'a', encoding='utf-8') as mdfp:

markdown_comment = str(test_desc).replace("\n","")
markdown_comment = markdown_comment.replace("-","<br>-")
markdown_comment = str(test_desc).replace("\n","")
markdown_comment = markdown_comment.replace("-","<br>-")

mdfp.write( f"| <H3>{ file_path } |\n")
mdfp.write( f"| {markdown_comment} |\n")
mdfp.write( f"| [![]( { file_path }_diagram.png )]({ file_path }_diagram.png) |\n")
mdfp.write( f"| [![]( { file_path }_table.png )]({ file_path }_table.png) |\n")
mdfp.write( f"| [{ file_path }.json]({ file_path }.json)<pre>" )
mdfp.write( f"| <H3>{ file_path } |\n")
mdfp.write( f"| {markdown_comment} |\n")
mdfp.write( f"| [![]( { file_path }_diagram.png )]({ file_path }_diagram.png) |\n")
mdfp.write( f"| [![]( { file_path }_table.png )]({ file_path }_table.png) |\n")
mdfp.write( f"| [{ file_path }.json]({ file_path }.json)<pre>" )

with open(f"{ file_path }.json", "r", encoding="utf-8") as jsonfp:
mdfp.write( jsonfp.read().replace("\n", "<BR>") )
with open(f"{ file_path }.json", "r", encoding="utf-8") as jsonfp:
mdfp.write( jsonfp.read().replace("\n", "<BR>") )

mdfp.write( f"</pre> |\n" )
mdfp.write( f"</pre> |\n" )

@pytest.fixture(scope="session", autouse=True)
def session_setup(request):
Expand All @@ -51,5 +55,5 @@ def test_setup(request):
yield {"report": report, "diagram_image": diagram_image, "table_image": table_image, "json_file": json_file}

# finally add the generated files for this test to the examples.md file
append_to_examples_md_file(request.param['file_path'], request.param['test_desc'])
append_to_examples_md_file(request.param)

0 comments on commit 4bbdd28

Please sign in to comment.