Skip to content

Commit bd3d668

Browse files
committed
test: always disable custom pickler in tests
1 parent 8f7208c commit bd3d668

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from __future__ import annotations
2+
3+
import pytest
4+
5+
from awkward._pickle import use_builtin_reducer
6+
7+
8+
@pytest.fixture(autouse=True)
9+
def disable_external_pickler():
10+
"""Fixture to disable external pickler implementation for every test"""
11+
with use_builtin_reducer():
12+
yield

tests/test_2757_attrs_metadata.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
22
from __future__ import annotations
33

4+
import pickle
5+
46
import packaging.version
57
import pytest
68

79
import awkward as ak
8-
from awkward._pickle import use_builtin_reducer
9-
10-
11-
@pytest.fixture
12-
def array_pickler():
13-
import pickle
14-
15-
with use_builtin_reducer():
16-
yield pickle
17-
1810

1911
SOME_ATTRS = {"foo": "!SOME"}
2012
OTHER_ATTRS = {"bar": "!OTHER", "foo": "!OTHER"}
@@ -31,18 +23,18 @@ def test_set_attrs():
3123
array.attrs = "Hello world!"
3224

3325

34-
def test_serialise_with_transient_attrs(array_pickler):
26+
def test_serialise_with_transient_attrs():
3527
attrs = {**SOME_ATTRS, "@transient_key": lambda: None}
3628
array = ak.Array([1, 2, 3], attrs=attrs)
37-
result = array_pickler.loads(array_pickler.dumps(array))
29+
result = pickle.loads(pickle.dumps(array))
3830
assert result.attrs == SOME_ATTRS
3931

4032

41-
def test_serialise_with_nonserialisable_attrs(array_pickler):
33+
def test_serialise_with_nonserialisable_attrs():
4234
attrs = {**SOME_ATTRS, "non_transient_key": lambda: None}
4335
array = ak.Array([1, 2, 3], attrs=attrs)
4436
with pytest.raises(AttributeError, match=r"Can't pickle local object"):
45-
array_pickler.loads(array_pickler.dumps(array))
37+
pickle.loads(pickle.dumps(array))
4638

4739

4840
def test_transient_metadata_persists():

0 commit comments

Comments
 (0)