From 25423ee7b3347434bac49555b0eb902b0ee054a4 Mon Sep 17 00:00:00 2001 From: rahul Date: Wed, 11 Dec 2024 11:26:19 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Tox=20environment=20for=20g?= =?UTF-8?q?entets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli/gentest/source_code_generator.py | 18 ++++++++++++------ src/config/app.py | 5 +++++ tox.ini | 11 +++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/cli/gentest/source_code_generator.py b/src/cli/gentest/source_code_generator.py index 6159642e0e..d37875dfe6 100644 --- a/src/cli/gentest/source_code_generator.py +++ b/src/cli/gentest/source_code_generator.py @@ -11,6 +11,8 @@ import jinja2 +from config import AppConfig + from .test_context_providers import Provider template_loader = jinja2.PackageLoader("cli.gentest") @@ -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() diff --git a/src/config/app.py b/src/config/app.py index c8bd8591bd..bdc24623a3 100644 --- a/src/config/app.py +++ b/src/config/app.py @@ -5,6 +5,8 @@ - AppConfig: Holds configurations for the application framework. """ +from pathlib import Path + from pydantic import BaseModel @@ -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.""" diff --git a/tox.ini b/tox.ini index 40656326a2..2be6a23f4b 100644 --- a/tox.ini +++ b/tox.ini @@ -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