• pytest11-pytest.ini的使用


    1.pytest.ini的放置位置:一般放在项目工程的根目录(即当前项目的顶级文件夹下)

    2.pytest.ini的作用:指定pytest的运行方式(在cmd输入pytest后,会读取pytest.ini中的配置信息,按指定的方式去运行)

    3.cmd下使用 pytest -h 命令查看pytest.ini的设置选项(以下截图只是部分选项)

    [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
      python_files (args):  glob-style file patterns for Python test module discovery
      python_classes (args):
                            prefixes or glob names for Python test class discovery
      python_functions (args):
                            prefixes or glob names for Python test function and method discovery
      disable_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 report
      junit_logging (string):
                            Write captured log messages to JUnit report: one of no|system-out|system-err
      junit_log_passing_tests (bool):
                            Capture log information for passing tests to JUnit report:
      junit_duration_report (string):
                            Duration time to report: one of total|call
      junit_family (string):
                            Emit XML for schema: one of legacy|xunit1|xunit2
      doctest_optionflags (args):
                            option flags for doctests
      doctest_encoding (string):
                            encoding used for doctest files
      cache_dir (string):   cache directory path.
      filterwarnings (linelist):
                            Each line specifies a pattern for warnings.filterwarnings. Processed after -W and --pythonwarnings.
      log_print (bool):     default value for --no-print-logs
      log_level (string):   default value for --log-level
      log_format (string):  default value for --log-format
      log_date_format (string):
                            default value for --log-date-format
      log_cli (bool):       enable log display during test run (also known as "live logging").
      log_cli_level (string):
                            default value for --log-cli-level
      log_cli_format (string):
                            default value for --log-cli-format
      log_cli_date_format (string):
                            default value for --log-cli-date-format
      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
      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
    
    environment variables:
      PYTEST_ADDOPTS           extra command line options
      PYTEST_PLUGINS           comma-separated plugins to load during startup
      PYTEST_DISABLE_PLUGIN_AUTOLOAD set to disable plugin auto-loading
      PYTEST_DEBUG             set to enable debug tracing of pytest's internals
    
    
    to see available markers type: pytest --markers
    to see available fixtures type: pytest --fixtures
    (shown according to specified file_or_dir or current dir if not specified; fixtures with leading '_' are only shown with the '-v' option
    View Code

     常用设置选项:

    #命令行参数  可添加多个命令行参数,空格分开,所有参数均为插件包的参数 

    addopts:-vs --alluredir=reports

    #测试用例的搜索目录

    testpaths:

    #搜索测试文件名

    python_files:

    #搜索测试类名

    python_classes

    #搜索测试方法名

    python_functions

  • 相关阅读:
    D. Longest Subsequence
    线段树入门HDU_1754
    poj_2503(map映射)
    HDU_4826
    poj_2251
    day 44 单表查询,多表查询
    day43 字段的修改、添加和删除,多表关系(外键),单表详细操作(增删改查)
    day 42 数据库的配置、数据库与表的一些剩余操作、用户操作、数据库表的引擎、数据库的模式、mysql支持的数据类型、约束
    day41 数据库介绍、数据库基本操作
    day 40 线程队列、线程定时器、进程池和线程池、同步与异步、用多线程来写socket服务端与客户端
  • 原文地址:https://www.cnblogs.com/wang-mengmeng/p/11776813.html
Copyright © 2020-2023  润新知