1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

remember to close the VCRHTTPSConnection

This commit is contained in:
Thomas Grainger
2023-12-15 11:08:49 +00:00
parent bddec2e62a
commit 3919cb2573

View File

@@ -1,3 +1,4 @@
import contextlib
from unittest import mock
from pytest import mark
@@ -16,7 +17,7 @@ class TestVCRConnection:
@mark.online
@mock.patch("vcr.cassette.Cassette.can_play_response_for", return_value=False)
def testing_connect(*args):
vcr_connection = VCRHTTPSConnection("www.google.com")
vcr_connection.cassette = Cassette("test", record_mode=mode.ALL)
vcr_connection.real_connection.connect()
assert vcr_connection.real_connection.sock is not None
with contextlib.closing(VCRHTTPSConnection("www.google.com")) as vcr_connection:
vcr_connection.cassette = Cassette("test", record_mode=mode.ALL)
vcr_connection.real_connection.connect()
assert vcr_connection.real_connection.sock is not None