Skip to content

Commit 8daf9a7

Browse files
API: expose public testing functions in pandas.testing (GH9895) (#16003)
1 parent 1f812e3 commit 8daf9a7

File tree

6 files changed

+49
-4
lines changed

6 files changed

+49
-4
lines changed

doc/source/api.rst

+10
Original file line numberDiff line numberDiff line change
@@ -1886,3 +1886,13 @@ Working with options
18861886
get_option
18871887
set_option
18881888
option_context
1889+
1890+
Testing functions
1891+
~~~~~~~~~~~~~~~~~
1892+
1893+
.. autosummary::
1894+
:toctree: generated/
1895+
1896+
testing.assert_frame_equal
1897+
testing.assert_series_equal
1898+
testing.assert_index_equal

doc/source/whatsnew/v0.20.0.txt

+17-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ Commonly called 'unix epoch' or POSIX time. This was the previous default, so th
150150

151151
.. _whatsnew_0200.enhancements.errors:
152152

153-
pandas errors
154-
^^^^^^^^^^^^^
153+
``pandas.errors``
154+
^^^^^^^^^^^^^^^^^
155155

156156
We are adding a standard public module for all pandas exceptions & warnings ``pandas.errors``. (:issue:`14800`). Previously
157157
these exceptions & warnings could be imported from ``pandas.core.common`` or ``pandas.io.common``. These exceptions and warnings
@@ -170,6 +170,21 @@ The following are now part of this API:
170170
'UnsortedIndexError',
171171
'UnsupportedFunctionCall']
172172

173+
174+
.. _whatsnew_0200.enhancements.testing:
175+
176+
``pandas.testing``
177+
^^^^^^^^^^^^^^^^^^
178+
179+
We are adding a standard module that exposes the public testing functions in ``pandas.testing``(:issue:`9895`). Those functions can be used when writing tests for functionality using pandas objects.
180+
181+
The following testing functions are now part of this API:
182+
183+
- :func:`testing.assert_frame_equal`
184+
- :func:`testing.assert_series_equal`
185+
- :func:`testing.assert_index_equal`
186+
187+
173188
.. _whatsnew_0200.enhancements.groupby_access:
174189

175190
Groupby Enhancements

pandas/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
from pandas.util.print_versions import show_versions
6565
from pandas.io.api import *
6666
from pandas.util._tester import test
67+
import pandas.testing
6768

6869
# extension module deprecations
6970
from pandas.util.depr_module import _DeprecatedModule

pandas/testing.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# flake8: noqa
2+
3+
"""
4+
Public testing utility functions.
5+
"""
6+
7+
from pandas.util.testing import (
8+
assert_frame_equal, assert_series_equal, assert_index_equal)

pandas/tests/api/test_api.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TestPDApi(Base, tm.TestCase):
3232
# top-level sub-packages
3333
lib = ['api', 'compat', 'core',
3434
'indexes', 'errors', 'pandas',
35-
'plotting', 'test', 'tools', 'tseries',
35+
'plotting', 'test', 'testing', 'tools', 'tseries',
3636
'util', 'options', 'io']
3737

3838
# these are already deprecated; awaiting removal
@@ -128,6 +128,17 @@ def test_api(self):
128128
self.check(api, self.allowed)
129129

130130

131+
class TestTesting(Base):
132+
133+
funcs = ['assert_frame_equal', 'assert_series_equal',
134+
'assert_index_equal']
135+
136+
def test_testing(self):
137+
138+
from pandas import testing
139+
self.check(testing, self.funcs)
140+
141+
131142
class TestDatetoolsDeprecation(tm.TestCase):
132143

133144
def test_deprecation_access_func(self):

pandas/util/testing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ def assert_index_equal(left, right, exact='equiv', check_names=True,
861861
right : Index
862862
exact : bool / string {'equiv'}, default False
863863
Whether to check the Index class, dtype and inferred_type
864-
are identical. If 'equiv', then RangeIndex can be substitued for
864+
are identical. If 'equiv', then RangeIndex can be substituted for
865865
Int64Index as well
866866
check_names : bool, default True
867867
Whether to check the names attribute.

0 commit comments

Comments
 (0)