File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 55args = sys .argv [1 :]
66copied = []
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+
813def 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
2135if 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
3348with open (".tox_copied_files" , "w" ) as f :
3449 for name in copied :
3550 f .write (name + "\n " )
You can’t perform that action at this time.
0 commit comments