From 2a2d21a14a78e028e8e9a9c3bbf815ea76501036 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 4 Jan 2020 17:26:13 +0000 Subject: [PATCH 1/7] Fix pytest junit_family warnings --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 192ba9bc407b1..8b935540fc7b9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,6 +66,7 @@ xfail_strict = True filterwarnings = error:Sparse:FutureWarning error:The SparseArray:FutureWarning +junit_family=xunit2 [coverage:run] branch = False From 27c0e0aecdcf8182a161eaa6c6857b5fecf40fac Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 4 Jan 2020 18:16:23 +0000 Subject: [PATCH 2/7] Add async marks + async/await --- ci/deps/azure-36-locale.yaml | 1 + ci/deps/azure-37-locale.yaml | 1 + environment.yml | 1 + pandas/conftest.py | 11 +++++++++++ pandas/tests/arrays/categorical/test_warnings.py | 6 ++++-- pandas/tests/frame/test_api.py | 6 ++++-- pandas/tests/indexes/test_base.py | 6 ++++-- pandas/tests/series/test_api.py | 6 ++++-- requirements-dev.txt | 1 + 9 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ci/deps/azure-36-locale.yaml b/ci/deps/azure-36-locale.yaml index 4f4c4524cb4dd..c6940f9327e0d 100644 --- a/ci/deps/azure-36-locale.yaml +++ b/ci/deps/azure-36-locale.yaml @@ -9,6 +9,7 @@ dependencies: - cython>=0.29.13 - pytest>=5.0.1 - pytest-xdist>=1.21 + - pytest-asyncio - hypothesis>=3.58.0 - pytest-azurepipelines diff --git a/ci/deps/azure-37-locale.yaml b/ci/deps/azure-37-locale.yaml index a10fa0904a451..111ba6b020bc7 100644 --- a/ci/deps/azure-37-locale.yaml +++ b/ci/deps/azure-37-locale.yaml @@ -8,6 +8,7 @@ dependencies: - cython>=0.29.13 - pytest>=5.0.1 - pytest-xdist>=1.21 + - pytest-asyncio - hypothesis>=3.58.0 - pytest-azurepipelines diff --git a/environment.yml b/environment.yml index 46fb5e7a19078..07028ab26dc83 100644 --- a/environment.yml +++ b/environment.yml @@ -55,6 +55,7 @@ dependencies: - pytest>=5.0.1 - pytest-cov - pytest-xdist>=1.21 + - pytest-asyncio # downstream tests - seaborn diff --git a/pandas/conftest.py b/pandas/conftest.py index 3eab2186ccb94..36dc2969a38ca 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -11,6 +11,7 @@ import pytest from pytz import FixedOffset, utc +from pandas.compat._optional import import_optional_dependency import pandas.util._test_decorators as td import pandas as pd @@ -930,3 +931,13 @@ def __len__(self): return self._data.__len__() return TestNonDictMapping + + +def async_mark(): + try: + import_optional_dependency("pytest_asyncio") + async_mark = pytest.mark.asyncio + except ImportError: + async_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio") + + return async_mark diff --git a/pandas/tests/arrays/categorical/test_warnings.py b/pandas/tests/arrays/categorical/test_warnings.py index 1ee877cbbf348..d876ffcbd43fb 100644 --- a/pandas/tests/arrays/categorical/test_warnings.py +++ b/pandas/tests/arrays/categorical/test_warnings.py @@ -1,16 +1,18 @@ import pytest import pandas._testing as tm +from pandas.conftest import async_mark class TestCategoricalWarnings: - def test_tab_complete_warning(self, ip): + @async_mark() + async def test_tab_complete_warning(self, ip): # https://github.com/pandas-dev/pandas/issues/16409 pytest.importorskip("IPython", minversion="6.0.0") from IPython.core.completer import provisionalcompleter code = "import pandas as pd; c = Categorical([])" - ip.run_code(code) + await ip.run_code(code) with tm.assert_produces_warning(None): with provisionalcompleter("ignore"): list(ip.Completer.completions("c.", 1)) diff --git a/pandas/tests/frame/test_api.py b/pandas/tests/frame/test_api.py index 8093b602dd6f3..40cde2eefc2f3 100644 --- a/pandas/tests/frame/test_api.py +++ b/pandas/tests/frame/test_api.py @@ -10,6 +10,7 @@ import pandas as pd from pandas import Categorical, DataFrame, Series, compat, date_range, timedelta_range import pandas._testing as tm +from pandas.conftest import async_mark class TestDataFrameMisc: @@ -539,13 +540,14 @@ def _check_f(base, f): f = lambda x: x.rename({1: "foo"}, inplace=True) _check_f(d.copy(), f) - def test_tab_complete_warning(self, ip): + @async_mark() + async def test_tab_complete_warning(self, ip): # GH 16409 pytest.importorskip("IPython", minversion="6.0.0") from IPython.core.completer import provisionalcompleter code = "import pandas as pd; df = pd.DataFrame()" - ip.run_code(code) + await ip.run_code(code) with tm.assert_produces_warning(None): with provisionalcompleter("ignore"): list(ip.Completer.completions("df.", 1)) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 4a773cc1c6f49..497bc747d591b 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -33,6 +33,7 @@ period_range, ) import pandas._testing as tm +from pandas.conftest import async_mark from pandas.core.algorithms import safe_sort from pandas.core.indexes.api import ( Index, @@ -2397,13 +2398,14 @@ def test_cached_properties_not_settable(self): with pytest.raises(AttributeError, match="Can't set attribute"): index.is_unique = False - def test_tab_complete_warning(self, ip): + @async_mark() + async def test_tab_complete_warning(self, ip): # https://github.com/pandas-dev/pandas/issues/16409 pytest.importorskip("IPython", minversion="6.0.0") from IPython.core.completer import provisionalcompleter code = "import pandas as pd; idx = pd.Index([1, 2])" - ip.run_code(code) + await ip.run_code(code) with tm.assert_produces_warning(None): with provisionalcompleter("ignore"): list(ip.Completer.completions("idx.", 4)) diff --git a/pandas/tests/series/test_api.py b/pandas/tests/series/test_api.py index 32587c6afee73..ddc38ab37d86b 100644 --- a/pandas/tests/series/test_api.py +++ b/pandas/tests/series/test_api.py @@ -20,6 +20,7 @@ timedelta_range, ) import pandas._testing as tm +from pandas.conftest import async_mark from pandas.core.arrays import PeriodArray import pandas.io.formats.printing as printing @@ -491,13 +492,14 @@ def test_empty_method(self): for full_series in [pd.Series([1]), s2]: assert not full_series.empty - def test_tab_complete_warning(self, ip): + @async_mark() + async def test_tab_complete_warning(self, ip): # https://github.com/pandas-dev/pandas/issues/16409 pytest.importorskip("IPython", minversion="6.0.0") from IPython.core.completer import provisionalcompleter code = "import pandas as pd; s = pd.Series()" - ip.run_code(code) + await ip.run_code(code) with tm.assert_produces_warning(None): with provisionalcompleter("ignore"): list(ip.Completer.completions("s.", 1)) diff --git a/requirements-dev.txt b/requirements-dev.txt index 9f18bf767ae56..6bbf0ebfb947f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -36,6 +36,7 @@ moto pytest>=5.0.1 pytest-cov pytest-xdist>=1.21 +pytest-asyncio seaborn statsmodels ipywidgets From d9bcb4fec855d324773e174cbf738893870d84bc Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 4 Jan 2020 18:18:01 +0000 Subject: [PATCH 3/7] Add async marks + async/await --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 8b935540fc7b9..192ba9bc407b1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,7 +66,6 @@ xfail_strict = True filterwarnings = error:Sparse:FutureWarning error:The SparseArray:FutureWarning -junit_family=xunit2 [coverage:run] branch = False From aa28b7c7580774cfff63b15aa8c290e167f21c77 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 4 Jan 2020 18:26:56 +0000 Subject: [PATCH 4/7] Move to _test_decorators --- pandas/conftest.py | 10 ---------- pandas/util/_test_decorators.py | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index 36dc2969a38ca..57505ce3879b1 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -931,13 +931,3 @@ def __len__(self): return self._data.__len__() return TestNonDictMapping - - -def async_mark(): - try: - import_optional_dependency("pytest_asyncio") - async_mark = pytest.mark.asyncio - except ImportError: - async_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio") - - return async_mark diff --git a/pandas/util/_test_decorators.py b/pandas/util/_test_decorators.py index a280da6e239b2..d8804994af426 100644 --- a/pandas/util/_test_decorators.py +++ b/pandas/util/_test_decorators.py @@ -32,6 +32,7 @@ def test_foo(): import pytest from pandas.compat import is_platform_32bit, is_platform_windows +from pandas.compat._optional import import_optional_dependency from pandas.compat.numpy import _np_version from pandas.core.computation.expressions import _NUMEXPR_INSTALLED, _USE_NUMEXPR @@ -251,3 +252,13 @@ def new_func(*args, **kwargs): assert flist2 == flist return new_func + + +def async_mark(): + try: + import_optional_dependency("pytest_asyncio") + async_mark = pytest.mark.asyncio + except ImportError: + async_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio") + + return async_mark From 6bc770ad2a9ac03faf373ca989c6581be8a3feb8 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 4 Jan 2020 18:30:14 +0000 Subject: [PATCH 5/7] Move to _test_decorators --- pandas/tests/arrays/categorical/test_warnings.py | 3 ++- pandas/tests/frame/test_api.py | 2 +- pandas/tests/indexes/test_base.py | 2 +- pandas/tests/series/test_api.py | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandas/tests/arrays/categorical/test_warnings.py b/pandas/tests/arrays/categorical/test_warnings.py index d876ffcbd43fb..f66c327e9967d 100644 --- a/pandas/tests/arrays/categorical/test_warnings.py +++ b/pandas/tests/arrays/categorical/test_warnings.py @@ -1,7 +1,8 @@ import pytest +from pandas.util._test_decorators import async_mark + import pandas._testing as tm -from pandas.conftest import async_mark class TestCategoricalWarnings: diff --git a/pandas/tests/frame/test_api.py b/pandas/tests/frame/test_api.py index 40cde2eefc2f3..26d6a917fe1ca 100644 --- a/pandas/tests/frame/test_api.py +++ b/pandas/tests/frame/test_api.py @@ -6,11 +6,11 @@ import pytest from pandas.compat import PY37 +from pandas.util._test_decorators import async_mark import pandas as pd from pandas import Categorical, DataFrame, Series, compat, date_range, timedelta_range import pandas._testing as tm -from pandas.conftest import async_mark class TestDataFrameMisc: diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 497bc747d591b..c1ab5a9dbe3eb 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -12,6 +12,7 @@ from pandas._libs.tslib import Timestamp from pandas.compat.numpy import np_datetime64_compat +from pandas.util._test_decorators import async_mark from pandas.core.dtypes.common import is_unsigned_integer_dtype from pandas.core.dtypes.generic import ABCIndex @@ -33,7 +34,6 @@ period_range, ) import pandas._testing as tm -from pandas.conftest import async_mark from pandas.core.algorithms import safe_sort from pandas.core.indexes.api import ( Index, diff --git a/pandas/tests/series/test_api.py b/pandas/tests/series/test_api.py index ddc38ab37d86b..d235e51d00793 100644 --- a/pandas/tests/series/test_api.py +++ b/pandas/tests/series/test_api.py @@ -5,6 +5,8 @@ import numpy as np import pytest +from pandas.util._test_decorators import async_mark + import pandas as pd from pandas import ( Categorical, @@ -20,7 +22,6 @@ timedelta_range, ) import pandas._testing as tm -from pandas.conftest import async_mark from pandas.core.arrays import PeriodArray import pandas.io.formats.printing as printing From 9551ea46aef1e70b6ffba17d20d7271179b17531 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 4 Jan 2020 18:36:22 +0000 Subject: [PATCH 6/7] Move to _test_decorators --- pandas/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index 57505ce3879b1..3eab2186ccb94 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -11,7 +11,6 @@ import pytest from pytz import FixedOffset, utc -from pandas.compat._optional import import_optional_dependency import pandas.util._test_decorators as td import pandas as pd From 829b658bc628607e945b3f7bf002e6276e83e3b4 Mon Sep 17 00:00:00 2001 From: alimcmaster1 Date: Sat, 4 Jan 2020 19:23:05 +0000 Subject: [PATCH 7/7] Add async marker --- pandas/tests/resample/test_resampler_grouper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pandas/tests/resample/test_resampler_grouper.py b/pandas/tests/resample/test_resampler_grouper.py index 95a7654a618b2..4e3585c0be884 100644 --- a/pandas/tests/resample/test_resampler_grouper.py +++ b/pandas/tests/resample/test_resampler_grouper.py @@ -2,6 +2,8 @@ import numpy as np +from pandas.util._test_decorators import async_mark + import pandas as pd from pandas import DataFrame, Series, Timestamp import pandas._testing as tm @@ -13,7 +15,8 @@ ) -def test_tab_complete_ipython6_warning(ip): +@async_mark() +async def test_tab_complete_ipython6_warning(ip): from IPython.core.completer import provisionalcompleter code = dedent( @@ -23,7 +26,7 @@ def test_tab_complete_ipython6_warning(ip): rs = s.resample("D") """ ) - ip.run_code(code) + await ip.run_code(code) with tm.assert_produces_warning(None): with provisionalcompleter("ignore"):