Skip to content

Commit

Permalink
GH-39849: [Python] Remove the use of pytest-lazy-fixture (#39850)
Browse files Browse the repository at this point in the history
### Rationale for this change

Removing the use of `pytest-lazy-fixture` in our test suite as it is unmaintained.
Changes in this PR include:

- Remove the use of `pytest-lazy-fixture`
- Remove marks from fixtures to avoid future error, see
   ```
   PytestRemovedIn9Warning: Marks applied to fixtures have no effect
     See docs: https://docs.pytest.org/en/stable/deprecations.html#applying-a-mark-to-a-fixture-function
   ```
- Catch two different warnings in `def test_legacy_int_type()`

### Are these changes tested?

The changes affect the tests so they must pass.

### Are there any user-facing changes?

No.
* Closes: #39849

Lead-authored-by: AlenkaF <[email protected]>
Co-authored-by: Joris Van den Bossche <[email protected]>
Signed-off-by: Joris Van den Bossche <[email protected]>
  • Loading branch information
AlenkaF and jorisvandenbossche authored Feb 1, 2024
1 parent 2721134 commit 44d5597
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 36 deletions.
3 changes: 1 addition & 2 deletions ci/conda_env_python.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ cloudpickle
fsspec
hypothesis
numpy>=1.16.6
pytest<8 # pytest-lazy-fixture broken on pytest 8.0.0
pytest<8
pytest-faulthandler
pytest-lazy-fixture
s3fs>=2023.10.0
setuptools
setuptools_scm<8.0.0
1 change: 0 additions & 1 deletion dev/tasks/conda-recipes/arrow-cpp/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ outputs:
# test_cpp_extension_in_python requires a compiler
- {{ compiler("cxx") }} # [linux]
- pytest
- pytest-lazy-fixture
- backports.zoneinfo # [py<39]
- boto3
- cffi
Expand Down
7 changes: 3 additions & 4 deletions python/pyarrow/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import urllib.request

import pytest
from pytest_lazyfixture import lazy_fixture
import hypothesis as h
from ..conftest import groups, defaults

Expand Down Expand Up @@ -259,13 +258,13 @@ def gcs_server():

@pytest.fixture(
params=[
lazy_fixture('builtin_pickle'),
lazy_fixture('cloudpickle')
'builtin_pickle',
'cloudpickle'
],
scope='session'
)
def pickle_module(request):
return request.param
return request.getfixturevalue(request.param)


@pytest.fixture(scope='session')
Expand Down
3 changes: 0 additions & 3 deletions python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def assert_dataset_fragment_convenience_methods(dataset):


@pytest.fixture
@pytest.mark.parquet
def mockfs():
mockfs = fs._MockFileSystem()

Expand Down Expand Up @@ -221,7 +220,6 @@ def multisourcefs(request):


@pytest.fixture
@pytest.mark.parquet
def dataset(mockfs):
format = ds.ParquetFileFormat()
selector = fs.FileSelector('subdir', recursive=True)
Expand Down Expand Up @@ -2692,7 +2690,6 @@ def test_dataset_partitioned_dictionary_type_reconstruct(tempdir, pickle_module)


@pytest.fixture
@pytest.mark.parquet
def s3_example_simple(s3_server):
from pyarrow.fs import FileSystem

Expand Down
5 changes: 1 addition & 4 deletions python/pyarrow/tests/test_extension_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,10 +1485,7 @@ def test_legacy_int_type():
batch = pa.RecordBatch.from_arrays([ext_arr], names=['ext'])
buf = ipc_write_batch(batch)

with pytest.warns(
RuntimeWarning,
match="pickle-based deserialization of pyarrow.PyExtensionType "
"subclasses is disabled by default"):
with pytest.warns((RuntimeWarning, FutureWarning)):
batch = ipc_read_batch(buf)
assert isinstance(batch.column(0).type, pa.UnknownExtensionType)

Expand Down
34 changes: 17 additions & 17 deletions python/pyarrow/tests/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,79 +362,79 @@ def py_fsspec_s3fs(request, s3_server):

@pytest.fixture(params=[
pytest.param(
pytest.lazy_fixture('localfs'),
'localfs',
id='LocalFileSystem()'
),
pytest.param(
pytest.lazy_fixture('localfs_with_mmap'),
'localfs_with_mmap',
id='LocalFileSystem(use_mmap=True)'
),
pytest.param(
pytest.lazy_fixture('subtree_localfs'),
'subtree_localfs',
id='SubTreeFileSystem(LocalFileSystem())'
),
pytest.param(
pytest.lazy_fixture('s3fs'),
's3fs',
id='S3FileSystem',
marks=pytest.mark.s3
),
pytest.param(
pytest.lazy_fixture('gcsfs'),
'gcsfs',
id='GcsFileSystem',
marks=pytest.mark.gcs
),
pytest.param(
pytest.lazy_fixture('hdfs'),
'hdfs',
id='HadoopFileSystem',
marks=pytest.mark.hdfs
),
pytest.param(
pytest.lazy_fixture('mockfs'),
'mockfs',
id='_MockFileSystem()'
),
pytest.param(
pytest.lazy_fixture('py_localfs'),
'py_localfs',
id='PyFileSystem(ProxyHandler(LocalFileSystem()))'
),
pytest.param(
pytest.lazy_fixture('py_mockfs'),
'py_mockfs',
id='PyFileSystem(ProxyHandler(_MockFileSystem()))'
),
pytest.param(
pytest.lazy_fixture('py_fsspec_localfs'),
'py_fsspec_localfs',
id='PyFileSystem(FSSpecHandler(fsspec.LocalFileSystem()))'
),
pytest.param(
pytest.lazy_fixture('py_fsspec_memoryfs'),
'py_fsspec_memoryfs',
id='PyFileSystem(FSSpecHandler(fsspec.filesystem("memory")))'
),
pytest.param(
pytest.lazy_fixture('py_fsspec_s3fs'),
'py_fsspec_s3fs',
id='PyFileSystem(FSSpecHandler(s3fs.S3FileSystem()))',
marks=pytest.mark.s3
),
])
def filesystem_config(request):
return request.param
return request.getfixturevalue(request.param)


@pytest.fixture
def fs(request, filesystem_config):
def fs(filesystem_config):
return filesystem_config['fs']


@pytest.fixture
def pathfn(request, filesystem_config):
def pathfn(filesystem_config):
return filesystem_config['pathfn']


@pytest.fixture
def allow_move_dir(request, filesystem_config):
def allow_move_dir(filesystem_config):
return filesystem_config['allow_move_dir']


@pytest.fixture
def allow_append_to_file(request, filesystem_config):
def allow_append_to_file(filesystem_config):
return filesystem_config['allow_append_to_file']


Expand Down
6 changes: 3 additions & 3 deletions python/pyarrow/tests/test_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ def stream_fixture():

@pytest.fixture(params=[
pytest.param(
pytest.lazy_fixture('file_fixture'),
'file_fixture',
id='File Format'
),
pytest.param(
pytest.lazy_fixture('stream_fixture'),
'stream_fixture',
id='Stream Format'
)
])
def format_fixture(request):
return request.param
return request.getfixturevalue(request.param)


def test_empty_file():
Expand Down
1 change: 0 additions & 1 deletion python/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ cffi
hypothesis
pandas
pytest<8
pytest-lazy-fixture
pytz
1 change: 0 additions & 1 deletion python/requirements-wheel-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ cffi
cython
hypothesis
pytest<8
pytest-lazy-fixture
pytz
tzdata; sys_platform == 'win32'

Expand Down

0 comments on commit 44d5597

Please sign in to comment.