From d64cdd337bc4e812cd2b49b59609d3d1582b6590 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Sat, 4 Jan 2025 21:18:53 +0000 Subject: [PATCH] style: fix formatting issues to comply with pre-commit hooks --- tests/integration/test_config.py | 1 + tests/unit/test_cassettes.py | 2 +- vcr/cassette.py | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index 361e7a332..8dd4dde6e 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -82,6 +82,7 @@ def some_test(): assert not os.path.exists(str(tmpdir.join("dontsave2.yml"))) + def test_set_drop_unused_requests(tmpdir, httpbin): my_vcr = vcr.VCR(drop_unused_requests=True) file = str(tmpdir.join("test.yaml")) diff --git a/tests/unit/test_cassettes.py b/tests/unit/test_cassettes.py index 0acd1164c..d1171a6da 100644 --- a/tests/unit/test_cassettes.py +++ b/tests/unit/test_cassettes.py @@ -401,7 +401,7 @@ def test_used_interactions(tmpdir): interactions = [ {"request": {"body": "", "uri": "foo1", "method": "GET", "headers": {}}, "response": "bar1"}, {"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.write(yaml.dump({"interactions": [interactions[0], interactions[1]]})) diff --git a/vcr/cassette.py b/vcr/cassette.py index 107e5d735..eec386f89 100644 --- a/vcr/cassette.py +++ b/vcr/cassette.py @@ -348,8 +348,10 @@ def _new_interactions(self): """List of new HTTP interactions (request/response tuples)""" new_interactions = [] for request, response in self.data: - if all(not requests_match(request, old_request, self._match_on) - for old_request, _ in self._old_interactions): + if all( + not requests_match(request, old_request, self._match_on) + for old_request, _ in self._old_interactions + ): new_interactions.append((request, response)) return new_interactions @@ -363,7 +365,7 @@ def _as_dict(self): return {"requests": requests, "responses": responses} 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 if force or self.dirty: self._persister.save_cassette(self._path, self._as_dict(), serializer=self._serializer)