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

打賞

免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2022 CODEPRJ.COM