diff --git a/doc/source/api.rst b/doc/source/api.rst index 6d1765ce65714..d0f548cc3d0b1 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -1886,3 +1886,13 @@ Working with options get_option set_option option_context + +Testing functions +~~~~~~~~~~~~~~~~~ + +.. autosummary:: + :toctree: generated/ + + testing.assert_frame_equal + testing.assert_series_equal + testing.assert_index_equal diff --git a/doc/source/whatsnew/v0.20.0.txt b/doc/source/whatsnew/v0.20.0.txt index 08208973b70d2..de33b7d4e3371 100644 --- a/doc/source/whatsnew/v0.20.0.txt +++ b/doc/source/whatsnew/v0.20.0.txt @@ -150,8 +150,8 @@ Commonly called 'unix epoch' or POSIX time. This was the previous default, so th .. _whatsnew_0200.enhancements.errors: -pandas errors -^^^^^^^^^^^^^ +``pandas.errors`` +^^^^^^^^^^^^^^^^^ We are adding a standard public module for all pandas exceptions & warnings ``pandas.errors``. (:issue:`14800`). Previously 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: 'UnsortedIndexError', 'UnsupportedFunctionCall'] + +.. _whatsnew_0200.enhancements.testing: + +``pandas.testing`` +^^^^^^^^^^^^^^^^^^ + +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. + +The following testing functions are now part of this API: + +- :func:`testing.assert_frame_equal` +- :func:`testing.assert_series_equal` +- :func:`testing.assert_index_equal` + + .. _whatsnew_0200.enhancements.groupby_access: Groupby Enhancements diff --git a/pandas/__init__.py b/pandas/__init__.py index 4e1bcbd613965..b221f9e43876b 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -64,6 +64,7 @@ from pandas.util.print_versions import show_versions from pandas.io.api import * from pandas.util._tester import test +import pandas.testing # extension module deprecations from pandas.util.depr_module import _DeprecatedModule diff --git a/pandas/testing.py b/pandas/testing.py new file mode 100644 index 0000000000000..3baf99957cb33 --- /dev/null +++ b/pandas/testing.py @@ -0,0 +1,8 @@ +# flake8: noqa + +""" +Public testing utility functions. +""" + +from pandas.util.testing import ( + assert_frame_equal, assert_series_equal, assert_index_equal) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 32ed77d94f637..ec9e6039c6ee4 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -32,7 +32,7 @@ class TestPDApi(Base, tm.TestCase): # top-level sub-packages lib = ['api', 'compat', 'core', 'indexes', 'errors', 'pandas', - 'plotting', 'test', 'tools', 'tseries', + 'plotting', 'test', 'testing', 'tools', 'tseries', 'util', 'options', 'io'] # these are already deprecated; awaiting removal @@ -128,6 +128,17 @@ def test_api(self): self.check(api, self.allowed) +class TestTesting(Base): + + funcs = ['assert_frame_equal', 'assert_series_equal', + 'assert_index_equal'] + + def test_testing(self): + + from pandas import testing + self.check(testing, self.funcs) + + class TestDatetoolsDeprecation(tm.TestCase): def test_deprecation_access_func(self): diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 08323fc0c9050..d1f88c7041e05 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -861,7 +861,7 @@ def assert_index_equal(left, right, exact='equiv', check_names=True, right : Index exact : bool / string {'equiv'}, default False Whether to check the Index class, dtype and inferred_type - are identical. If 'equiv', then RangeIndex can be substitued for + are identical. If 'equiv', then RangeIndex can be substituted for Int64Index as well check_names : bool, default True Whether to check the names attribute.