Skip to content

Commit 53a85f2

Browse files
committed
Refactor test_pickle_image to use pytest.mark.parametrize
1 parent 97280a0 commit 53a85f2

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Tests/test_pickle.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import pickle
22

3+
import pytest
34
from PIL import Image
45

56

6-
def helper_pickle_file(tmp_path, pickle, protocol=0, mode=None):
7+
def helper_pickle_file(
8+
tmp_path, pickle, protocol=0, test_file="Tests/images/hopper.jpg", mode=None
9+
):
710
# Arrange
8-
with Image.open("Tests/images/hopper.jpg") as im:
11+
with Image.open(test_file) as im:
912
filename = str(tmp_path / "temp.pkl")
1013
if mode:
1114
im = im.convert(mode)
@@ -35,11 +38,14 @@ def helper_pickle_string(
3538
assert im == loaded_im
3639

3740

38-
def test_pickle_image(tmp_path):
41+
@pytest.mark.parametrize(
42+
"test_file", ["Tests/images/hopper.jpg"],
43+
)
44+
def test_pickle_image(test_file, tmp_path):
3945
# Act / Assert
4046
for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1):
41-
helper_pickle_string(pickle, protocol)
42-
helper_pickle_file(tmp_path, pickle, protocol)
47+
helper_pickle_string(pickle, protocol, test_file)
48+
helper_pickle_file(tmp_path, pickle, protocol, test_file)
4349

4450

4551
def test_pickle_p_mode():

0 commit comments

Comments
 (0)