Skip to content

Commit

Permalink
✨ feat: Tox environment for gentets
Browse files Browse the repository at this point in the history
  • Loading branch information
raxhvl committed Dec 11, 2024
1 parent dc05b42 commit 25423ee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/cli/gentest/source_code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import jinja2

from config import AppConfig

from .test_context_providers import Provider

template_loader = jinja2.PackageLoader("cli.gentest")
Expand Down Expand Up @@ -72,12 +74,16 @@ def format_code(code: str) -> str:
black_path = Path(sys.prefix) / "bin" / "black"

# Call black to format the file
config_path = Path(sys.prefix).parent / "pyproject.toml"

subprocess.run(
[str(black_path), str(input_file_path), "--quiet", "--config", str(config_path)],
check=True,
)
config_path = AppConfig().ROOT_DIR / "pyproject.toml"

try:
subprocess.run(
[str(black_path), str(input_file_path), "--quiet", "--config", str(config_path)],
check=True,
)
except subprocess.CalledProcessError as e:
print(f"Error formatting code with Black: {e}", file=sys.stderr)
raise

# Return the formatted source code
return input_file_path.read_text()
5 changes: 5 additions & 0 deletions src/config/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- AppConfig: Holds configurations for the application framework.
"""

from pathlib import Path

from pydantic import BaseModel


Expand All @@ -15,3 +17,6 @@ class AppConfig(BaseModel):

version: str = "3.0.0"
"""The version of the application framework."""

ROOT_DIR: Path = Path(__file__).resolve().parents[2]
"""The root directory of the project."""
11 changes: 11 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,14 @@ commands =
python -c "import src.cli.tox_helpers; src.cli.tox_helpers.pyspelling()"
python -c "import src.cli.tox_helpers; src.cli.tox_helpers.markdownlint()"
mkdocs build --strict

[testenv:gentest]
description = Execute an end-to-end gentest

extras =
lint

commands =
uv run gentest 0xa41f343be7a150b740e5c939fa4d89f3a2850dbe21715df96b612fc20d1906be tests/paris/test_0xa41f.py
uv run fill tests/paris/test_0xa41f.py
# uv run consume direct -k test_0xa41f --evm-bin evmone-t8n

0 comments on commit 25423ee

Please sign in to comment.