diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index c2d1eb8ae1372..06e645563d51c 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -28,6 +28,7 @@ import pandas.core.computation.expr as expr import pandas.util.testing as tm +import pandas.util._test_decorators as td from pandas.util.testing import (assert_frame_equal, randbool, assert_numpy_array_equal, assert_series_equal, assert_produces_warning) @@ -175,9 +176,8 @@ def test_floor_division(self): for lhs, rhs in product(self.lhses, self.rhses): self.check_floor_division(lhs, '//', rhs) + @td.skip_if_windows def test_pow(self): - tm._skip_if_windows() - # odd failure on win32 platform, so skip for lhs, rhs in product(self.lhses, self.rhses): self.check_pow(lhs, '**', rhs) diff --git a/pandas/tests/indexes/datetimes/test_date_range.py b/pandas/tests/indexes/datetimes/test_date_range.py index 826e20b8b0586..3ce51983c111d 100644 --- a/pandas/tests/indexes/datetimes/test_date_range.py +++ b/pandas/tests/indexes/datetimes/test_date_range.py @@ -11,6 +11,7 @@ import pandas as pd import pandas.util.testing as tm +import pandas.util._test_decorators as td from pandas import compat from pandas import date_range, bdate_range, offsets, DatetimeIndex, Timestamp from pandas.tseries.offsets import (generate_range, CDay, BDay, DateOffset, @@ -49,8 +50,8 @@ def test_date_range_timestamp_equiv_explicit_pytz(self): ts = Timestamp('20090415', tz=pytz.timezone('US/Eastern'), freq='D') assert ts == stamp + @td.skip_if_windows_python_3 def test_date_range_timestamp_equiv_explicit_dateutil(self): - tm._skip_if_windows_python_3() from pandas._libs.tslibs.timezones import dateutil_gettz as gettz rng = date_range('20090415', '20090519', tz=gettz('US/Eastern')) diff --git a/pandas/tests/indexes/datetimes/test_setops.py b/pandas/tests/indexes/datetimes/test_setops.py index 5df75338d01d7..b74da4922429d 100644 --- a/pandas/tests/indexes/datetimes/test_setops.py +++ b/pandas/tests/indexes/datetimes/test_setops.py @@ -5,6 +5,7 @@ import pandas as pd import pandas.util.testing as tm +import pandas.util._test_decorators as td from pandas import (DatetimeIndex, date_range, Series, bdate_range, DataFrame, Int64Index, Index, to_datetime) from pandas.tseries.offsets import Minute, BMonthEnd, MonthEnd @@ -358,9 +359,8 @@ def test_month_range_union_tz_pytz(self): early_dr.union(late_dr) + @td.skip_if_windows_python_3 def test_month_range_union_tz_dateutil(self): - tm._skip_if_windows_python_3() - from pandas._libs.tslibs.timezones import dateutil_gettz tz = dateutil_gettz('US/Eastern') diff --git a/pandas/tests/indexes/period/test_period.py b/pandas/tests/indexes/period/test_period.py index 48378233dd638..599f6efd16f74 100644 --- a/pandas/tests/indexes/period/test_period.py +++ b/pandas/tests/indexes/period/test_period.py @@ -3,10 +3,11 @@ import numpy as np import pandas as pd +import pandas.util._test_decorators as td from pandas.util import testing as tm from pandas import (PeriodIndex, period_range, notna, DatetimeIndex, NaT, Index, Period, Int64Index, Series, DataFrame, date_range, - offsets, compat) + offsets) from ..datetimelike import DatetimeLike @@ -544,9 +545,8 @@ def test_shift_nat(self): tm.assert_index_equal(result, expected) assert result.name == expected.name + @td.skip_if_32bit def test_ndarray_compat_properties(self): - if compat.is_platform_32bit(): - pytest.skip("skipping on 32bit") super(TestPeriodIndex, self).test_ndarray_compat_properties() def test_shift_ndarray(self): diff --git a/pandas/tests/io/parser/c_parser_only.py b/pandas/tests/io/parser/c_parser_only.py index 6d476e326213e..7a1fca55dd51e 100644 --- a/pandas/tests/io/parser/c_parser_only.py +++ b/pandas/tests/io/parser/c_parser_only.py @@ -16,6 +16,7 @@ import pandas as pd import pandas.util.testing as tm +import pandas.util._test_decorators as td from pandas import DataFrame from pandas import compat from pandas.compat import StringIO, range, lrange @@ -129,9 +130,8 @@ def test_unsupported_dtype(self): dtype={'A': 'U8'}, index_col=0) + @td.skip_if_32bit def test_precise_conversion(self): - # see gh-8002 - tm._skip_if_32bit() from decimal import Decimal normal_errors = [] diff --git a/pandas/tests/io/test_pytables.py b/pandas/tests/io/test_pytables.py index 85f24e794f12a..6df31b73da9b7 100644 --- a/pandas/tests/io/test_pytables.py +++ b/pandas/tests/io/test_pytables.py @@ -17,6 +17,7 @@ isna, compat, concat, Timestamp) import pandas.util.testing as tm +import pandas.util._test_decorators as td from pandas.util.testing import (assert_panel4d_equal, assert_panel_equal, assert_frame_equal, @@ -24,7 +25,7 @@ set_timezone) from pandas.compat import (is_platform_windows, is_platform_little_endian, - PY3, PY35, PY36, BytesIO, text_type, + PY35, PY36, BytesIO, text_type, range, lrange, u) from pandas.io.formats.printing import pprint_thing from pandas.core.dtypes.common import is_categorical_dtype @@ -40,10 +41,6 @@ LooseVersion('2.2') else 'zlib') -# testing on windows/py3 seems to fault -# for using compression -skip_compression = PY3 and is_platform_windows() - # contextmanager to ensure the file cleanup @@ -719,12 +716,10 @@ def test_put_compression(self): pytest.raises(ValueError, store.put, 'b', df, format='fixed', complib='zlib') + @td.skip_if_windows_python_3 def test_put_compression_blosc(self): tm.skip_if_no_package('tables', min_version='2.2', app='blosc support') - if skip_compression: - pytest.skip("skipping on windows/PY3") - df = tm.makeTimeDataFrame() with ensure_clean_store(self.path) as store: @@ -2892,7 +2887,10 @@ def test_timeseries_preepoch(self): except OverflowError: pytest.skip('known failer on some windows platforms') - def test_frame(self): + @pytest.mark.parametrize("compression", [ + False, pytest.param(True, marks=td.skip_if_windows_python_3) + ]) + def test_frame(self, compression): df = tm.makeDataFrame() @@ -2900,21 +2898,14 @@ def test_frame(self): df.values[0, 0] = np.nan df.values[5, 3] = np.nan - self._check_roundtrip_table(df, tm.assert_frame_equal) - self._check_roundtrip(df, tm.assert_frame_equal) - - if not skip_compression: - self._check_roundtrip_table(df, tm.assert_frame_equal, - compression=True) - self._check_roundtrip(df, tm.assert_frame_equal, - compression=True) + self._check_roundtrip_table(df, tm.assert_frame_equal, + compression=compression) + self._check_roundtrip(df, tm.assert_frame_equal, + compression=compression) tdf = tm.makeTimeDataFrame() - self._check_roundtrip(tdf, tm.assert_frame_equal) - - if not skip_compression: - self._check_roundtrip(tdf, tm.assert_frame_equal, - compression=True) + self._check_roundtrip(tdf, tm.assert_frame_equal, + compression=compression) with ensure_clean_store(self.path) as store: # not consolidated @@ -3021,7 +3012,10 @@ def test_store_series_name(self): recons = store['series'] tm.assert_series_equal(recons, series) - def test_store_mixed(self): + @pytest.mark.parametrize("compression", [ + False, pytest.param(True, marks=td.skip_if_windows_python_3) + ]) + def test_store_mixed(self, compression): def _make_one(): df = tm.makeDataFrame() @@ -3046,19 +3040,12 @@ def _make_one(): tm.assert_frame_equal(store['obj'], df2) # check that can store Series of all of these types - self._check_roundtrip(df1['obj1'], tm.assert_series_equal) - self._check_roundtrip(df1['bool1'], tm.assert_series_equal) - self._check_roundtrip(df1['int1'], tm.assert_series_equal) - - if not skip_compression: - self._check_roundtrip(df1['obj1'], tm.assert_series_equal, - compression=True) - self._check_roundtrip(df1['bool1'], tm.assert_series_equal, - compression=True) - self._check_roundtrip(df1['int1'], tm.assert_series_equal, - compression=True) - self._check_roundtrip(df1, tm.assert_frame_equal, - compression=True) + self._check_roundtrip(df1['obj1'], tm.assert_series_equal, + compression=compression) + self._check_roundtrip(df1['bool1'], tm.assert_series_equal, + compression=compression) + self._check_roundtrip(df1['int1'], tm.assert_series_equal, + compression=compression) def test_wide(self): @@ -5639,6 +5626,7 @@ def test_fixed_offset_tz(self): tm.assert_index_equal(recons.index, rng) assert rng.tz == recons.index.tz + @td.skip_if_windows def test_store_timezone(self): # GH2852 # issue storing datetime.date with a timezone as it resets when read diff --git a/pandas/tests/scalar/test_timestamp.py b/pandas/tests/scalar/test_timestamp.py index 80421dcd462d4..9c649a42fb8ee 100644 --- a/pandas/tests/scalar/test_timestamp.py +++ b/pandas/tests/scalar/test_timestamp.py @@ -15,6 +15,7 @@ from pytz.exceptions import AmbiguousTimeError, NonExistentTimeError import pandas.util.testing as tm +import pandas.util._test_decorators as td from pandas.tseries import offsets, frequencies from pandas._libs.tslibs.timezones import get_timezone, dateutil_gettz as gettz from pandas._libs.tslibs import conversion, period @@ -943,6 +944,7 @@ def test_is_leap_year(self, tz): dt = Timestamp('2100-01-01 00:00:00', tz=tz) assert not dt.is_leap_year + @td.skip_if_windows def test_timestamp(self): # GH#17329 # tz-naive --> treat it as if it were UTC for purposes of timestamp() @@ -1366,9 +1368,8 @@ def test_timestamp_to_datetime_explicit_pytz(self): assert stamp == dtval assert stamp.tzinfo == dtval.tzinfo + @td.skip_if_windows_python_3 def test_timestamp_to_datetime_explicit_dateutil(self): - tm._skip_if_windows_python_3() - stamp = Timestamp('20090415', tz=gettz('US/Eastern'), freq='D') dtval = stamp.to_pydatetime() assert stamp == dtval diff --git a/pandas/tests/sparse/test_libsparse.py b/pandas/tests/sparse/test_libsparse.py index 4842ebdd103c4..7719ea46503fd 100644 --- a/pandas/tests/sparse/test_libsparse.py +++ b/pandas/tests/sparse/test_libsparse.py @@ -4,8 +4,7 @@ import numpy as np import operator import pandas.util.testing as tm - -from pandas import compat +import pandas.util._test_decorators as td from pandas.core.sparse.array import IntIndex, BlockIndex, _make_index import pandas._libs.sparse as splib @@ -190,6 +189,7 @@ def test_intindex_make_union(self): class TestSparseIndexIntersect(object): + @td.skip_if_windows def test_intersect(self): def _check_correct(a, b, expected): result = a.intersect(b) @@ -212,8 +212,6 @@ def _check_case(xloc, xlen, yloc, ylen, eloc, elen): _check_length_exc(xindex.to_int_index(), longer_index.to_int_index()) - if compat.is_platform_windows(): - pytest.skip("segfaults on win-64 when all tests are run") check_cases(_check_case) def test_intersect_empty(self): diff --git a/pandas/tests/tseries/test_timezones.py b/pandas/tests/tseries/test_timezones.py index af26ddb554752..9530cd5ac3f43 100644 --- a/pandas/tests/tseries/test_timezones.py +++ b/pandas/tests/tseries/test_timezones.py @@ -12,6 +12,7 @@ from datetime import datetime, timedelta, tzinfo, date import pandas.util.testing as tm +import pandas.util._test_decorators as td import pandas.tseries.offsets as offsets from pandas.compat import lrange, zip, PY3 from pandas.core.indexes.datetimes import bdate_range, date_range @@ -958,10 +959,8 @@ def cmptz(self, tz1, tz2): def localize(self, tz, x): return x.replace(tzinfo=tz) + @td.skip_if_windows def test_utc_with_system_utc(self): - # Skipped on win32 due to dateutil bug - tm._skip_if_windows() - from pandas._libs.tslibs.timezones import maybe_get_tz # from system utc to real utc @@ -1270,6 +1269,7 @@ def test_ambiguous_compat(self): assert (result_pytz.to_pydatetime().tzname() == result_dateutil.to_pydatetime().tzname()) + @td.skip_if_windows def test_replace_tzinfo(self): # GH 15683 dt = datetime(2016, 3, 27, 1) @@ -1663,6 +1663,7 @@ def test_normalize_tz(self): assert result.is_normalized assert not rng.is_normalized + @td.skip_if_windows def test_normalize_tz_local(self): # see gh-13459 timezones = ['US/Pacific', 'US/Eastern', 'UTC', 'Asia/Kolkata', diff --git a/pandas/tests/util/test_testing.py b/pandas/tests/util/test_testing.py index fe7c3b99987f5..31580bc9eab57 100644 --- a/pandas/tests/util/test_testing.py +++ b/pandas/tests/util/test_testing.py @@ -5,11 +5,11 @@ import sys from pandas import Series, DataFrame import pandas.util.testing as tm +import pandas.util._test_decorators as td from pandas.util.testing import (assert_almost_equal, raise_with_traceback, assert_index_equal, assert_series_equal, assert_frame_equal, assert_numpy_array_equal, RNGContext) -from pandas.compat import is_platform_windows class TestAssertAlmostEqual(object): @@ -159,12 +159,9 @@ def test_raise_with_traceback(self): class TestAssertNumpyArrayEqual(object): + @td.skip_if_windows def test_numpy_array_equal_message(self): - if is_platform_windows(): - pytest.skip("windows has incomparable line-endings " - "and uses L on the shape") - expected = """numpy array are different numpy array shapes are different @@ -287,12 +284,9 @@ def test_numpy_array_equal_message(self): assert_almost_equal(np.array([1, 2]), np.array([3, 4, 5]), obj='Index') + @td.skip_if_windows def test_numpy_array_equal_object_message(self): - if is_platform_windows(): - pytest.skip("windows has incomparable line-endings " - "and uses L on the shape") - a = np.array([pd.Timestamp('2011-01-01'), pd.Timestamp('2011-01-01')]) b = np.array([pd.Timestamp('2011-01-01'), pd.Timestamp('2011-01-02')]) diff --git a/pandas/tests/util/test_util.py b/pandas/tests/util/test_util.py index be4e60c6493c8..8da2b401fc848 100644 --- a/pandas/tests/util/test_util.py +++ b/pandas/tests/util/test_util.py @@ -16,7 +16,7 @@ validate_bool_kwarg) import pandas.util.testing as tm -from pandas.util._test_decorators import safe_import +import pandas.util._test_decorators as td class TestDecorators(object): @@ -406,6 +406,7 @@ def test_numpy_errstate_is_default(): assert np.geterr() == expected +@td.skip_if_windows class TestLocaleUtils(object): @classmethod @@ -416,8 +417,6 @@ def setup_class(cls): if not cls.locales: pytest.skip("No locales found") - tm._skip_if_windows() - @classmethod def teardown_class(cls): del cls.locales @@ -486,8 +485,8 @@ def test_make_signature(): def test_safe_import(monkeypatch): - assert not safe_import("foo") - assert not safe_import("pandas", min_version="99.99.99") + assert not td.safe_import("foo") + assert not td.safe_import("pandas", min_version="99.99.99") # Create dummy module to be imported import types @@ -496,7 +495,7 @@ def test_safe_import(monkeypatch): mod = types.ModuleType(mod_name) mod.__version__ = "1.5" - assert not safe_import(mod_name) + assert not td.safe_import(mod_name) monkeypatch.setitem(sys.modules, mod_name, mod) - assert not safe_import(mod_name, min_version="2.0") - assert safe_import(mod_name, min_version="1.0") + assert not td.safe_import(mod_name, min_version="2.0") + assert td.safe_import(mod_name, min_version="1.0") diff --git a/pandas/util/_test_decorators.py b/pandas/util/_test_decorators.py index ab37c71404ad9..6d15f360bcbe8 100644 --- a/pandas/util/_test_decorators.py +++ b/pandas/util/_test_decorators.py @@ -27,6 +27,8 @@ def test_foo(): import pytest from distutils.version import LooseVersion +from pandas.compat import is_platform_windows, is_platform_32bit, PY3 + def safe_import(mod_name, min_version=None): """ @@ -83,3 +85,10 @@ def _skip_if_mpl_1_5(): reason="Missing matplotlib dependency") skip_if_mpl_1_5 = pytest.mark.skipif(_skip_if_mpl_1_5(), reason="matplotlib 1.5") +skip_if_32bit = pytest.mark.skipif(is_platform_32bit(), + reason="skipping for 32 bit") +skip_if_windows = pytest.mark.skipif(is_platform_windows(), + reason="Running on Windows") +skip_if_windows_python_3 = pytest.mark.skipif(is_platform_windows() and PY3, + reason=("not used on python3/" + "win32")) diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 60b95b931b993..81f84ea646c86 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -38,9 +38,7 @@ import pandas.compat as compat from pandas.compat import ( filter, map, zip, range, unichr, lrange, lmap, lzip, u, callable, Counter, - raise_with_traceback, httplib, is_platform_windows, is_platform_32bit, - StringIO, PY3 -) + raise_with_traceback, httplib, StringIO, PY3) from pandas import (bdate_range, CategoricalIndex, Categorical, IntervalIndex, DatetimeIndex, TimedeltaIndex, PeriodIndex, RangeIndex, @@ -319,12 +317,6 @@ def close(fignum=None): _close(fignum) -def _skip_if_32bit(): - if is_platform_32bit(): - import pytest - pytest.skip("skipping for 32 bit") - - def _skip_if_mpl_1_5(): import matplotlib as mpl @@ -367,18 +359,6 @@ def _skip_if_no_xarray(): pytest.skip("xarray version is too low: {version}".format(version=v)) -def _skip_if_windows_python_3(): - if PY3 and is_platform_windows(): - import pytest - pytest.skip("not used on python 3/win32") - - -def _skip_if_windows(): - if is_platform_windows(): - import pytest - pytest.skip("Running on Windows") - - def _skip_if_no_pathlib(): try: from pathlib import Path # noqa @@ -2825,9 +2805,6 @@ def set_timezone(tz): ... 'EDT' """ - if is_platform_windows(): - import pytest - pytest.skip("timezone setting not supported on windows") import os import time