Skip to content

Commit 51f77b5

Browse files
committed
Fix docs
1 parent dfc767c commit 51f77b5

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

doc/source/contributing.rst

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,14 @@ Otherwise, you need to do it manually:
632632
warnings.warn('Use new_func instead.', FutureWarning, stacklevel=2)
633633
new_func()
634634
635+
You'll also need to
636+
637+
1. write a new test that asserts a warning is issued when calling with the deprecated argument
638+
2. Update all of pandas existing tests and code to use the new argument
639+
640+
See :ref:`contributing.warnings` for more.
641+
642+
635643
.. _contributing.ci:
636644

637645
Testing With Continuous Integration
@@ -859,20 +867,30 @@ preferred if the inputs or logic are simple, with Hypothesis tests reserved
859867
for cases with complex logic or where there are too many combinations of
860868
options or subtle interactions to test (or think of!) all of them.
861869

862-
.. _warnings:
870+
.. _contributing.warnings:
863871

864-
Warnings
865-
~~~~~~~~
872+
Testing Warnings
873+
~~~~~~~~~~~~~~~~
866874

867-
By default, pandas test suite will fail if any unhandled warnings are emitted.
875+
By default, one of pandas CI workers will fail if any unhandled warnings are emitted.
868876

869877
If your change involves checking that a warning is actually emitted, use
870-
``tm.assert_produces_warning(ExpectedWarning)``. We prefer this to pytest's
871-
``pytest.warns`` context manager because ours checks that the warning's stacklevel
872-
is set correctly.
878+
``tm.assert_produces_warning(ExpectedWarning)``.
879+
880+
881+
.. code-block:: python
882+
883+
with tm.assert_prodcues_warning(FutureWarning):
884+
df.some_operation()
885+
886+
We prefer this to the ``pytest.warns`` context manager because ours checks that the warning's
887+
stacklevel is set correctly. The stacklevel is what ensure the *user's* file name and line number
888+
is printed in the warning, rather than something internal to pandas. It represents the nubmer of
889+
function calls from user code (e.g. ``df.some_operation()``) to the function that actually emits
890+
the warning.
873891

874892
If you have a test that would emit a warning, but you aren't actually testing the
875-
warning it self (say because it's going to be removed in the future, or because we're
893+
warning itself (say because it's going to be removed in the future, or because we're
876894
matching a 3rd-party library's behavior), then use ``pytest.mark.filterwarnings`` to
877895
ignore the error.
878896

0 commit comments

Comments
 (0)