|
11 | 11 | from warnings import warn |
12 | 12 |
|
13 | 13 | from _pytest.warning_types import PytestDeprecationWarning |
| 14 | +from _pytest.warning_types import PytestRemovedIn7Warning |
| 15 | +from _pytest.warning_types import PytestRemovedIn8Warning |
14 | 16 | from _pytest.warning_types import UnformattedWarning |
15 | 17 |
|
16 | 18 | # set of plugins which have been integrated into the core; we use this list to ignore |
|
23 | 25 |
|
24 | 26 |
|
25 | 27 | FILLFUNCARGS = UnformattedWarning( |
26 | | - PytestDeprecationWarning, |
| 28 | + PytestRemovedIn7Warning, |
27 | 29 | "{name} is deprecated, use " |
28 | 30 | "function._request._fillfixtures() instead if you cannot avoid reaching into internals.", |
29 | 31 | ) |
30 | 32 |
|
31 | 33 | PYTEST_COLLECT_MODULE = UnformattedWarning( |
32 | | - PytestDeprecationWarning, |
| 34 | + PytestRemovedIn7Warning, |
33 | 35 | "pytest.collect.{name} was moved to pytest.{name}\n" |
34 | 36 | "Please update to the new name.", |
35 | 37 | ) |
36 | 38 |
|
| 39 | +# This can be* removed pytest 8, but it's harmless and common, so no rush to remove. |
| 40 | +# * If you're in the future: "could have been". |
37 | 41 | YIELD_FIXTURE = PytestDeprecationWarning( |
38 | 42 | "@pytest.yield_fixture is deprecated.\n" |
39 | 43 | "Use @pytest.fixture instead; they are the same." |
40 | 44 | ) |
41 | 45 |
|
42 | | -MINUS_K_DASH = PytestDeprecationWarning( |
| 46 | +MINUS_K_DASH = PytestRemovedIn7Warning( |
43 | 47 | "The `-k '-expr'` syntax to -k is deprecated.\nUse `-k 'not expr'` instead." |
44 | 48 | ) |
45 | 49 |
|
46 | | -MINUS_K_COLON = PytestDeprecationWarning( |
| 50 | +MINUS_K_COLON = PytestRemovedIn7Warning( |
47 | 51 | "The `-k 'expr:'` syntax to -k is deprecated.\n" |
48 | 52 | "Please open an issue if you use this and want a replacement." |
49 | 53 | ) |
50 | 54 |
|
51 | | -WARNING_CAPTURED_HOOK = PytestDeprecationWarning( |
| 55 | +WARNING_CAPTURED_HOOK = PytestRemovedIn7Warning( |
52 | 56 | "The pytest_warning_captured is deprecated and will be removed in a future release.\n" |
53 | 57 | "Please use pytest_warning_recorded instead." |
54 | 58 | ) |
55 | 59 |
|
56 | | -WARNING_CMDLINE_PREPARSE_HOOK = PytestDeprecationWarning( |
| 60 | +WARNING_CMDLINE_PREPARSE_HOOK = PytestRemovedIn8Warning( |
57 | 61 | "The pytest_cmdline_preparse hook is deprecated and will be removed in a future release. \n" |
58 | 62 | "Please use pytest_load_initial_conftests hook instead." |
59 | 63 | ) |
60 | 64 |
|
61 | | -FSCOLLECTOR_GETHOOKPROXY_ISINITPATH = PytestDeprecationWarning( |
| 65 | +FSCOLLECTOR_GETHOOKPROXY_ISINITPATH = PytestRemovedIn8Warning( |
62 | 66 | "The gethookproxy() and isinitpath() methods of FSCollector and Package are deprecated; " |
63 | 67 | "use self.session.gethookproxy() and self.session.isinitpath() instead. " |
64 | 68 | ) |
65 | 69 |
|
66 | | -STRICT_OPTION = PytestDeprecationWarning( |
| 70 | +STRICT_OPTION = PytestRemovedIn8Warning( |
67 | 71 | "The --strict option is deprecated, use --strict-markers instead." |
68 | 72 | ) |
69 | 73 |
|
| 74 | +# This deprecation is never really meant to be removed. |
70 | 75 | PRIVATE = PytestDeprecationWarning("A private pytest class or function was used.") |
71 | 76 |
|
72 | | -UNITTEST_SKIP_DURING_COLLECTION = PytestDeprecationWarning( |
| 77 | +UNITTEST_SKIP_DURING_COLLECTION = PytestRemovedIn8Warning( |
73 | 78 | "Raising unittest.SkipTest to skip tests during collection is deprecated. " |
74 | 79 | "Use pytest.skip() instead." |
75 | 80 | ) |
76 | 81 |
|
77 | | -ARGUMENT_PERCENT_DEFAULT = PytestDeprecationWarning( |
| 82 | +ARGUMENT_PERCENT_DEFAULT = PytestRemovedIn8Warning( |
78 | 83 | 'pytest now uses argparse. "%default" should be changed to "%(default)s"', |
79 | 84 | ) |
80 | 85 |
|
81 | 86 | ARGUMENT_TYPE_STR_CHOICE = UnformattedWarning( |
82 | | - PytestDeprecationWarning, |
| 87 | + PytestRemovedIn8Warning, |
83 | 88 | "`type` argument to addoption() is the string {typ!r}." |
84 | 89 | " For choices this is optional and can be omitted, " |
85 | 90 | " but when supplied should be a type (for example `str` or `int`)." |
86 | 91 | " (options: {names})", |
87 | 92 | ) |
88 | 93 |
|
89 | 94 | ARGUMENT_TYPE_STR = UnformattedWarning( |
90 | | - PytestDeprecationWarning, |
| 95 | + PytestRemovedIn8Warning, |
91 | 96 | "`type` argument to addoption() is the string {typ!r}, " |
92 | 97 | " but when supplied should be a type (for example `str` or `int`)." |
93 | 98 | " (options: {names})", |
94 | 99 | ) |
95 | 100 |
|
96 | 101 |
|
97 | 102 | HOOK_LEGACY_PATH_ARG = UnformattedWarning( |
98 | | - PytestDeprecationWarning, |
| 103 | + PytestRemovedIn8Warning, |
99 | 104 | "The ({pylib_path_arg}: py.path.local) argument is deprecated, please use ({pathlib_path_arg}: pathlib.Path)\n" |
100 | 105 | "see https://docs.pytest.org/en/latest/deprecations.html" |
101 | 106 | "#py-path-local-arguments-for-hooks-replaced-with-pathlib-path", |
102 | 107 | ) |
103 | 108 |
|
104 | 109 | NODE_CTOR_FSPATH_ARG = UnformattedWarning( |
105 | | - PytestDeprecationWarning, |
| 110 | + PytestRemovedIn8Warning, |
106 | 111 | "The (fspath: py.path.local) argument to {node_type_name} is deprecated. " |
107 | 112 | "Please use the (path: pathlib.Path) argument instead.\n" |
108 | 113 | "See https://docs.pytest.org/en/latest/deprecations.html" |
109 | 114 | "#fspath-argument-for-node-constructors-replaced-with-pathlib-path", |
110 | 115 | ) |
111 | 116 |
|
112 | | -WARNS_NONE_ARG = PytestDeprecationWarning( |
| 117 | +WARNS_NONE_ARG = PytestRemovedIn8Warning( |
113 | 118 | "Passing None to catch any warning has been deprecated, pass no arguments instead:\n" |
114 | 119 | " Replace pytest.warns(None) by simply pytest.warns()." |
115 | 120 | ) |
116 | 121 |
|
117 | 122 | KEYWORD_MSG_ARG = UnformattedWarning( |
118 | | - PytestDeprecationWarning, |
| 123 | + PytestRemovedIn8Warning, |
119 | 124 | "pytest.{func}(msg=...) is now deprecated, use pytest.{func}(reason=...) instead", |
120 | 125 | ) |
121 | 126 |
|
122 | | -INSTANCE_COLLECTOR = PytestDeprecationWarning( |
| 127 | +INSTANCE_COLLECTOR = PytestRemovedIn8Warning( |
123 | 128 | "The pytest.Instance collector type is deprecated and is no longer used. " |
124 | 129 | "See https://docs.pytest.org/en/latest/deprecations.html#the-pytest-instance-collector", |
125 | 130 | ) |
|
0 commit comments