def pytest_addoption(parser: Parser) -> None: group = parser.getgroup('blockage-httpx') group.addoption( '--blockage-httpx', action='store_true', help='Block httpx requests during test run', ) parser.addini( 'blockage-httpx', default=False, help='Block httpx requests during test run', ) group.addoption( '--disable-blockage-mark', action='store', help='If a test uses this mark, blockage would be disabled (default value is "integration")', default='', ) parser.addini( 'disable-blockage-mark', help='If a test uses this mark, blockage would be disabled (default value is "integration")', default='', )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("general") group.addoption( "--lf", "--last-failed", action="store_true", dest="lf", help="rerun only the tests that failed " "at the last run (or all if none failed)", ) group.addoption( "--ff", "--failed-first", action="store_true", dest="failedfirst", help="run all tests, but run the last failures first.\n" "This may re-order tests and thus lead to " "repeated fixture setup/teardown.", ) group.addoption( "--nf", "--new-first", action="store_true", dest="newfirst", help="run tests from new files first, then the rest of the tests " "sorted by file mtime", ) group.addoption( "--cache-show", action="append", nargs="?", dest="cacheshow", help=("show cache contents, don't perform collection or tests. " "Optional argument: glob (default: '*')."), ) group.addoption( "--cache-clear", action="store_true", dest="cacheclear", help="remove all cache contents at start of test run.", ) cache_dir_default = ".pytest_cache" if "TOX_ENV_DIR" in os.environ: cache_dir_default = os.path.join(os.environ["TOX_ENV_DIR"], cache_dir_default) parser.addini("cache_dir", default=cache_dir_default, help="cache directory path.") group.addoption( "--lfnf", "--last-failed-no-failures", action="store", dest="last_failed_no_failures", choices=("all", "none"), default="all", help="which tests to run with no previously (known) failures.", )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("pytest-warnings") group.addoption( "-W", "--pythonwarnings", action="append", help="set which warnings to report, see -W option of python itself.", ) parser.addini( "filterwarnings", type="linelist", help="Each line specifies a pattern for " "warnings.filterwarnings. " "Processed after -W/--pythonwarnings.", )
def pytest_addoption(parser: Parser) -> None: parser.addini( "doctest_optionflags", "option flags for doctests", type="args", default=["ELLIPSIS"], ) parser.addini( "doctest_encoding", "encoding used for doctest files", default="utf-8" ) group = parser.getgroup("collect") group.addoption( "--doctest-modules", action="store_true", default=False, help="run doctests in all .py modules", dest="doctestmodules", ) group.addoption( "--doctest-report", type=str.lower, default="udiff", help="choose another output format for diffs on doctest failure", choices=DOCTEST_REPORT_CHOICES, dest="doctestreport", ) group.addoption( "--doctest-glob", action="append", default=[], metavar="pat", help="doctests file matching pattern, default: test*.txt", dest="doctestglob", ) group.addoption( "--doctest-ignore-import-errors", action="store_true", default=False, help="ignore doctest ImportErrors", dest="doctest_ignore_import_errors", ) group.addoption( "--doctest-continue-on-failure", action="store_true", default=False, help="for a given doctest, continue to run after the first failure", dest="doctest_continue_on_failure", )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("general") group.addoption( "--runxfail", action="store_true", dest="runxfail", default=False, help="report the results of xfail tests as if they were not marked", ) parser.addini( "xfail_strict", "default for the strict parameter of xfail " "markers when not given explicitly (default: False)", default=False, type="bool", )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("terminal reporting") group.addoption( "--junitxml", "--junit-xml", action="store", dest="xmlpath", metavar="path", type=functools.partial(filename_arg, optname="--junitxml"), default=None, help="create junit-xml style report file at given path.", ) group.addoption( "--junitprefix", "--junit-prefix", action="store", metavar="str", default=None, help="prepend prefix to classnames in junit-xml output", ) parser.addini("junit_suite_name", "Test suite name for JUnit report", default="pytest") parser.addini( "junit_logging", "Write captured log messages to JUnit report: " "one of no|log|system-out|system-err|out-err|all", default="no", ) parser.addini( "junit_log_passing_tests", "Capture log information for passing tests to JUnit report: ", type="bool", default=True, ) parser.addini( "junit_duration_report", "Duration time to report: one of total|call", default="total", ) # choices=['total', 'call']) parser.addini( "junit_family", "Emit XML for schema: one of legacy|xunit1|xunit2", default="xunit2", )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("general") group._addoption( "-k", action="store", dest="keyword", default="", metavar="EXPRESSION", help="only run tests which match the given substring expression. " "An expression is a python evaluatable expression " "where all names are substring-matched against tests names " "and their parent classes. Example: -k 'test_method or test_" "other' matches all tests functions and classes whose name " "contains 'test_method' or 'test_other', while -k 'not test_method' " "matches those that don't contain 'test_method' in their names. " "-k 'not test_method and not test_other' will eliminate the matches. " "Additionally keywords are matched to classes and functions " "containing extra names in their 'extra_keyword_matches' set, " "as well as functions which have names assigned directly to them. " "The matching is case-insensitive.", ) group._addoption( "-m", action="store", dest="markexpr", default="", metavar="MARKEXPR", help="only run tests matching given mark expression.\n" "For example: -m 'mark1 and not mark2'.", ) group.addoption( "--markers", action="store_true", help="show markers (builtin, plugin and per-project ones).", ) parser.addini("markers", "markers for tests functions", "linelist") parser.addini(EMPTY_PARAMETERSET_OPTION, "default marker for empty parametersets")
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("debugconfig") group.addoption( "--assert", action="store", dest="assertmode", choices=("rewrite", "plain"), default="rewrite", metavar="MODE", help=( "Control assertion debugging tools.\n" "'plain' performs no assertion debugging.\n" "'rewrite' (the default) rewrites assert statements in test modules" " on import to provide assert expression information."), ) parser.addini( "enable_assertion_pass_hook", type="bool", default=False, help="Enables the pytest_assertion_pass hook." "Make sure to delete any previously generated pyc cache files.", )
def pytest_addoption(parser: Parser) -> None: """Add options to control ansible.""" log.debug('pytest_addoption() called') group: OptionGroup = parser.getgroup('pytest-iqa') group.addoption( '--inventory', action='store', dest='inventory', required=True, metavar='INVENTORY', help='Inventory file to use', ) # Default values for pytest.ini files (if absent) parser.addini( 'log_level', default='WARNING', type=None, help='logging level used by the logging module', ) parser.addini( 'log_format', default=DEFAULT_LOG_FORMAT, type=None, help='log format as used by the logging module.', ) parser.addini( 'log_date_format', default=DEFAULT_LOG_DATE_FORMAT, type=None, help='log date format as used by the logging module.', ) parser.addini( 'log_cli', default=True, type='bool', help='enable log display during test run (also known as "live logging").', )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("terminal reporting", "reporting", after="general") group._addoption( "-v", "--verbose", action="count", default=0, dest="verbose", help="increase verbosity.", ) group._addoption( "--no-header", action="store_true", default=False, dest="no_header", help="disable header", ) group._addoption( "--no-summary", action="store_true", default=False, dest="no_summary", help="disable summary", ) group._addoption( "-q", "--quiet", action=MoreQuietAction, default=0, dest="verbose", help="decrease verbosity.", ) group._addoption( "--verbosity", dest="verbose", type=int, default=0, help="set verbosity. Default is 0.", ) group._addoption( "-r", action="store", dest="reportchars", default=_REPORTCHARS_DEFAULT, metavar="chars", help="show extra test summary info as specified by chars: (f)ailed, " "(E)rror, (s)kipped, (x)failed, (X)passed, " "(p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. " "(w)arnings are enabled by default (see --disable-warnings), " "'N' can be used to reset the list. (default: 'fE').", ) group._addoption( "--disable-warnings", "--disable-pytest-warnings", default=False, dest="disable_warnings", action="store_true", help="disable warnings summary", ) group._addoption( "-l", "--showlocals", action="store_true", dest="showlocals", default=False, help="show locals in tracebacks (disabled by default).", ) group._addoption( "--tb", metavar="style", action="store", dest="tbstyle", default="auto", choices=["auto", "long", "short", "no", "line", "native"], help="traceback print mode (auto/long/short/line/native/no).", ) group._addoption( "--show-capture", action="store", dest="showcapture", choices=["no", "stdout", "stderr", "log", "all"], default="all", help="Controls how captured stdout/stderr/log is shown on failed tests. " "Default is 'all'.", ) group._addoption( "--fulltrace", "--full-trace", action="store_true", default=False, help="don't cut any tracebacks (default is to cut).", ) group._addoption( "--color", metavar="color", action="store", dest="color", default="auto", choices=["yes", "no", "auto"], help="color terminal output (yes/no/auto).", ) group._addoption( "--code-highlight", default="yes", choices=["yes", "no"], help="Whether code should be highlighted (only if --color is also enabled)", ) parser.addini( "console_output_style", help='console output: "classic", or with additional progress information ("progress" (percentage) | "count").', default="progress", )
def pytest_addoption(parser: Parser) -> None: parser.addini( "norecursedirs", "directory patterns to avoid for recursion", type="args", default=[ "*.egg", ".*", "_darcs", "build", "CVS", "dist", "node_modules", "venv", "{arch}", ], ) parser.addini( "testpaths", "directories to search for tests when no files or directories are given in the " "command line.", type="args", default=[], ) group = parser.getgroup("general", "running and selection options") group._addoption( "-x", "--exitfirst", action="store_const", dest="maxfail", const=1, help="exit instantly on first error or failed test.", ) group = parser.getgroup("pytest-warnings") group.addoption( "-W", "--pythonwarnings", action="append", help="set which warnings to report, see -W option of python itself.", ) parser.addini( "filterwarnings", type="linelist", help="Each line specifies a pattern for " "warnings.filterwarnings. " "Processed after -W/--pythonwarnings.", ) group._addoption( "--maxfail", metavar="num", action="store", type=int, dest="maxfail", default=0, help="exit after first num failures or errors.", ) group._addoption( "--strict-config", action="store_true", help="any warnings encountered while parsing the `pytest` section of the configuration file raise errors.", ) group._addoption( "--strict-markers", action="store_true", help="markers not registered in the `markers` section of the configuration file raise errors.", ) group._addoption( "--strict", action="store_true", help="(deprecated) alias to --strict-markers.", ) group._addoption( "-c", metavar="file", type=str, dest="inifilename", help="load configuration from `file` instead of trying to locate one of the implicit " "configuration files.", ) group._addoption( "--continue-on-collection-errors", action="store_true", default=False, dest="continue_on_collection_errors", help="Force test execution even if collection errors occur.", ) group._addoption( "--rootdir", action="store", dest="rootdir", help="Define root directory for tests. Can be relative path: 'root_dir', './root_dir', " "'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables: " "'$HOME/root_dir'.", ) group = parser.getgroup("collect", "collection") group.addoption( "--collectonly", "--collect-only", "--co", action="store_true", help="only collect tests, don't execute them.", ) group.addoption( "--pyargs", action="store_true", help="try to interpret all arguments as python packages.", ) group.addoption( "--ignore", action="append", metavar="path", help="ignore path during collection (multi-allowed).", ) group.addoption( "--ignore-glob", action="append", metavar="path", help="ignore path pattern during collection (multi-allowed).", ) group.addoption( "--deselect", action="append", metavar="nodeid_prefix", help="deselect item (via node id prefix) during collection (multi-allowed).", ) group.addoption( "--confcutdir", dest="confcutdir", default=None, metavar="dir", type=functools.partial(directory_arg, optname="--confcutdir"), help="only load conftest.py's relative to specified dir.", ) group.addoption( "--noconftest", action="store_true", dest="noconftest", default=False, help="Don't load any conftest.py files.", ) group.addoption( "--keepduplicates", "--keep-duplicates", action="store_true", dest="keepduplicates", default=False, help="Keep duplicate tests.", ) group.addoption( "--collect-in-virtualenv", action="store_true", dest="collect_in_virtualenv", default=False, help="Don't ignore tests in a local virtualenv directory", ) group.addoption( "--import-mode", default="prepend", choices=["prepend", "append", "importlib"], dest="importmode", help="prepend/append to sys.path when importing test modules and conftest files, " "default is to prepend.", ) group = parser.getgroup("debugconfig", "test session debugging and configuration") group.addoption( "--basetemp", dest="basetemp", default=None, type=validate_basetemp, metavar="dir", help=( "base temporary directory for this test run." "(warning: this directory is removed if it exists)" ), )
def pytest_addoption(parser: Parser) -> None: """Add options to control log capturing.""" group = parser.getgroup("logging") def add_option_ini(option, dest, default=None, type=None, **kwargs): parser.addini(dest, default=default, type=type, help="default value for " + option) group.addoption(option, dest=dest, **kwargs) add_option_ini( "--log-level", dest="log_level", default=None, metavar="LEVEL", help=( "level of messages to catch/display.\n" "Not set by default, so it depends on the root/parent log handler's" ' effective level, where it is "WARNING" by default.'), ) add_option_ini( "--log-format", dest="log_format", default=DEFAULT_LOG_FORMAT, help="log format as used by the logging module.", ) add_option_ini( "--log-date-format", dest="log_date_format", default=DEFAULT_LOG_DATE_FORMAT, help="log date format as used by the logging module.", ) parser.addini( "log_cli", default=False, type="bool", help= 'enable log display during test run (also known as "live logging").', ) add_option_ini("--log-cli-level", dest="log_cli_level", default=None, help="cli logging level.") add_option_ini( "--log-cli-format", dest="log_cli_format", default=None, help="log format as used by the logging module.", ) add_option_ini( "--log-cli-date-format", dest="log_cli_date_format", default=None, help="log date format as used by the logging module.", ) add_option_ini( "--log-file", dest="log_file", default=None, help="path to a file when logging will be written to.", ) add_option_ini( "--log-file-level", dest="log_file_level", default=None, help="log file logging level.", ) add_option_ini( "--log-file-format", dest="log_file_format", default=DEFAULT_LOG_FORMAT, help="log format as used by the logging module.", ) add_option_ini( "--log-file-date-format", dest="log_file_date_format", default=DEFAULT_LOG_DATE_FORMAT, help="log date format as used by the logging module.", ) add_option_ini( "--log-auto-indent", dest="log_auto_indent", default=None, help= "Auto-indent multiline messages passed to the logging module. Accepts true|on, false|off or an integer.", )
def pytest_addoption(parser: Parser) -> None: help = ("Dump the traceback of all threads if a test takes " "more than TIMEOUT seconds to finish.") parser.addini("faulthandler_timeout", help, default=0.0)