Skip to content

Commit bef384e

Browse files
committed
Replace read with getvalue where possible
1 parent 326f625 commit bef384e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

tests/mock_vws/fixtures/prepared_requests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def add_target(
4545
"""
4646
Return details of the endpoint for adding a target.
4747
"""
48-
image_data = image_file_failed_state.read()
48+
image_data = image_file_failed_state.getvalue()
4949
image_data_encoded = base64.b64encode(s=image_data).decode(
5050
encoding="ascii"
5151
)
@@ -431,7 +431,7 @@ def query(
431431
"""
432432
Return details of the endpoint for making an image recognition query.
433433
"""
434-
image_content = high_quality_image.read()
434+
image_content = high_quality_image.getvalue()
435435
date = rfc_1123_date()
436436
request_path = "/v1/query"
437437
files = {"image": ("image.jpeg", image_content, "image/jpeg")}

tests/mock_vws/test_add_target.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def test_content_types(
145145
"""
146146
Any non-empty ``Content-Type`` header is allowed.
147147
"""
148-
image_data = image_file_failed_state.read()
148+
image_data = image_file_failed_state.getvalue()
149149
image_data_encoded = base64.b64encode(s=image_data).decode(
150150
encoding="ascii"
151151
)
@@ -173,7 +173,7 @@ def test_empty_content_type(
173173
An ``UNAUTHORIZED`` response is given if an empty ``Content-Type``
174174
header is given.
175175
"""
176-
image_data = image_file_failed_state.read()
176+
image_data = image_file_failed_state.getvalue()
177177
image_data_encoded = base64.b64encode(s=image_data).decode(
178178
encoding="ascii"
179179
)
@@ -219,7 +219,7 @@ def test_missing_data(
219219
"""
220220
`name`, `width` and `image` are all required.
221221
"""
222-
image_data = image_file_failed_state.read()
222+
image_data = image_file_failed_state.getvalue()
223223
image_data_encoded = base64.b64encode(s=image_data).decode(
224224
encoding="ascii",
225225
)
@@ -261,7 +261,7 @@ def test_width_invalid(
261261
"""
262262
The width must be a number greater than zero.
263263
"""
264-
image_data = image_file_failed_state.read()
264+
image_data = image_file_failed_state.getvalue()
265265
image_data_encoded = base64.b64encode(s=image_data).decode(
266266
encoding="ascii"
267267
)
@@ -369,7 +369,7 @@ def test_name_invalid(
369369
A target's name must be a string of length 0 < N < 65, with characters
370370
in a particular range.
371371
"""
372-
image_data = image_file_failed_state.read()
372+
image_data = image_file_failed_state.getvalue()
373373
image_data_encoded = base64.b64encode(s=image_data).decode(
374374
encoding="ascii",
375375
)
@@ -709,7 +709,7 @@ def test_valid(
709709
"""
710710
Boolean values and NULL are valid active flags.
711711
"""
712-
image_data = image_file_failed_state.read()
712+
image_data = image_file_failed_state.getvalue()
713713
image_data_encoded = base64.b64encode(s=image_data).decode(
714714
encoding="ascii",
715715
)
@@ -739,7 +739,7 @@ def test_invalid(
739739
Values which are not Boolean values or NULL are not valid active flags.
740740
"""
741741
active_flag = "string"
742-
image_data = image_file_failed_state.read()
742+
image_data = image_file_failed_state.getvalue()
743743
image_data_encoded = base64.b64encode(s=image_data).decode(
744744
encoding="ascii"
745745
)
@@ -773,7 +773,7 @@ def test_not_set(
773773
"""
774774
The active flag defaults to True if it is not set.
775775
"""
776-
image_data = image_file_failed_state.read()
776+
image_data = image_file_failed_state.getvalue()
777777
image_data_encoded = base64.b64encode(s=image_data).decode(
778778
encoding="ascii"
779779
)
@@ -798,7 +798,7 @@ def test_set_to_none(
798798
"""
799799
The active flag defaults to True if it is set to NULL.
800800
"""
801-
image_data = image_file_failed_state.read()
801+
image_data = image_file_failed_state.getvalue()
802802
image_data_encoded = base64.b64encode(s=image_data).decode(
803803
encoding="ascii"
804804
)
@@ -832,7 +832,7 @@ def test_invalid_extra_data(
832832
"""
833833
A `BAD_REQUEST` response is returned when unexpected data is given.
834834
"""
835-
image_data = image_file_failed_state.read()
835+
image_data = image_file_failed_state.getvalue()
836836
image_data_encoded = base64.b64encode(s=image_data).decode(
837837
encoding="ascii"
838838
)
@@ -897,7 +897,7 @@ def test_null(
897897
"""
898898
NULL is valid application metadata.
899899
"""
900-
image_data = image_file_failed_state.read()
900+
image_data = image_file_failed_state.getvalue()
901901
image_data_encoded = base64.b64encode(s=image_data).decode(
902902
encoding="ascii"
903903
)
@@ -925,7 +925,7 @@ def test_invalid_type(
925925
Values which are not a string or NULL are not valid application
926926
metadata.
927927
"""
928-
image_data = image_file_failed_state.read()
928+
image_data = image_file_failed_state.getvalue()
929929
image_data_encoded = base64.b64encode(s=image_data).decode(
930930
encoding="ascii"
931931
)

0 commit comments

Comments
 (0)