Skip to content

Commit 5aa514c

Browse files
committed
Simplify exception mock
1 parent cacde44 commit 5aa514c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tests/test_zenodo.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,10 @@ def test_get_metadata_and_archive_url_failure(monkeypatch):
6565
record._get_metadata_and_archive_url()
6666

6767

68-
def test_get_metadata_and_archive_url_connection_error(monkeypatch):
69-
monkeypatch.setattr(
70-
"requests.get",
71-
lambda *args, **kwargs: (_ for _ in ()).throw(
72-
requests.exceptions.RequestException("Connection error")
73-
),
74-
)
68+
@patch(
69+
"requests.get", side_effect=requests.exceptions.RequestException("Connection error")
70+
)
71+
def test_get_metadata_and_archive_url_connection_error(mock_get):
7572
record = ZenodoRecord("123", Path("/tmp"), "test")
7673

7774
assert record._get_metadata_and_archive_url() is None

0 commit comments

Comments
 (0)