14.4 运行特定测试

你可以通过提供测试套件作为第一个参数来运行特定的测试。

以下是 Linux 或 macOS 上的一个示例:

$ ./python -m test test_webbrowser
Run tests sequentially
0:00:00 load avg: 2.74 [1/1] test_webbrowser
== Tests result: SUCCESS ==
1 test OK.
Total duration: 117 ms
Tests result: SUCCESS

以下是 Windows 上的一个示例:

> rt.bat -q -d -x64 test_webbrowser

你还可以使用 -v 参数查看执行的测试的详细列表以及结果:

$ ./python -m test test_webbrowser -v
== CPython 3.9
== macOS-10.14.3-x86_64-i386-64bit little-endian
== cwd: /Users/anthonyshaw/cpython/build/test_python_24562
== CPU count: 4
== encodings: locale=UTF-8, FS=utf-8
Run tests sequentially
0:00:00 load avg: 2.36 [1/1] test_webbrowser
test_open (test.test_webbrowser.BackgroundBrowserCommandTest) ...ok
test_register (test.test_webbrowser.BrowserRegistrationTest) ...ok
test_register_default (test.test_webbrowser.BrowserRegistrationTest) ...ok
test_register_preferred (test.test_webbrowser.BrowserRegistrationTest) ...ok
test_open (test.test_webbrowser.ChromeCommandTest) ...ok
test_open_new (test.test_webbrowser.ChromeCommandTest) ...ok
...
test_open_with_autoraise_false (test.test_webbrowser.OperaCommandTest) ...ok
Ran 34 tests in 0.056s
OK (skipped=2)
== Tests result: SUCCESS ==
1 test OK.
Total duration: 134 ms
Tests result: SUCCESS

如果你希望对 CPython 进行更改,了解如何使用测试套件并检查你编译的版本的状态是非常重要的。在开始进行更改之前,你应该运行整个测试套件,并确保所有内容都通过。

Last updated