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
| (.venv) PS D:\project\howtospider> python -m unittest -h usage: python.exe -m unittest [-h] [-v] [-q] [--locals] [--durations N] [-f] [-c] [-b] [-k TESTNAMEPATTERNS] [tests ...]
positional arguments: tests a list of any number of test modules, classes and test methods.
options: -h, --help show this help message and exit -v, --verbose Verbose output 显示详细信息 -q, --quiet Quiet output 显示简略信息 --locals Show local variables in tracebacks 在tracebacks中显示变量 --durations N Show the N slowest test cases (N=0 for all) 显示最慢的几个测试用例 -f, --failfast Stop on first fail or error 遇到第一个失败的用例就停止 -c, --catch Catch Ctrl-C and display results so far 按ctrl c 运行完当前用例结束则返回测试结果, 再按ctrl c 就触发KeyboardInterrupt异常 -b, --buffer Buffer stdout and stderr during tests 缓存标准输出 错误输出 -k TESTNAMEPATTERNS Only run tests which match the given substring 运行符合关键词的用例
Examples: python.exe -m unittest test_module - run tests from test_module python.exe -m unittest module.TestClass - run tests from module.TestClass python.exe -m unittest module.Class.test_method - run specified test method python.exe -m unittest path/to/test_file.py - run tests from test_file.py
usage: python.exe -m unittest discover [-h] [-v] [-q] [--locals] [--durations N] [-f] [-c] [-b] [-k TESTNAMEPATTERNS] [-s START] [-p PATTERN] [-t TOP]
options: -h, --help show this help message and exit -v, --verbose Verbose output -q, --quiet Quiet output --locals Show local variables in tracebacks --durations N Show the N slowest test cases (N=0 for all) -f, --failfast Stop on first fail or error -c, --catch Catch Ctrl-C and display results so far -b, --buffer Buffer stdout and stderr during tests -k TESTNAMEPATTERNS Only run tests which match the given substring -s START, --start-directory START Directory to start discovery ('.' default) -p PATTERN, --pattern PATTERN Pattern to match tests ('test*.py' default) -t TOP, --top-level-directory TOP Top level directory of project (defaults to start directory)
For test discovery all test modules must be importable from the top level directory of the project.
|