def test_group_ordering(self, parser: parseopt.Parser) -> None: parser.getgroup("1") parser.getgroup("2") parser.getgroup("3", after="1") groups = parser._groups groups_names = [x.name for x in groups] assert groups_names == list("132")
def pytest_addoption(parser: Parser): api_group = parser.getgroup("api", after="web") api_group.addoption(API_URL, help='Base URL of the application API') web_group = parser.getgroup("web") web_group.addoption(APP_URL, help='Base URL of the application') web_group.addoption(BROWSER, help='Possible values: ' 'chrome | firefox') web_group.addoption(WEBDRIVER_FOLDER, help='Path to folder with browser driver')
def test_group_shortopt_lowercase(self, parser: parseopt.Parser) -> None: group = parser.getgroup("hello") with pytest.raises(ValueError): group.addoption("-x", action="store_true") assert len(group.options) == 0 group._addoption("-x", action="store_true") assert len(group.options) == 1
def pytest_addoption(parser: Parser) -> None: # noqa: D103 group = parser.getgroup("mypy-tests") group.addoption( "--mypy-testing-base", type=str, default=tempfile.gettempdir(), help="Base directory for tests to use", ) group.addoption( "--mypy-ini-file", type=str, help="Which .ini file to use as a default config for tests", ) group.addoption( "--mypy-same-process", action="store_true", help= "Run in the same process. Useful for debugging, will create problems with import cache", ) group.addoption( "--mypy-extension-hook", type=str, help= "Fully qualified path to the extension hook function, in case you need custom yaml keys. " "Has to be top-level.", )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("recording") group.addoption( "--record-mode", action="store", default=None, choices=RECORD_MODES, help='VCR.py record mode. Default to "none".', ) group.addoption("--block-network", action="store_true", default=False, help="Block network access except for VCR recording.") group.addoption( "--allowed-hosts", action="store", default=None, help= "List of regexes, separated by comma, to match hosts to where connection must be allowed.", ) group.addoption( "--disable-recording", action="store_true", default=False, help="Disable VCR.py integration.", )
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: """Registers argparse-style options for Ensembl's unit testing. `Pytest initialisation hook <https://docs.pytest.org/en/latest/reference.html#_pytest.hookspec.pytest_addoption>`_. Args: parser: Parser for command line arguments and ini-file values. """ # Add the Ensembl unitary test parameters to pytest parser group = parser.getgroup("ensembl unit testing") group.addoption( '--server', action='store', metavar='URL', dest='server', required=True, help="URL to the server where to create the test database(s).") group.addoption( '--keep-data', action='store_true', dest='keep_data', help= "Do not remove test databases/temporary directories. Default: False")
def test_pytest_addoption(self, test_pytest_parser: Parser) -> None: pytest_addoption(test_pytest_parser) group = test_pytest_parser.getgroup(_PLUGIN_NAME, _GROUP_HELP) assert isinstance(group, OptionGroup) assert len(group.options) == 1 assert group.options[0].names() == _Options.enable_injection.names() assert group.options[0].attrs() == _Options.enable_injection.attrs()
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("jobserver") group.addoption( "--jobserver", action="store", metavar="FILE", help="Named pipe to use as jobserver. If xdist is active, this is the filepath as seen by the worker nodes.", )
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("debugconfig") group.addoption( "--setupplan", "--setup-plan", action="store_true", help="show what fixtures and tests would be executed but " "don't execute anything.", )
def test_pytest_addoption(self): parser = Parser() plugin.pytest_addoption(parser) options = parser.getgroup("terminal reporting").options assert options[0].names() == ["--timer-top-n"] assert options[1].names() == ["--timer-no-color"] assert options[2].names() == ["--timer-filter"]
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("terminal reporting", "resultlog plugin options") group.addoption( "--resultlog", "--result-log", action="store", metavar="path", default=None, help="DEPRECATED path for machine-readable result log.", )
def pytest_addoption(parser: PytestParser) -> None: """ Add options to the pytest runner configurations. """ group = parser.getgroup("snappiershot") group.addoption( "--snappiershot-full-diff", action="store_true", default=False, dest=PACKAGE_FULL_DIFF_OPTION, help="Display full snapshot diff on failure. ", )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("terminal reporting", "reporting", after="general") group.addoption( "--durations", action="store", type=int, default=None, metavar="N", help="show N slowest setup/test durations (N=0 for all).", )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("debugconfig") group.addoption( "--version", "-V", action="count", default=0, dest="version", help="display pytest version and information about plugins. " "When given twice, also display information about plugins.", ) group._addoption( "-h", "--help", action=HelpAction, dest="help", help="show help message and configuration info", ) group._addoption( "-p", action="append", dest="plugins", default=[], metavar="name", help= "early-load given plugin module name or entry point (multi-allowed).\n" "To avoid loading of plugins, use the `no:` prefix, e.g. " "`no:doctest`.", ) group.addoption( "--traceconfig", "--trace-config", action="store_true", default=False, help="trace considerations of conftest.py files.", ) group.addoption( "--debug", action="store", nargs="?", const="pytestdebug.log", dest="debug", metavar="DEBUG_FILE_NAME", help="store internal tracing debug information in this log file.\n" "This file is opened with 'w' and truncated as a result, care advised.\n" "Defaults to 'pytestdebug.log'.", ) group._addoption( "-o", "--override-ini", dest="override_ini", action="append", help= 'override ini option with "option=value" style, e.g. `-o xfail_strict=True -o cache_dir=cache`.', )
def pytest_addoption(parser: Parser) -> None: """Register argparse-style options for CITest.""" group = parser.getgroup("continuous integration test (citest)") group.addoption('--reference-db', action='store', metavar='URL', dest='reference_db', help="URL to the reference database") group.addoption('--reference-dir', action='store', metavar='PATH', dest='reference_dir', help="Path to reference's root directory") group.addoption('--target-db', action='store', metavar='URL', dest='target_db', help="URL to the target database") group.addoption('--target-dir', action='store', metavar='PATH', dest='target_dir', help="Path to target's root directory")
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("terminal reporting") group._addoption( "--pastebin", metavar="mode", action="store", dest="pastebin", default=None, choices=["failed", "all"], help="send failed|all info to bpaste.net pastebin service.", )
def pytest_addoption(parser: Parser) -> None: """Turns on emoji parser feature. Args: parser (Parser): cli parser """ group: OptionGroup = parser.getgroup("emoji") group.addoption("--emoji-out", "--eo", action="store_true", help="Adds emoji to pytest results")
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup('mypy-tests') group.addoption('--mypy-testing-base', type=str, default='/tmp', help='Base directory for tests to use') group.addoption('--mypy-ini-file', type=str, help='Which .ini file to use as a default config for tests') group.addoption('--mypy-same-process', action='store_true', help='Run in the same process. Useful for debugging, will create problems with import cache') group.addoption('--mypy-extension-hook', type=str, help='Fully qualifield path to the extension hook function, in case you need custom yaml keys. ' 'Has to be top-level.')
def test_multiple_metavar_help(self, parser: parseopt.Parser) -> None: """ Help text for options with a metavar tuple should display help in the form "--preferences=value1 value2 value3" (#2004). """ group = parser.getgroup("general") group.addoption("--preferences", metavar=("value1", "value2", "value3"), nargs=3) group._addoption("-h", "--help", action="store_true", dest="help") parser.parse(["-h"]) help = parser.optparser.format_help() assert "--preferences=value1 value2 value3" in help
def test_drop_short_help1(self, parser: parseopt.Parser) -> None: group = parser.getgroup("general") group.addoption("--doit", "--func-args", action="store_true", help="foo") group._addoption( "-h", "--help", action="store_true", dest="help", help="show help message and configuration info", ) parser.parse(["-h"]) help = parser.optparser.format_help() assert "-doit, --func-args foo" in help
def pytest_addoption(parser: Parser, pluginmanager): """ Adds command line options used by the Seekret plugin. """ _ = pluginmanager # Unused. group = parser.getgroup('seekret') group.addoption('--run-profile', dest='run_profile', type=str, default=None, help='Run profile YAML file to use for the test session')
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("debugconfig") group.addoption( "--setuponly", "--setup-only", action="store_true", help="only setup fixtures, do not execute tests.", ) group.addoption( "--setupshow", "--setup-show", action="store_true", help="show setup of fixtures while executing tests.", )
def pytest_addoption(parser: Parser) -> None: """Add pytest command line options to configure nuts""" group = parser.getgroup("nuts") # Nornir context specific parameters group.addoption( "--nornir-config", "--nornir-configuration", action="store", dest="nornir_configuration", default=NornirNutsContext.DEFAULT_NORNIR_CONFIG_FILE, metavar="NORNIR_CONFIG", help="nuts nornir configuration file. Default is nr-config.yaml", )
def pytest_addoption(parser: Parser): xray = parser.getgroup('Jira Xray report') xray.addoption(JIRA_XRAY_FLAG, action='store_true', default=False, help='Upload test results to JIRA XRAY') xray.addoption(JIRA_CLOUD, action='store_true', default=False, help='Use with JIRA XRAY could server') xray.addoption( JIRA_API_KEY, action='store_true', default=False, help='Use API Key authentication', ) xray.addoption( JIRA_TOKEN, action='store_true', default=False, help='Use token authentication', ) xray.addoption( JIRA_CLIENT_SECRET_AUTH, action='store_true', default=False, help='Use client secret authentication', ) xray.addoption(XRAY_EXECUTION_ID, action='store', metavar='ExecutionId', default=None, help='XRAY Test Execution ID') xray.addoption(XRAY_TEST_PLAN_ID, action='store', metavar='TestplanId', default=None, help='XRAY Test Plan ID') xray.addoption( XRAYPATH, action='store', metavar='path', default=None, help= 'Do not upload to a server but create JSON report file at given path') xray.addoption( XRAY_ALLOW_DUPLICATE_IDS, action='store_true', default=False, help='Allow test ids to be present on multiple pytest tests')
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("factoryboy-state") group.addoption( "--show-state", action="store_true", dest="show_state", default=False, help="Show factoryboy state for failures.", ) group.addoption( "--set-state", action="store", dest="factoryboy_state", default=None, help="Set factoryboy state.", )
def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("general") group.addoption( "--sw", "--stepwise", action="store_true", dest="stepwise", help= "exit on test failure and continue from last failing test next time", ) group.addoption( "--stepwise-skip", action="store_true", dest="stepwise_skip", help="ignore the first failing test but stop on the next failing test", )