pytest —help可查看pytest.ini的设置选项
[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:markers (linelist): markers for test functionsempty_parameter_set_mark (string):default marker for empty parametersetsnorecursedirs (args): directory patterns to avoid for recursiontestpaths (args): directories to search for tests when no files or directories are given in the command line.usefixtures (args): list of default fixtures to be used with this projectpython_files (args): glob-style file patterns for Python test module discoverypython_classes (args):prefixes or glob names for Python test class discoverypython_functions (args):prefixes or glob names for Python test function and method discoverydisable_test_id_escaping_and_forfeit_all_rights_to_community_support (bool):disable string escape non-ascii characters, might cause unwanted side effects(use at your own risk)console_output_style (string):console output: "classic", or with additional progress information ("progress" (percentage) | "count").xfail_strict (bool): default for the strict parameter of xfail markers when not given explicitly (default: False)enable_assertion_pass_hook (bool):Enables the pytest_assertion_pass hook.Make sure to delete any previously generated pyc cache files.junit_suite_name (string):Test suite name for JUnit reportjunit_logging (string):Write captured log messages to JUnit report: one of no|log|system-out|system-err|out-err|alljunit_log_passing_tests (bool):Capture log information for passing tests to JUnit report:junit_duration_report (string):Duration time to report: one of total|calljunit_family (string):Emit XML for schema: one of legacy|xunit1|xunit2doctest_optionflags (args):option flags for doctestsdoctest_encoding (string):encoding used for doctest filescache_dir (string): cache directory path.filterwarnings (linelist):Each line specifies a pattern for warnings.filterwarnings. Processed after -W/--pythonwarnings.log_print (bool): default value for --no-print-logslog_level (string): default value for --log-levellog_format (string): default value for --log-formatlog_date_format (string):default value for --log-date-formatlog_cli (bool): enable log display during test run (also known as "live logging").log_cli_level (string):default value for --log-cli-levellog_cli_format (string):default value for --log-cli-formatlog_cli_date_format (string):default value for --log-cli-date-formatlog_file (string): default value for --log-filelog_file_level (string):default value for --log-file-levellog_file_format (string):default value for --log-file-formatlog_file_date_format (string):default value for --log-file-date-formatlog_auto_indent (string):default value for --log-auto-indentfaulthandler_timeout (string):Dump the traceback of all threads if a test takes more than TIMEOUT seconds to finish. Not available on Windows.addopts (args): extra command line optionsminversion (string): minimally required pytest versionrender_collapsed (bool):Open the report with all rows collapsed. Useful for very large reports
常见的pytest.ini配置项
markers:为用例打标记,详见mark实现根据标签执行用例
addopts:可修改默认命令行选项,假设我们每次执行用例都需要执行一大串指令,可把执行指令添加到pytest.ini,
# pytest.ini[pytest]# #--self-contained-html 为了防止分享报告的时候样式丢失addopts = -v --rerun 1 --html=./report/report.html --self-contained-html
设置如上之后,打开cmd只需要输入pytest就能默认带上这些默认参数
