in case of warnings which need to format their messages. """ from _pytest.warning_types import PytestDeprecationWarning from _pytest.warning_types import UnformattedWarning # set of plugins which have been integrated into the core; we use this list to ignore # them during registration to avoid conflicts DEPRECATED_EXTERNAL_PLUGINS = { "pytest_catchlog", "pytest_capturelog", "pytest_faulthandler", } FILLFUNCARGS = UnformattedWarning( PytestDeprecationWarning, "{name} is deprecated, use " "function._request._fillfixtures() instead if you cannot avoid reaching into internals.", ) PYTEST_COLLECT_MODULE = UnformattedWarning( PytestDeprecationWarning, "pytest.collect.{name} was moved to pytest.{name}\n" "Please update to the new name.", ) YIELD_FIXTURE = PytestDeprecationWarning( "@pytest.yield_fixture is deprecated.\n" "Use @pytest.fixture instead; they are the same.") MINUS_K_DASH = PytestDeprecationWarning( "The `-k '-expr'` syntax to -k is deprecated.\nUse `-k 'not expr'` instead."
# This deprecation is never really meant to be removed. PRIVATE = PytestDeprecationWarning( "A private pytest class or function was used.") UNITTEST_SKIP_DURING_COLLECTION = PytestRemovedIn8Warning( "Raising unittest.SkipTest to skip tests during collection is deprecated. " "Use pytest.skip() instead.") ARGUMENT_PERCENT_DEFAULT = PytestRemovedIn8Warning( 'pytest now uses argparse. "%default" should be changed to "%(default)s"', ) ARGUMENT_TYPE_STR_CHOICE = UnformattedWarning( PytestRemovedIn8Warning, "`type` argument to addoption() is the string {typ!r}." " For choices this is optional and can be omitted, " " but when supplied should be a type (for example `str` or `int`)." " (options: {names})", ) ARGUMENT_TYPE_STR = UnformattedWarning( PytestRemovedIn8Warning, "`type` argument to addoption() is the string {typ!r}, " " but when supplied should be a type (for example `str` or `int`)." " (options: {names})", ) HOOK_LEGACY_PATH_ARG = UnformattedWarning( PytestRemovedIn8Warning, "The ({pylib_path_arg}: py.path.local) argument is deprecated, please use ({pathlib_path_arg}: pathlib.Path)\n" "see https://docs.pytest.org/en/latest/deprecations.html"
from _pytest.warning_types import UnformattedWarning, RemovedInPytest4Warning MAIN_STR_ARGS = RemovedInPytest4Warning( "passing a string to pytest.main() is deprecated, " "pass a list of arguments instead.") YIELD_TESTS = RemovedInPytest4Warning( "yield tests are deprecated, and scheduled to be removed in pytest 4.0") CACHED_SETUP = RemovedInPytest4Warning( "cached_setup is deprecated and will be removed in a future release. " "Use standard fixture functions instead.") COMPAT_PROPERTY = UnformattedWarning( RemovedInPytest4Warning, "usage of {owner}.{name} is deprecated, please use pytest.{name} instead", ) CUSTOM_CLASS = UnformattedWarning( RemovedInPytest4Warning, 'use of special named "{name}" objects in collectors of type "{type_name}" to ' "customize the created nodes is deprecated. " "Use pytest_pycollect_makeitem(...) to create custom " "collection nodes instead.", ) FUNCARG_PREFIX = UnformattedWarning( RemovedInPytest4Warning, '{name}: declaring fixtures using "pytest_funcarg__" prefix is deprecated ' "and scheduled to be removed in pytest 4.0. " "Please remove the prefix and use the @pytest.fixture decorator instead.",
from warnings import warn from _pytest.warning_types import PytestDeprecationWarning from _pytest.warning_types import UnformattedWarning # set of plugins which have been integrated into the core; we use this list to ignore # them during registration to avoid conflicts DEPRECATED_EXTERNAL_PLUGINS = { "pytest_catchlog", "pytest_capturelog", "pytest_faulthandler", } FILLFUNCARGS = UnformattedWarning( PytestDeprecationWarning, "{name} is deprecated, use " "function._request._fillfixtures() instead if you cannot avoid reaching into internals.", ) PYTEST_COLLECT_MODULE = UnformattedWarning( PytestDeprecationWarning, "pytest.collect.{name} was moved to pytest.{name}\n" "Please update to the new name.", ) YIELD_FIXTURE = PytestDeprecationWarning( "@pytest.yield_fixture is deprecated.\n" "Use @pytest.fixture instead; they are the same.") MINUS_K_DASH = PytestDeprecationWarning( "The `-k '-expr'` syntax to -k is deprecated.\nUse `-k 'not expr'` instead."
" {}\n" "Please move it to a top level conftest file at the rootdir:\n" " {}\n" "For more information, visit:\n" " https://docs.pytest.org/en/latest/deprecations.html#pytest-plugins-in-non-top-level-conftest-files" ) PYTEST_CONFIG_GLOBAL = PytestDeprecationWarning( "the `pytest.config` global is deprecated. Please use `request.config` " "or `pytest_configure` (if you're a pytest plugin) instead.") PYTEST_ENSURETEMP = RemovedInPytest4Warning( "pytest/tmpdir_factory.ensuretemp is deprecated, \n" "please use the tmp_path fixture or tmp_path_factory.mktemp") PYTEST_LOGWARNING = PytestDeprecationWarning( "pytest_logwarning is deprecated, no longer being called, and will be removed soon\n" "please use pytest_warning_captured instead") PYTEST_WARNS_UNKNOWN_KWARGS = UnformattedWarning( PytestDeprecationWarning, "pytest.warns() got unexpected keyword arguments: {args!r}.\n" "This will be an error in future versions.", ) PYTEST_PARAM_UNKNOWN_KWARGS = UnformattedWarning( PytestDeprecationWarning, "pytest.param() got unexpected keyword arguments: {args!r}.\n" "This will be an error in future versions.", )
"The `funcargnames` attribute was an alias for `fixturenames`, " "since pytest 2.3 - use the newer attribute instead.") RESULT_LOG = PytestDeprecationWarning( "--result-log is deprecated, please try the new pytest-reportlog plugin.\n" "See https://docs.pytest.org/en/latest/deprecations.html#result-log-result-log for more information." ) FIXTURE_POSITIONAL_ARGUMENTS = PytestDeprecationWarning( "Passing arguments to pytest.fixture() as positional arguments is deprecated - pass them " "as a keyword argument instead.") NODE_USE_FROM_PARENT = UnformattedWarning( PytestDeprecationWarning, "Direct construction of {name} has been deprecated, please use {name}.from_parent.\n" "See " "https://docs.pytest.org/en/latest/deprecations.html#node-construction-changed-to-node-from-parent" " for more details.", ) JUNIT_XML_DEFAULT_FAMILY = PytestDeprecationWarning( "The 'junit_family' default value will change to 'xunit2' in pytest 6.0.\n" "Add 'junit_family=xunit1' to your pytest.ini file to keep the current format " "in future versions of pytest and silence this warning.") NO_PRINT_LOGS = PytestDeprecationWarning( "--no-print-logs is deprecated and scheduled for removal in pytest 6.0.\n" "Please use --show-capture instead.") COLLECT_DIRECTORY_HOOK = PytestDeprecationWarning( "The pytest_collect_directory hook is not working.\n"
FUNCARGNAMES = PytestDeprecationWarning( "The `funcargnames` attribute was an alias for `fixturenames`, " "since pytest 2.3 - use the newer attribute instead.") RESULT_LOG = PytestDeprecationWarning( "--result-log is deprecated, please try the new pytest-reportlog plugin.\n" "See https://docs.pytest.org/en/latest/deprecations.html#result-log-result-log for more information." ) FIXTURE_POSITIONAL_ARGUMENTS = PytestDeprecationWarning( "Passing arguments to pytest.fixture() as positional arguments is deprecated - pass them " "as a keyword argument instead.") NODE_USE_FROM_PARENT = UnformattedWarning( PytestDeprecationWarning, "direct construction of {name} has been deprecated, please use {name}.from_parent", ) JUNIT_XML_DEFAULT_FAMILY = PytestDeprecationWarning( "The 'junit_family' default value will change to 'xunit2' in pytest 6.0.\n" "Add 'junit_family=xunit1' to your pytest.ini file to keep the current format " "in future versions of pytest and silence this warning.") NO_PRINT_LOGS = PytestDeprecationWarning( "--no-print-logs is deprecated and scheduled for removal in pytest 6.0.\n" "Please use --show-capture instead.") COLLECT_DIRECTORY_HOOK = PytestDeprecationWarning( "The pytest_collect_directory hook is not working.\n" "Please use collect_ignore in conftests or pytest_collection_modifyitems.")
# set of plugins which have been integrated into the core; we use this list to ignore # them during registration to avoid conflicts DEPRECATED_EXTERNAL_PLUGINS = { "pytest_catchlog", "pytest_capturelog", "pytest_faulthandler", } FILLFUNCARGS = PytestDeprecationWarning( "The `_fillfuncargs` function is deprecated, use " "function._request._fillfixtures() instead if you cannot avoid reaching into internals." ) PYTEST_COLLECT_MODULE = UnformattedWarning( PytestDeprecationWarning, "pytest.collect.{name} was moved to pytest.{name}\n" "Please update to the new name.", ) MINUS_K_DASH = PytestDeprecationWarning( "The `-k '-expr'` syntax to -k is deprecated.\nUse `-k 'not expr'` instead." ) MINUS_K_COLON = PytestDeprecationWarning( "The `-k 'expr:'` syntax to -k is deprecated.\n" "Please open an issue if you use this and want a replacement.") WARNING_CAPTURED_HOOK = PytestDeprecationWarning( "The pytest_warning_captured is deprecated and will be removed in a future release.\n" "Please use pytest_warning_recorded instead.")