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

style: fix formatting issues to comply with pre-commit hooks

This commit is contained in:
Daniel Silva
2025-01-04 21:18:53 +00:00
parent 36c7465cf7
commit d64cdd337b
3 changed files with 7 additions and 4 deletions

View File

@@ -82,6 +82,7 @@ def test_dont_record_on_exception(tmpdir):
assert not os.path.exists(str(tmpdir.join("dontsave2.yml"))) assert not os.path.exists(str(tmpdir.join("dontsave2.yml")))
def test_set_drop_unused_requests(tmpdir, httpbin): def test_set_drop_unused_requests(tmpdir, httpbin):
my_vcr = vcr.VCR(drop_unused_requests=True) my_vcr = vcr.VCR(drop_unused_requests=True)
file = str(tmpdir.join("test.yaml")) file = str(tmpdir.join("test.yaml"))

View File

@@ -401,7 +401,7 @@ def test_used_interactions(tmpdir):
interactions = [ interactions = [
{"request": {"body": "", "uri": "foo1", "method": "GET", "headers": {}}, "response": "bar1"}, {"request": {"body": "", "uri": "foo1", "method": "GET", "headers": {}}, "response": "bar1"},
{"request": {"body": "", "uri": "foo2", "method": "GET", "headers": {}}, "response": "bar2"}, {"request": {"body": "", "uri": "foo2", "method": "GET", "headers": {}}, "response": "bar2"},
{"request": {"body": "", "uri": "foo3", "method": "GET", "headers": {}}, "response": "bar3"} {"request": {"body": "", "uri": "foo3", "method": "GET", "headers": {}}, "response": "bar3"},
] ]
file = tmpdir.join("test_cassette.yml") file = tmpdir.join("test_cassette.yml")
file.write(yaml.dump({"interactions": [interactions[0], interactions[1]]})) file.write(yaml.dump({"interactions": [interactions[0], interactions[1]]}))

View File

@@ -348,8 +348,10 @@ class Cassette:
"""List of new HTTP interactions (request/response tuples)""" """List of new HTTP interactions (request/response tuples)"""
new_interactions = [] new_interactions = []
for request, response in self.data: for request, response in self.data:
if all(not requests_match(request, old_request, self._match_on) if all(
for old_request, _ in self._old_interactions): not requests_match(request, old_request, self._match_on)
for old_request, _ in self._old_interactions
):
new_interactions.append((request, response)) new_interactions.append((request, response))
return new_interactions return new_interactions
@@ -363,7 +365,7 @@ class Cassette:
return {"requests": requests, "responses": responses} return {"requests": requests, "responses": responses}
def _save(self, force=False): def _save(self, force=False):
if (len(self._played_interactions) < len(self._old_interactions)): if len(self._played_interactions) < len(self._old_interactions):
force = True force = True
if force or self.dirty: if force or self.dirty:
self._persister.save_cassette(self._path, self._as_dict(), serializer=self._serializer) self._persister.save_cassette(self._path, self._as_dict(), serializer=self._serializer)