forked from andela/buggy-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
26 lines (21 loc) · 807 Bytes
/
run_tests.py
File metadata and controls
26 lines (21 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
"""
Test runner script for the buggy-python project.
Usage:
python3 run_tests.py # Run all tests
python3 run_tests.py -v # Run with verbose output
python3 run_tests.py test_loop # Run specific test module
"""
import sys
import unittest
if __name__ == '__main__':
# Discover and run all tests in the tests directory
loader = unittest.TestLoader()
start_dir = 'tests'
suite = loader.discover(start_dir, pattern='test_*.py')
# Run with verbosity level 2 for detailed output
verbosity = 2 if '-v' in sys.argv or '--verbose' in sys.argv else 1
runner = unittest.TextTestRunner(verbosity=verbosity)
result = runner.run(suite)
# Exit with appropriate code
sys.exit(0 if result.wasSuccessful() else 1)