> For the complete documentation index, see [llms.txt](https://hai-shi.gitbook.io/cpython-internals/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hai-shi.gitbook.io/cpython-internals/14-test-suites/14.6-test-utilities.md).

# 14.6 测试工具

通过导入 `test.support.script_helper` 模块，你可以访问一些帮助函数来测试 Python 运行时：

* `assert_python_ok(*args，**env_vars)` 使用指定的参数执行 python 进程，并返回一个元组（返回代码、`stdout`、`stderr`）。
* `assert_python_failure(*args，**env_vars)` 类似于 `assert_python_ok()`，但断言参数会执行失败。
* `make_script(script_dir，script_basename，source)` 使用 `script_basename` 和 `source` 在 `script_dir` 中生成一个脚本 ，然后返回脚本路径。其与 `assert_python_ok()` 或 `assert_python_failure()` 组合使用会更有效。

如果你想创建一个在模块未构建时会被跳过的测试，那么你可以使用 `test.support.import_module()` 工具函数。它将抛出一个 `SkipTest` 并向测试执行器发出跳过此测试包的信号。如下示例所示：

```python
import test.support

_multiprocessing = test.support.import_module('_multiprocessing')

# Your tests...
```
