Skip to content

Commit

Permalink
test execution
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-kuprianov committed Jul 27, 2022
1 parent be3272f commit f836e2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion atomkraft/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def trace(
Test blockchain by running one trace
"""

test_trace(trace.name, reactor.name, keypath)
test_trace(trace.name, reactor if reactor is None else reactor.name, keypath)


@app.command()
Expand Down
12 changes: 10 additions & 2 deletions atomkraft/test/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from atomkraft.utils.project import project_root
import os.path
from datetime import datetime
import pytest
from ..reactor.reactor import get_reactor


trace_test_stub = """
Expand All @@ -20,6 +22,9 @@ def test_trace(trace: PathLike, reactor: PathLike, keypath: str):
Test blockchain by running one trace
"""

if reactor is None:
reactor = get_reactor()

root = project_root()
if not root:
raise RuntimeError(
Expand All @@ -40,10 +45,13 @@ def test_trace(trace: PathLike, reactor: PathLike, keypath: str):
.replace(":", "_")
.replace("-", "_")
)
test = os.path.join(tests, f"{test_name}.py")
with open(test, "w") as test:
test_path = os.path.join(tests, f"{test_name}.py")
with open(test_path, "w") as test:
print(f"Writing {test_name} ...")
test.write(
trace_test_stub.format(
str(reactor).replace("/", ".").replace(".py", ""), trace, keypath
)
)
print(f"Executing {test_name} ...")
pytest.main(["-s", test_path])

0 comments on commit f836e2f

Please sign in to comment.