Skip to content

Commit db951b2

Browse files
Update unit_tests/sources/declarative/decoders/test_composite_decoder.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 5364059 commit db951b2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

unit_tests/sources/declarative/decoders/test_composite_decoder.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,15 @@ def test_composite_raw_decoder_csv_parser_without_mocked_response():
227227
httpd = HTTPServer(("localhost", 8080), TestServer)
228228
thread = Thread(target=httpd.serve_forever, args=())
229229
thread.start()
230-
231-
response = requests.get("http://localhost:8080", stream=True)
232-
result = list(CompositeRawDecoder(parser=CsvParser()).decode(response))
233-
234-
assert len(result) == 1
235-
httpd.shutdown() # release port and kill the thread
236-
230+
thread.start()
231+
try:
232+
response = requests.get(f"http://localhost:{port}", stream=True)
233+
result = list(CompositeRawDecoder(parser=CsvParser()).decode(response))
234+
235+
assert len(result) == 1
236+
finally:
237+
httpd.shutdown() # release port and kill the thread
238+
thread.join(timeout=5) # ensure thread is cleaned up
237239

238240
def test_given_response_already_consumed_when_decode_then_no_data_is_returned(requests_mock):
239241
requests_mock.register_uri(

0 commit comments

Comments
 (0)