Skip to content

Test pytables refactor #28746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Oct 5, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b7450c7
added a conftest.py to pytables subdir
tolaa001 Oct 2, 2019
480184d
added common.py file to migrate the functions which all 3 test classe…
tolaa001 Oct 2, 2019
31d6836
moved TestTimezone class to test_timezones.py and relevant imports
tolaa001 Oct 2, 2019
e3242f4
moved HDFComplexvalues class to test_hdf_complex_values.py and releva…
tolaa001 Oct 2, 2019
1985c96
updated common.py, updated imports in test_hdf_complex_values and cre…
tolaa001 Oct 2, 2019
e93f3df
removed tables variable as not required for Timezone class
tolaa001 Oct 2, 2019
80d6aaf
cleaned up unused imports
tolaa001 Oct 2, 2019
7f0842b
updated import for ensure_clean_path to reference common.py instead
tolaa001 Oct 2, 2019
882ba8e
deleted test_pytables.py after splitting contents across 4 python files
tolaa001 Oct 2, 2019
54483fb
created test_hdf_store module to move class TestHDFStore
tolaa001 Oct 2, 2019
cd6a2c9
Ran black formatting
tolaa001 Oct 2, 2019
eb14b23
amended scope for setup_mode to module as the future state of test mo…
tolaa001 Oct 2, 2019
7b640fc
running isort to import in the right order
tolaa001 Oct 2, 2019
44c56f1
moving tables from common.py to the modules requiring this
tolaa001 Oct 2, 2019
595670e
renaming test files to make them sexier
tolaa001 Oct 2, 2019
515825a
copied pytest.importorskip to timezone
tolaa001 Oct 2, 2019
6106a24
removed test_timezone class and kept module functional
tolaa001 Oct 2, 2019
8f540a7
removed test_hdfcomplexvalues class and kept module functional
tolaa001 Oct 2, 2019
cfdd437
convert test_store back to class to make git diff easier for review
tolaa001 Oct 2, 2019
6375977
Merge remote-tracking branch 'upstream/master' into test_pytables_ref…
tolaa001 Oct 2, 2019
aa97d78
moved xfail_non_writeable into _test_decorators
tolaa001 Oct 2, 2019
9931352
removed numpy from safe import
tolaa001 Oct 2, 2019
27d62e4
importing numpy instead of using safe import
tolaa001 Oct 3, 2019
2e83dfd
Merge remote-tracking branch 'upstream/master' into test_pytables_ref…
tolaa001 Oct 3, 2019
eeac6ce
removing unused imports
tolaa001 Oct 3, 2019
78c710b
added tables to xfail decorator
tolaa001 Oct 3, 2019
a38bc5e
changed import for decorator
tolaa001 Oct 3, 2019
6d97676
reverted accidentally changes to test_operator.py
tolaa001 Oct 3, 2019
64ec41d
Merge remote-tracking branch 'upstream/master' into test_pytables_ref…
tolaa001 Oct 3, 2019
49e9d31
moved tables to common.py
tolaa001 Oct 4, 2019
e5cecce
fixed import
tolaa001 Oct 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pandas/tests/io/pytables/test_complex.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from distutils.version import LooseVersion
from warnings import catch_warnings

import numpy as np
import pytest

from pandas.util._test_decorators import xfail_non_writeable
import pandas.util._test_decorators as td

import pandas as pd
from pandas import DataFrame, Series
Expand Down Expand Up @@ -71,7 +70,7 @@ def test_complex_table(setup_path):
assert_frame_equal(df, reread)


@xfail_non_writeable
@td.xfail_non_writeable
def test_complex_mixed_fixed(setup_path):
complex64 = np.array(
[1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j], dtype=np.complex64
Expand Down
25 changes: 12 additions & 13 deletions pandas/tests/io/pytables/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from pandas.compat import PY36, is_platform_little_endian, is_platform_windows
import pandas.util._test_decorators as td
from pandas.util._test_decorators import xfail_non_writeable

from pandas.core.dtypes.common import is_categorical_dtype

Expand Down Expand Up @@ -812,7 +811,7 @@ def test_put_integer(self, setup_path):
df = DataFrame(np.random.randn(50, 100))
self._check_roundtrip(df, tm.assert_frame_equal, setup_path)

@xfail_non_writeable
@td.xfail_non_writeable
def test_put_mixed_type(self, setup_path):
df = tm.makeTimeDataFrame()
df["obj1"] = "foo"
Expand Down Expand Up @@ -1415,7 +1414,7 @@ def test_to_hdf_with_min_itemsize(self, setup_path):
)

@pytest.mark.parametrize(
"format", [pytest.param("fixed", marks=xfail_non_writeable), "table"]
"format", [pytest.param("fixed", marks=td.xfail_non_writeable), "table"]
)
def test_to_hdf_errors(self, format, setup_path):

Expand Down Expand Up @@ -1812,7 +1811,7 @@ def test_pass_spec_to_storer(self, setup_path):
with pytest.raises(TypeError):
store.select("df", where=[("columns=A")])

@xfail_non_writeable
@td.xfail_non_writeable
def test_append_misc(self, setup_path):

with ensure_clean_store(setup_path) as store:
Expand Down Expand Up @@ -2020,7 +2019,7 @@ def test_unimplemented_dtypes_table_columns(self, setup_path):
with pytest.raises(TypeError):
store.append("df_unimplemented", df)

@xfail_non_writeable
@td.xfail_non_writeable
@pytest.mark.skipif(
LooseVersion(np.__version__) == LooseVersion("1.15.0"),
reason=(
Expand Down Expand Up @@ -2255,7 +2254,7 @@ def test_float_index(self, setup_path):
s = Series(np.random.randn(10), index=index)
self._check_roundtrip(s, tm.assert_series_equal, path=setup_path)

@xfail_non_writeable
@td.xfail_non_writeable
def test_tuple_index(self, setup_path):

# GH #492
Expand All @@ -2268,7 +2267,7 @@ def test_tuple_index(self, setup_path):
simplefilter("ignore", pd.errors.PerformanceWarning)
self._check_roundtrip(DF, tm.assert_frame_equal, path=setup_path)

@xfail_non_writeable
@td.xfail_non_writeable
@pytest.mark.filterwarnings("ignore::pandas.errors.PerformanceWarning")
def test_index_types(self, setup_path):

Expand Down Expand Up @@ -2332,7 +2331,7 @@ def test_timeseries_preepoch(self, setup_path):
except OverflowError:
pytest.skip("known failer on some windows platforms")

@xfail_non_writeable
@td.xfail_non_writeable
@pytest.mark.parametrize(
"compression", [False, pytest.param(True, marks=td.skip_if_windows_python_3)]
)
Expand Down Expand Up @@ -2366,7 +2365,7 @@ def test_frame(self, compression, setup_path):
# empty
self._check_roundtrip(df[:0], tm.assert_frame_equal, path=setup_path)

@xfail_non_writeable
@td.xfail_non_writeable
def test_empty_series_frame(self, setup_path):
s0 = Series()
s1 = Series(name="myseries")
Expand All @@ -2380,7 +2379,7 @@ def test_empty_series_frame(self, setup_path):
self._check_roundtrip(df1, tm.assert_frame_equal, path=setup_path)
self._check_roundtrip(df2, tm.assert_frame_equal, path=setup_path)

@xfail_non_writeable
@td.xfail_non_writeable
@pytest.mark.parametrize(
"dtype", [np.int64, np.float64, np.object, "m8[ns]", "M8[ns]"]
)
Expand Down Expand Up @@ -2466,7 +2465,7 @@ def test_store_series_name(self, setup_path):
recons = store["series"]
tm.assert_series_equal(recons, series)

@xfail_non_writeable
@td.xfail_non_writeable
@pytest.mark.parametrize(
"compression", [False, pytest.param(True, marks=td.skip_if_windows_python_3)]
)
Expand Down Expand Up @@ -4024,7 +4023,7 @@ def test_pytables_native2_read(self, datapath, setup_path):
d1 = store["detector"]
assert isinstance(d1, DataFrame)

@xfail_non_writeable
@td.xfail_non_writeable
def test_legacy_table_fixed_format_read_py2(self, datapath, setup_path):
# GH 24510
# legacy table with fixed format written in Python 2
Expand Down Expand Up @@ -4183,7 +4182,7 @@ def test_unicode_longer_encoded(self, setup_path):
result = store.get("df")
tm.assert_frame_equal(result, df)

@xfail_non_writeable
@td.xfail_non_writeable
def test_store_datetime_mixed(self, setup_path):

df = DataFrame({"a": [1, 2, 3], "b": [1.0, 2.0, 3.0], "c": ["a", "b", "c"]})
Expand Down
33 changes: 18 additions & 15 deletions pandas/tests/series/test_operators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime, timedelta
import operator

import re
import numpy as np
import pytest

Expand Down Expand Up @@ -94,24 +94,25 @@ def test_logical_operators_int_dtype_with_int_scalar(self):
def test_logical_operators_int_dtype_with_float(self):
# GH#9016: support bitwise op for integer types
s_0123 = Series(range(4), dtype="int64")

with pytest.raises(TypeError):
msg = r"cannot compare a dtyped \[int64\] array with a scalar of type \[float\]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you changing things here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies, this shouldn't have been a change here as I was working on another branch working on the bare pytest_raises issue.

with pytest.raises(TypeError, match=msg):
s_0123 & np.NaN
with pytest.raises(TypeError):
msg = r"cannot compare a dtyped \[int64\] array with a scalar of type \[bool\]"
with pytest.raises(TypeError, match=msg):
s_0123 & 3.14
with pytest.raises(TypeError):
with pytest.raises(TypeError, match="unsupported.* 'int' and 'float'"):
s_0123 & [0.1, 4, 3.14, 2]
with pytest.raises(TypeError):
with pytest.raises(TypeError, match="unsupported.* 'int' and 'float'"):
s_0123 & np.array([0.1, 4, 3.14, 2])
with pytest.raises(TypeError):
with pytest.raises(TypeError, match="unsupported.* 'int' and 'float'"):
s_0123 & Series([0.1, 4, -3.14, 2])

def test_logical_operators_int_dtype_with_str(self):
s_1111 = Series([1] * 4, dtype="int8")

with pytest.raises(TypeError):
msg = r"cannot compare a dtyped \[int8\] array with a scalar of type \[bool\]"
with pytest.raises(TypeError, match=msg):
s_1111 & "a"
with pytest.raises(TypeError):
with pytest.raises(TypeError, match="unsupported.* 'int' and 'str'"):
s_1111 & ["a", "b", "c", "d"]

def test_logical_operators_int_dtype_with_bool(self):
Expand Down Expand Up @@ -228,8 +229,8 @@ def test_logical_operators_int_dtype_with_bool_dtype_and_reindex(self):

def test_scalar_na_logical_ops_corners(self):
s = Series([2, 3, 4, 5, 6, 7, 8, 9, 10])

with pytest.raises(TypeError):
msg = r"cannot compare a dtyped \[int64\] array with a scalar of type \[bool\]"
with pytest.raises(TypeError, match=msg):
s & datetime(2005, 1, 1)

s = Series([2, 3, 4, 5, 6, 7, 8, 9, datetime(2005, 1, 1)])
Expand All @@ -247,11 +248,13 @@ def test_scalar_na_logical_ops_corners(self):

# this is an alignment issue; these are equivalent
# https://github.com/pandas-dev/pandas/issues/5284

with pytest.raises(TypeError):
msg = (
r"cannot compare a dtyped \[float64\] array with a scalar of type \[float\]"
)
with pytest.raises(TypeError, match=msg):
d.__and__(s, axis="columns")

with pytest.raises(TypeError):
with pytest.raises(TypeError, match=msg):
s & d

# this is wrong as its not a boolean result
Expand Down
3 changes: 2 additions & 1 deletion pandas/util/_test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def safe_import(mod_name, min_version=None):
# and pytables 3.4.4
tables = safe_import("tables")
xfail_non_writeable = pytest.mark.xfail(
LooseVersion(np.__version__) >= LooseVersion("1.16")
tables
and LooseVersion(np.__version__) >= LooseVersion("1.16")
and LooseVersion(tables.__version__) < LooseVersion("3.5.1"),
reason=(
"gh-25511, gh-24839. pytables needs a "
Expand Down