1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-10 09:35:34 +00:00

use context manager for requests.Session

This commit is contained in:
Thomas Grainger
2023-12-15 18:38:56 +00:00
parent d39c26b358
commit 8e13af2ee9

View File

@@ -63,7 +63,7 @@ def test_flickr_should_respond_with_200(tmpdir):
def test_cookies(tmpdir, httpbin): def test_cookies(tmpdir, httpbin):
testfile = str(tmpdir.join("cookies.yml")) testfile = str(tmpdir.join("cookies.yml"))
with vcr.use_cassette(testfile): with vcr.use_cassette(testfile):
s = requests.Session() with requests.Session() as s:
s.get(httpbin.url + "/cookies/set?k1=v1&k2=v2") s.get(httpbin.url + "/cookies/set?k1=v1&k2=v2")
assert s.cookies.keys() == ["k1", "k2"] assert s.cookies.keys() == ["k1", "k2"]