@@ -632,6 +632,14 @@ Otherwise, you need to do it manually:
632
632
warnings.warn(' Use new_func instead.' , FutureWarning , stacklevel = 2 )
633
633
new_func()
634
634
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
+
635
643
.. _contributing.ci :
636
644
637
645
Testing With Continuous Integration
@@ -859,20 +867,30 @@ preferred if the inputs or logic are simple, with Hypothesis tests reserved
859
867
for cases with complex logic or where there are too many combinations of
860
868
options or subtle interactions to test (or think of!) all of them.
861
869
862
- .. _ warnings :
870
+ .. _ contributing.warnings :
863
871
864
- Warnings
865
- ~~~~~~~~
872
+ Testing Warnings
873
+ ~~~~~~~~~~~~~~~~
866
874
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.
868
876
869
877
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.
873
891
874
892
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
876
894
matching a 3rd-party library's behavior), then use ``pytest.mark.filterwarnings `` to
877
895
ignore the error.
878
896
0 commit comments