fix: fix directory structure and test files
This commit is contained in:
21
.gitignore
vendored
21
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -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}")
|
||||
|
||||
6
tests/test.tampy
Normal file
6
tests/test.tampy
Normal file
@@ -0,0 +1,6 @@
|
||||
x = 1
|
||||
y = 2
|
||||
if x > y:
|
||||
print("x is greater")
|
||||
else:
|
||||
print("y is greater")
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user