-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test.py; reorganize all python tutorials
- Loading branch information
1 parent
20faf9d
commit 63ad291
Showing
5 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
import subprocess | ||
|
||
def run_tests(directory): | ||
# Get all .py files in the directory, sort them alphabetically, and skip 'template.py' | ||
test_files = sorted( | ||
f for f in os.listdir(directory) if f.endswith(".py") and f != "template.py" | ||
) | ||
|
||
# Run each test file | ||
for test_file in test_files: | ||
print(f"Running {test_file}...") | ||
test_path = os.path.join(directory, test_file) | ||
result = subprocess.run(["python3", test_path], capture_output=True, text=True) | ||
|
||
# Print the results | ||
print(f"Output of {test_file}:\n{result.stdout}") | ||
if result.returncode != 0: | ||
print(f"Error in {test_file}:\n{result.stderr}") | ||
print("--------------------------------------------------") | ||
print("Test failed.") | ||
return # Stop batch execution if a test fails | ||
else: | ||
print("Test passed!") | ||
print("--------------------------------------------------") | ||
|
||
print("All tests completed successfully!") | ||
|
||
if __name__ == "__main__": | ||
run_tests("../tutorials") |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.