From 2a2bb1468c941d8707130c8f1e63cc081aaa4aed Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Tue, 24 Sep 2019 16:37:35 +0200 Subject: [PATCH] ARROW-6674: [Python] Fix or ignore the test warnings --- python/pyarrow/tests/conftest.py | 18 +++++------------- python/pyarrow/tests/test_array.py | 12 ++++++------ python/pyarrow/tests/test_io.py | 2 +- python/pyarrow/tests/test_parquet.py | 6 ++---- python/pyarrow/tests/test_serialization.py | 2 ++ 5 files changed, 16 insertions(+), 24 deletions(-) diff --git a/python/pyarrow/tests/conftest.py b/python/pyarrow/tests/conftest.py index a095d81bcf70..bfb1e8e5d0b5 100644 --- a/python/pyarrow/tests/conftest.py +++ b/python/pyarrow/tests/conftest.py @@ -51,7 +51,9 @@ 'plasma', 's3', 'tensorflow', - 'flight' + 'flight', + 'slow', + 'requires_testing_data', ] @@ -70,6 +72,8 @@ 's3': False, 'tensorflow': False, 'flight': False, + 'slow': False, + 'requires_testing_data': True, } try: @@ -166,18 +170,6 @@ def bool_env(name, default=None): action='store_true', default=default, help=('Run only the {} test group'.format(group))) - parser.addoption('--runslow', action='store_true', - default=False, help='run slow tests') - - -def pytest_collection_modifyitems(config, items): - if not config.getoption('--runslow'): - skip_slow = pytest.mark.skip(reason='need --runslow option to run') - - for item in items: - if 'slow' in item.keywords: - item.add_marker(skip_slow) - def pytest_runtest_setup(item): only_set = False diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py index 91ca247aa279..7c75a2a830c4 100644 --- a/python/pyarrow/tests/test_array.py +++ b/python/pyarrow/tests/test_array.py @@ -152,15 +152,15 @@ def test_to_pandas_zero_copy(): arr = pa.array(range(10)) for i in range(10): - np_arr = arr.to_pandas() - assert sys.getrefcount(np_arr) == 2 - np_arr = None # noqa + series = arr.to_pandas() + assert sys.getrefcount(series) == 2 + series = None # noqa assert sys.getrefcount(arr) == 2 for i in range(10): arr = pa.array(range(10)) - np_arr = arr.to_pandas() + series = arr.to_pandas() arr = None gc.collect() @@ -168,9 +168,9 @@ def test_to_pandas_zero_copy(): # Because of py.test's assert inspection magic, if you put getrefcount # on the line being examined, it will be 1 higher than you expect - base_refcount = sys.getrefcount(np_arr.base) + base_refcount = sys.getrefcount(series.values.base) assert base_refcount == 2 - np_arr.sum() + series.sum() @pytest.mark.nopandas diff --git a/python/pyarrow/tests/test_io.py b/python/pyarrow/tests/test_io.py index 12fad99ba847..76148e7d8b2d 100644 --- a/python/pyarrow/tests/test_io.py +++ b/python/pyarrow/tests/test_io.py @@ -1191,7 +1191,7 @@ def test_compressed_recordbatch_stream(compression): else: raise writer = pa.RecordBatchStreamWriter(stream, table.schema) - writer.write_table(table, chunksize=3) + writer.write_table(table, max_chunksize=3) writer.close() stream.close() # Flush data buf = raw.getvalue() diff --git a/python/pyarrow/tests/test_parquet.py b/python/pyarrow/tests/test_parquet.py index f8a3563e25f9..6aeed0a1892d 100644 --- a/python/pyarrow/tests/test_parquet.py +++ b/python/pyarrow/tests/test_parquet.py @@ -2352,9 +2352,7 @@ def test_noncoerced_nanoseconds_written_without_exception(tempdir): # nanosecond timestamps by default n = 9 df = pd.DataFrame({'x': range(n)}, - index=pd.DatetimeIndex(start='2017-01-01', - freq='1n', - periods=n)) + index=pd.date_range('2017-01-01', freq='1n', periods=n)) tb = pa.Table.from_pandas(df) filename = tempdir / 'written.parquet' @@ -3025,7 +3023,7 @@ def test_write_nested_zero_length_array_chunk_failure(): # Each column is a ChunkedArray with 2 elements my_arrays = [pa.array(batch, type=pa.struct(cols)).flatten() for batch in data] - my_batches = [pa.RecordBatch.from_arrays(batch, pa.schema(cols)) + my_batches = [pa.RecordBatch.from_arrays(batch, schema=pa.schema(cols)) for batch in my_arrays] tbl = pa.Table.from_batches(my_batches, pa.schema(cols)) _check_roundtrip(tbl) diff --git a/python/pyarrow/tests/test_serialization.py b/python/pyarrow/tests/test_serialization.py index 1761b2e34838..5ba54d3277b5 100644 --- a/python/pyarrow/tests/test_serialization.py +++ b/python/pyarrow/tests/test_serialization.py @@ -520,6 +520,8 @@ def deserializer(data): assert np.alltrue(new_x.view(np.ndarray) == np.zeros(3)) +@pytest.mark.filterwarnings( + "ignore:the matrix subclass:PendingDeprecationWarning") def test_numpy_matrix_serialization(tmpdir): class CustomType(object): def __init__(self, val):