-
Notifications
You must be signed in to change notification settings - Fork 4
/
_scripts.py
58 lines (36 loc) · 1.42 KB
/
_scripts.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import subprocess
def lint():
"""Run Ruff linter and fix all the changes that can be fixed automatically."""
subprocess.run(['ruff', 'check', '--fix'], check=True)
def format_code():
"""Format code with Ruff."""
subprocess.run(['ruff', 'format'], check=True)
def lint_and_format():
"""Run both linting and formatting."""
lint()
format_code()
def run_tests():
"""Run all tests using pytest."""
subprocess.run(['pytest'], check=True)
def run_tests_on_files(files):
"""Run tests on specific file or files."""
subprocess.run(['pytest', *files], check=True)
def run_tests_on_classes(classes):
"""Run tests on specific class or classes."""
for class_name in classes:
subprocess.run(['pytest', '-k', class_name], check=True)
def run_coverage():
"""Run tests with coverage reporting."""
subprocess.run(['coverage', 'run', '-m', 'pytest'], check=True)
def run_coverage_report():
"""Generate and display coverage report."""
subprocess.run(['coverage', 'report'], check=True)
def run_coverage_html():
"""Generate HTML coverage report."""
subprocess.run(['coverage', 'html'], check=True)
def watch_tests():
"""Run tests in watch mode using pytest-watch."""
subprocess.run(['ptw'], check=True)
def watch_tests_with_coverage():
"""Run tests in watch mode with coverage."""
subprocess.run(['ptw', '--runner', 'coverage run -m pytest'], check=True)