Skip to content

Commit a30e379

Browse files
Update prepare_tests.py
Co-authored-by: LeAndre <lcjunior1220@gmail.com>
1 parent 9505203 commit a30e379

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

scripts/prepare_tests.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@
55
args = sys.argv[1:]
66
copied = []
77

8+
def is_test_file(filename):
9+
"""Return True if filename already matches pytest test naming conventions."""
10+
base = os.path.basename(filename)
11+
return base.startswith("test_") or base.endswith("_test.py")
12+
813
def copy_file(src):
914
base = os.path.basename(src)
15+
16+
# Skip files already named like tests
17+
if is_test_file(base):
18+
print(f"[tox] Skipping already-valid test file: {src}")
19+
return
20+
1021
new = f"test_{base}"
1122
shutil.copy(src, new)
1223
copied.append(new)
@@ -16,7 +27,10 @@ def walk_dir(path):
1627
for root, _, files in os.walk(path):
1728
for f in files:
1829
if f.endswith(".py"):
19-
copy_file(os.path.join(root, f))
30+
full = os.path.join(root, f)
31+
copy_file(full)
32+
33+
print("[tox] Received args:", args)
2034

2135
if not args:
2236
print("[tox] No files or directories passed — using pytest auto-discovery.")
@@ -30,6 +44,7 @@ def walk_dir(path):
3044
else:
3145
print(f"[tox] Warning: {path} does not exist and will be ignored.")
3246

47+
# Save copied files for cleanup
3348
with open(".tox_copied_files", "w") as f:
3449
for name in copied:
3550
f.write(name + "\n")

0 commit comments

Comments
 (0)