From d62b9098dd80b7792f0d5478d4e67ac06154606d Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 16 Apr 2020 11:44:28 +0300 Subject: [PATCH] Refactor other tests into test_pickle_image --- Tests/test_pickle.py | 47 ++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py index b95d8baca..fe4e75646 100644 --- a/Tests/test_pickle.py +++ b/Tests/test_pickle.py @@ -39,45 +39,28 @@ def helper_pickle_string( @pytest.mark.parametrize( - "test_file", ["Tests/images/hopper.jpg"], + ("test_file", "test_mode"), + [ + ("Tests/images/hopper.jpg", None), + ("Tests/images/hopper.jpg", "L"), + ("Tests/images/hopper.jpg", "PA"), + ("Tests/images/test-card.png", None), + ("Tests/images/zero_bb.png", None), + ("Tests/images/zero_bb_scale2.png", None), + ("Tests/images/non_zero_bb.png", None), + ("Tests/images/non_zero_bb_scale2.png", None), + ("Tests/images/p_trns_single.png", None), + ("Tests/images/pil123p.png", None), + ("Tests/images/itxt_chunks.png", None), + ], ) -def test_pickle_image(test_file, tmp_path): +def test_pickle_image(tmp_path, test_file, test_mode): # Act / Assert for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1): helper_pickle_string(pickle, protocol, test_file) helper_pickle_file(tmp_path, pickle, protocol, test_file) -def test_pickle_p_mode(): - # Act / Assert - for test_file in [ - "Tests/images/test-card.png", - "Tests/images/zero_bb.png", - "Tests/images/zero_bb_scale2.png", - "Tests/images/non_zero_bb.png", - "Tests/images/non_zero_bb_scale2.png", - "Tests/images/p_trns_single.png", - "Tests/images/pil123p.png", - "Tests/images/itxt_chunks.png", - ]: - for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1): - helper_pickle_string(pickle, protocol=protocol, test_file=test_file) - - -def test_pickle_pa_mode(tmp_path): - # Act / Assert - for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1): - helper_pickle_string(pickle, protocol, mode="PA") - helper_pickle_file(tmp_path, pickle, protocol, mode="PA") - - -def test_pickle_l_mode(tmp_path): - # Act / Assert - for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1): - helper_pickle_string(pickle, protocol, mode="L") - helper_pickle_file(tmp_path, pickle, protocol, mode="L") - - def test_pickle_la_mode_with_palette(tmp_path): # Arrange filename = str(tmp_path / "temp.pkl")