Run a test with RustPython and return parsed results. Args: test_name: Test module name (e.g., "test_foo" or "test_ctypes.test_bar") skip_build: If True, use pre-built binary instead of cargo run Returns: TestResult with parsed test results
(test_name: str, skip_build: bool = False)
| 45 | |
| 46 | |
| 47 | def run_test(test_name: str, skip_build: bool = False) -> TestResult: |
| 48 | """ |
| 49 | Run a test with RustPython and return parsed results. |
| 50 | |
| 51 | Args: |
| 52 | test_name: Test module name (e.g., "test_foo" or "test_ctypes.test_bar") |
| 53 | skip_build: If True, use pre-built binary instead of cargo run |
| 54 | |
| 55 | Returns: |
| 56 | TestResult with parsed test results |
| 57 | """ |
| 58 | if skip_build: |
| 59 | cmd = ["./target/release/rustpython"] |
| 60 | if sys.platform == "win32": |
| 61 | cmd = ["./target/release/rustpython.exe"] |
| 62 | else: |
| 63 | cmd = ["cargo", "run", "--release", "--"] |
| 64 | |
| 65 | result = subprocess.run( |
| 66 | cmd + ["-m", "test", "-v", "-u", "all", "--slowest", test_name], |
| 67 | stdout=subprocess.PIPE, # Capture stdout for parsing |
| 68 | stderr=None, # Let stderr pass through to terminal |
| 69 | text=True, |
| 70 | ) |
| 71 | return parse_results(result) |
| 72 | |
| 73 | |
| 74 | def _try_parse_test_info(test_info: str) -> tuple[str, str] | None: |
no test coverage detected