Skip to content

Commit 6bca579

Browse files
committed
Refinements
1 parent 92a4e7e commit 6bca579

File tree

4 files changed

+49
-36
lines changed

4 files changed

+49
-36
lines changed

pandas/errors/__init__.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ class PandasChangeWarning(Warning):
9898
9999
See Also
100100
--------
101-
errors.Pandas4Warning : Class for deprecations to be enforced in pandas 4.0.
101+
errors.PandasPendingDeprecationWarning : Class for deprecations that will raise a
102+
PendingDeprecationWarning.
103+
errors.PandasDeprecationWarning : Class for deprecations that will raise a
104+
DeprecationWarning.
102105
errors.PandasFutureWarning : Class for deprecations that will raise a FutureWarning.
103106
104107
Examples
@@ -119,7 +122,9 @@ class PandasPendingDeprecationWarning(PandasChangeWarning, PendingDeprecationWar
119122
120123
See Also
121124
--------
122-
errors.Pandas4Warning : Class for deprecations to be enforced in pandas 4.0.
125+
errors.PandasChangeWarning: Class for deprecations that will raise any warning.
126+
errors.PandasDeprecationWarning : Class for deprecations that will raise a
127+
DeprecationWarning.
123128
errors.PandasFutureWarning : Class for deprecations that will raise a FutureWarning.
124129
125130
Examples
@@ -135,7 +140,9 @@ class PandasDeprecationWarning(PandasChangeWarning, DeprecationWarning):
135140
136141
See Also
137142
--------
138-
errors.Pandas4Warning : Class for deprecations to be enforced in pandas 4.0.
143+
errors.PandasChangeWarning: Class for deprecations that will raise any warning.
144+
errors.PandasPendingDeprecationWarning : Class for deprecations that will raise a
145+
PendingDeprecationWarning.
139146
errors.PandasFutureWarning : Class for deprecations that will raise a FutureWarning.
140147
141148
Examples
@@ -151,7 +158,11 @@ class PandasFutureWarning(PandasChangeWarning, FutureWarning):
151158
152159
See Also
153160
--------
154-
errors.Pandas4Warning : Class for deprecations to be enforced in pandas 4.0.
161+
errors.PandasChangeWarning: Class for deprecations that will raise any warning.
162+
errors.PandasPendingDeprecationWarning : Class for deprecations that will raise a
163+
PendingDeprecationWarning.
164+
errors.PandasDeprecationWarning : Class for deprecations that will raise a
165+
DeprecationWarning.
155166
156167
Examples
157168
--------
@@ -166,6 +177,11 @@ class Pandas4Warning(PandasDeprecationWarning):
166177
167178
See Also
168179
--------
180+
errors.PandasChangeWarning: Class for deprecations that will raise any warning.
181+
errors.PandasPendingDeprecationWarning : Class for deprecations that will raise a
182+
PendingDeprecationWarning.
183+
errors.PandasDeprecationWarning : Class for deprecations that will raise a
184+
DeprecationWarning.
169185
errors.PandasFutureWarning : Class for deprecations that will raise a FutureWarning.
170186
171187
Examples
@@ -186,7 +202,11 @@ class Pandas5Warning(PandasPendingDeprecationWarning):
186202
187203
See Also
188204
--------
189-
errors.Pandas4Warning : Class for deprecations to be enforced in pandas 4.0.
205+
errors.PandasChangeWarning: Class for deprecations that will raise any warning.
206+
errors.PandasPendingDeprecationWarning : Class for deprecations that will raise a
207+
PendingDeprecationWarning.
208+
errors.PandasDeprecationWarning : Class for deprecations that will raise a
209+
DeprecationWarning.
190210
errors.PandasFutureWarning : Class for deprecations that will raise a FutureWarning.
191211
192212
Examples

pandas/tests/test_errors.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,21 @@ def test_AbstractMethodError_classmethod():
112112
Foo().method()
113113

114114

115+
@pytest.mark.parametrize(
116+
"warn_category, catch_category",
117+
[
118+
(Pandas4Warning, PandasChangeWarning),
119+
(Pandas4Warning, PandasDeprecationWarning),
120+
(Pandas5Warning, PandasChangeWarning),
121+
(Pandas5Warning, PandasPendingDeprecationWarning),
122+
],
123+
)
124+
def test_pandas_warnings(warn_category, catch_category):
125+
# https://github.com/pandas-dev/pandas/pull/61468
126+
with tm.assert_produces_warning(catch_category):
127+
warnings.warn("test", category=warn_category)
128+
129+
115130
@pytest.mark.parametrize(
116131
"warn_category, filter_category",
117132
[

pandas/tests/util/test_deprecate_nonkeyword_arguments.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def test_four_arguments():
5555

5656
def test_three_arguments_with_name_in_warning():
5757
msg = (
58-
"Starting with pandas version 4.0 all arguments of f_add_inputs "
59-
"except for the arguments 'a' and 'b' will be keyword-only."
58+
f"Starting with pandas version {WARNING_CATEGORY.version()} all arguments of "
59+
"f_add_inputs except for the arguments 'a' and 'b' will be keyword-only."
6060
)
6161
with tm.assert_produces_warning(WARNING_CATEGORY, match=msg):
6262
assert f(6, 3, 3) == 12
@@ -84,7 +84,7 @@ def test_three_arguments_default_allowed_args():
8484

8585
def test_three_positional_argument_with_warning_message_analysis():
8686
msg = (
87-
"Starting with pandas version 4.0 all arguments of g "
87+
f"Starting with pandas version {WARNING_CATEGORY.version()} all arguments of g "
8888
"except for the argument 'a' will be keyword-only."
8989
)
9090
with tm.assert_produces_warning(WARNING_CATEGORY, match=msg):
@@ -111,7 +111,10 @@ def test_one_positional_argument():
111111

112112

113113
def test_one_positional_argument_with_warning_message_analysis():
114-
msg = "Starting with pandas version 4.0 all arguments of h will be keyword-only."
114+
msg = (
115+
f"Starting with pandas version {WARNING_CATEGORY.version()} all arguments "
116+
"of h will be keyword-only."
117+
)
115118
with tm.assert_produces_warning(WARNING_CATEGORY, match=msg):
116119
assert h(19) == 19
117120

@@ -141,8 +144,8 @@ def test_foo_signature():
141144

142145
def test_class():
143146
msg = (
144-
r"Starting with pandas version 4.0 all arguments of Foo\.baz "
145-
r"except for the argument \'bar\' will be keyword-only"
147+
rf"Starting with pandas version {WARNING_CATEGORY.version()} all arguments "
148+
r"of Foo\.baz except for the argument \'bar\' will be keyword-only"
146149
)
147150
with tm.assert_produces_warning(WARNING_CATEGORY, match=msg):
148151
Foo().baz("qux", "quox")

pandas/tests/util/test_pandas_deprecation_warning.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)