From 4ee33c5eafa0162e2862f31494b93a6acab07163 Mon Sep 17 00:00:00 2001 From: KeshavAnandCode Date: Sun, 3 May 2026 13:02:50 -0500 Subject: [PATCH] fix: fix directory structure and test files --- .gitignore | 21 ++++++++++++++++++--- README.md | 0 src/tampy/cli.py | 2 +- tests/test.tampy | 6 ++++++ tests/test_cli.py | 9 +++++---- 5 files changed, 30 insertions(+), 8 deletions(-) delete mode 100644 README.md create mode 100644 tests/test.tampy diff --git a/.gitignore b/.gitignore index c9b6edb..819e9f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,24 @@ +# Python bytecode *.pyc +*.pyo + +# Cache __pycache__/ *.egg-info/ .pytest_cache/ -*.map +.coverage +.htmlcov/ + +# Environment .env .venv/ -test.py -test.tampy +.env/* +!/.env.example + +# Build artifacts +*.map +dist/ +build/ + +# Generated test files +tests/*.py diff --git a/README.md b/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/tampy/cli.py b/src/tampy/cli.py index 22346eb..724b6d5 100644 --- a/src/tampy/cli.py +++ b/src/tampy/cli.py @@ -31,7 +31,7 @@ def main(): python_code = transpiler.transpile(code) if args.command == "build": - output_file = args.file.replace(".tampy", ".py") + output_file = Path(args.file).with_suffix(".py") with open(output_file, "w", encoding="utf-8") as f: f.write(python_code) print(f"Generated: {output_file}") diff --git a/tests/test.tampy b/tests/test.tampy new file mode 100644 index 0000000..d6658b0 --- /dev/null +++ b/tests/test.tampy @@ -0,0 +1,6 @@ +x = 1 +y = 2 +if x > y: + print("x is greater") +else: + print("y is greater") diff --git a/tests/test_cli.py b/tests/test_cli.py index e829d9e..1d5f968 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -9,19 +9,20 @@ from pathlib import Path def test_build_command(): """Test build command.""" result = subprocess.run( - [sys.executable, "-m", "tampy", "build", "test.tampy"], + [sys.executable, "-m", "tampy", "build", "tests/test.tampy"], capture_output=True, text=True, env={**dict(os.environ), "PYTHONPATH": "src"} ) assert result.returncode == 0 assert "Generated:" in result.stdout + assert Path("tests/test.py").exists() def test_run_command(): """Test run command.""" result = subprocess.run( - [sys.executable, "-m", "tampy", "run", "test.tampy"], + [sys.executable, "-m", "tampy", "run", "tests/test.tampy"], capture_output=True, text=True, env={**dict(os.environ), "PYTHONPATH": "src"} @@ -33,10 +34,10 @@ def test_run_command(): def test_file_extension_replacement(): """Test that .tampy is replaced with .py.""" result = subprocess.run( - [sys.executable, "-m", "tampy", "build", "test.tampy"], + [sys.executable, "-m", "tampy", "build", "tests/test.tampy"], capture_output=True, text=True, env={**dict(os.environ), "PYTHONPATH": "src"} ) assert result.returncode == 0 - assert Path("test.py").exists() + assert Path("tests/test.py").exists()