rustest 0.14.0__cp313-cp313-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rustest/cli.py ADDED
@@ -0,0 +1,135 @@
1
+ """Command line interface helpers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ from collections.abc import Sequence
7
+
8
+ from .core import run
9
+
10
+
11
+ def build_parser() -> argparse.ArgumentParser:
12
+ parser = argparse.ArgumentParser(
13
+ prog="rustest",
14
+ description="Run Python tests at blazing speed with a Rust powered core.",
15
+ )
16
+ _ = parser.add_argument(
17
+ "paths",
18
+ nargs="*",
19
+ default=(".",),
20
+ help="Files or directories to collect tests from.",
21
+ )
22
+ _ = parser.add_argument(
23
+ "-k",
24
+ "--pattern",
25
+ help="Substring to filter tests by (case insensitive).",
26
+ )
27
+ _ = parser.add_argument(
28
+ "-m",
29
+ "--marks",
30
+ dest="mark_expr",
31
+ help='Run tests matching the given mark expression (e.g., "slow", "not slow", "slow and integration").',
32
+ )
33
+ _ = parser.add_argument(
34
+ "-n",
35
+ "--workers",
36
+ type=int,
37
+ help="Number of worker slots to use (experimental).",
38
+ )
39
+ _ = parser.add_argument(
40
+ "--no-capture",
41
+ dest="capture_output",
42
+ action="store_false",
43
+ help="Do not capture stdout/stderr during test execution.",
44
+ )
45
+ _ = parser.add_argument(
46
+ "-v",
47
+ "--verbose",
48
+ action="store_true",
49
+ help="Show verbose output with hierarchical test structure.",
50
+ )
51
+ _ = parser.add_argument(
52
+ "--ascii",
53
+ action="store_true",
54
+ help="Use ASCII characters instead of Unicode symbols for output.",
55
+ )
56
+ _ = parser.add_argument(
57
+ "--no-color",
58
+ dest="color",
59
+ action="store_false",
60
+ help="Disable colored output.",
61
+ )
62
+ _ = parser.add_argument(
63
+ "--no-codeblocks",
64
+ dest="enable_codeblocks",
65
+ action="store_false",
66
+ help="Disable code block tests from markdown files.",
67
+ )
68
+ _ = parser.add_argument(
69
+ "--lf",
70
+ "--last-failed",
71
+ action="store_true",
72
+ dest="last_failed",
73
+ help="Rerun only the tests that failed in the last run.",
74
+ )
75
+ _ = parser.add_argument(
76
+ "--ff",
77
+ "--failed-first",
78
+ action="store_true",
79
+ dest="failed_first",
80
+ help="Run previously failed tests first, then all other tests.",
81
+ )
82
+ _ = parser.add_argument(
83
+ "-x",
84
+ "--exitfirst",
85
+ action="store_true",
86
+ dest="fail_fast",
87
+ help="Exit instantly on first error or failed test.",
88
+ )
89
+ _ = parser.add_argument(
90
+ "--pytest-compat",
91
+ action="store_true",
92
+ dest="pytest_compat",
93
+ help="Enable pytest compatibility mode - allows running existing pytest tests without modifying imports.",
94
+ )
95
+ parser.set_defaults(
96
+ capture_output=True,
97
+ color=True,
98
+ enable_codeblocks=True,
99
+ last_failed=False,
100
+ failed_first=False,
101
+ fail_fast=False,
102
+ pytest_compat=False,
103
+ )
104
+ return parser
105
+
106
+
107
+ def main(argv: Sequence[str] | None = None) -> int:
108
+ parser = build_parser()
109
+ args = parser.parse_args(argv)
110
+
111
+ # Determine last_failed_mode
112
+ if args.last_failed:
113
+ last_failed_mode = "only"
114
+ elif args.failed_first:
115
+ last_failed_mode = "first"
116
+ else:
117
+ last_failed_mode = "none"
118
+
119
+ report = run(
120
+ paths=list(args.paths),
121
+ pattern=args.pattern,
122
+ mark_expr=args.mark_expr,
123
+ workers=args.workers,
124
+ capture_output=args.capture_output,
125
+ enable_codeblocks=args.enable_codeblocks,
126
+ last_failed_mode=last_failed_mode,
127
+ fail_fast=args.fail_fast,
128
+ pytest_compat=args.pytest_compat,
129
+ verbose=args.verbose,
130
+ ascii=args.ascii,
131
+ no_color=not args.color,
132
+ )
133
+ # Note: Rust now handles all output rendering with real-time progress
134
+ # The Python _print_report() function is no longer called
135
+ return 0 if report.failed == 0 else 1
@@ -0,0 +1,3 @@
1
+ """Compatibility shims for other testing frameworks."""
2
+
3
+ __all__ = []