From 8e13af2ee9c1815f128b3a654310a0e92a20afda Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 15 Dec 2023 18:38:56 +0000 Subject: [PATCH] use context manager for requests.Session --- tests/integration/test_wild.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/test_wild.py b/tests/integration/test_wild.py index 6e0df08..2db7744 100644 --- a/tests/integration/test_wild.py +++ b/tests/integration/test_wild.py @@ -63,12 +63,12 @@ def test_flickr_should_respond_with_200(tmpdir): def test_cookies(tmpdir, httpbin): testfile = str(tmpdir.join("cookies.yml")) with vcr.use_cassette(testfile): - s = requests.Session() - s.get(httpbin.url + "/cookies/set?k1=v1&k2=v2") - assert s.cookies.keys() == ["k1", "k2"] + with requests.Session() as s: + s.get(httpbin.url + "/cookies/set?k1=v1&k2=v2") + assert s.cookies.keys() == ["k1", "k2"] - r2 = s.get(httpbin.url + "/cookies") - assert sorted(r2.json()["cookies"].keys()) == ["k1", "k2"] + r2 = s.get(httpbin.url + "/cookies") + assert sorted(r2.json()["cookies"].keys()) == ["k1", "k2"] @pytest.mark.online