diff --git a/pandas/_testing/_io.py b/pandas/_testing/_io.py index 58ce9b17909bb..a0b6963cfac97 100644 --- a/pandas/_testing/_io.py +++ b/pandas/_testing/_io.py @@ -160,11 +160,10 @@ def network( Tests decorated with @network will fail if it's possible to make a network connection to another URL (defaults to google.com):: - >>> from pandas._testing import network - >>> from pandas.io.common import urlopen - >>> @network + >>> from pandas import _testing as ts + >>> @ts.network ... def test_network(): - ... with urlopen("rabbit://bonanza.com"): + ... with pd.io.common.urlopen("rabbit://bonanza.com"): ... pass Traceback ... @@ -172,7 +171,7 @@ def network( You can specify alternative URLs:: - >>> @network("https://www.yahoo.com") + >>> @ts.network("https://www.yahoo.com") ... def test_something_with_yahoo(): ... raise IOError("Failure Message") >>> test_something_with_yahoo() @@ -183,7 +182,7 @@ def network( If you set check_before_test, it will check the url first and not run the test on failure:: - >>> @network("failing://url.blaher", check_before_test=True) + >>> @ts.network("failing://url.blaher", check_before_test=True) ... def test_something(): ... print("I ran!") ... raise ValueError("Failure") diff --git a/pandas/_testing/asserters.py b/pandas/_testing/asserters.py index d0957b1814213..79c8e64fc4df3 100644 --- a/pandas/_testing/asserters.py +++ b/pandas/_testing/asserters.py @@ -303,10 +303,10 @@ def assert_index_equal( Examples -------- - >>> from pandas.testing import assert_index_equal + >>> from pandas import testing as tm >>> a = pd.Index([1, 2, 3]) >>> b = pd.Index([1, 2, 3]) - >>> assert_index_equal(a, b) + >>> tm.assert_index_equal(a, b) """ __tracebackhide__ = True @@ -794,10 +794,10 @@ def assert_extension_array_equal( Examples -------- - >>> from pandas.testing import assert_extension_array_equal + >>> from pandas import testing as tm >>> a = pd.Series([1, 2, 3, 4]) >>> b, c = a.array, a.array - >>> assert_extension_array_equal(b, c) + >>> tm.assert_extension_array_equal(b, c) """ if check_less_precise is not no_default: warnings.warn( @@ -938,10 +938,10 @@ def assert_series_equal( Examples -------- - >>> from pandas.testing import assert_series_equal + >>> from pandas import testing as tm >>> a = pd.Series([1, 2, 3, 4]) >>> b = pd.Series([1, 2, 3, 4]) - >>> assert_series_equal(a, b) + >>> tm.assert_series_equal(a, b) """ __tracebackhide__ = True diff --git a/pandas/core/dtypes/base.py b/pandas/core/dtypes/base.py index 7dad8c61f4fc7..372abee701b02 100644 --- a/pandas/core/dtypes/base.py +++ b/pandas/core/dtypes/base.py @@ -387,8 +387,7 @@ def register_extension_dtype(cls: type_t[ExtensionDtypeT]) -> type_t[ExtensionDt Examples -------- - >>> from pandas.api.extensions import register_extension_dtype - >>> from pandas.api.extensions import ExtensionDtype + >>> from pandas.api.extensions import register_extension_dtype, ExtensionDtype >>> @register_extension_dtype ... class MyExtensionDtype(ExtensionDtype): ... name = "myextension" diff --git a/pandas/io/formats/latex.py b/pandas/io/formats/latex.py index 93069a1e2955d..3ffb60a042f69 100644 --- a/pandas/io/formats/latex.py +++ b/pandas/io/formats/latex.py @@ -488,9 +488,8 @@ def _select_iterator(self, over: str) -> type[RowStringIterator]: class LongTableBuilder(GenericTableBuilder): """Concrete table builder for longtable. - >>> from pandas import DataFrame >>> from pandas.io.formats import format as fmt - >>> df = DataFrame({"a": [1, 2], "b": ["b1", "b2"]}) + >>> df = pd.DataFrame({"a": [1, 2], "b": ["b1", "b2"]}) >>> formatter = fmt.DataFrameFormatter(df) >>> builder = LongTableBuilder(formatter, caption='a long table', ... label='tab:long', column_format='lrl') @@ -578,9 +577,8 @@ def env_end(self) -> str: class RegularTableBuilder(GenericTableBuilder): """Concrete table builder for regular table. - >>> from pandas import DataFrame >>> from pandas.io.formats import format as fmt - >>> df = DataFrame({"a": [1, 2], "b": ["b1", "b2"]}) + >>> df = pd.DataFrame({"a": [1, 2], "b": ["b1", "b2"]}) >>> formatter = fmt.DataFrameFormatter(df) >>> builder = RegularTableBuilder(formatter, caption='caption', label='lab', ... column_format='lrc') @@ -625,9 +623,8 @@ def env_end(self) -> str: class TabularBuilder(GenericTableBuilder): """Concrete table builder for tabular environment. - >>> from pandas import DataFrame >>> from pandas.io.formats import format as fmt - >>> df = DataFrame({"a": [1, 2], "b": ["b1", "b2"]}) + >>> df = pd.DataFrame({"a": [1, 2], "b": ["b1", "b2"]}) >>> formatter = fmt.DataFrameFormatter(df) >>> builder = TabularBuilder(formatter, column_format='lrc') >>> table = builder.get_result() diff --git a/pandas/tseries/holiday.py b/pandas/tseries/holiday.py index 54ac116afe3cf..15de48c416476 100644 --- a/pandas/tseries/holiday.py +++ b/pandas/tseries/holiday.py @@ -197,7 +197,8 @@ class from pandas.tseries.offsets Holiday: July 3rd (month=7, day=3, ) >>> NewYears = Holiday( - ... "New Years Day", month=1, day=1, observance=nearest_workday + ... "New Years Day", month=1, day=1, + ... observance=nearest_workday ... ) >>> NewYears # doctest: +SKIP Holiday: New Years Day (