pytest.ini配置文件之addopts设置项
一、配置文件设置选项
使用pytest --help指令可以查看pytest.ini的设置选项
pytest -h
结果:
[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:
  markers (linelist):   markers for test functions
  empty_parameter_set_mark (string):
                        default marker for empty parametersets
  norecursedirs (args): directory patterns to avoid for recursion
  testpaths (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 project
  log_file (string):    default value for --log-file
  log_file_level (string):
                        default value for --log-file-level
  log_file_format (string):
                        default value for --log-file-format
  log_file_date_format (string):
                        default value for --log-file-date-format
  log_auto_indent (string):
                        default value for --log-auto-indent
  faulthandler_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 options
  minversion (string):  minimally required pytest version
二、addopts设置项
addopts设置项,可以添加指定的 OPTS 命令行参数集,在执行命令时,不用再每次都输入长串命令,就好像它们是由用户指定的一样。示例:如果您有这个ini文件内容:
#pytest.ini
[pytest]
python_files = test05.py
addopts = -v -s --alluredir=report/allure
配置好后,执行pytest命令时,就相当于执行如下命令:
pytest -v -s --alluredir=report/allure test05.py
结果:

参考
1、https://www.osgeo.cn/pytest/reference.html#ini-options-ref

                
            
        
浙公网安备 33010602011771号