From 3d34b09a361dadb50bb4e4ffa18c75928904c30d Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Mon, 6 Nov 2023 12:18:46 -0800 Subject: Simplify mock usage in tests --- tests/test_client.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'tests/test_client.py') diff --git a/tests/test_client.py b/tests/test_client.py index 45739d3..207d9b2 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -16,11 +16,10 @@ # along with Wikiget. If not, see . import logging -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock, patch, sentinel import pytest -from mwclient import InvalidResponse, Site -from mwclient.image import Image +from mwclient import InvalidResponse from requests import ConnectionError, HTTPError from wikiget import DEFAULT_SITE @@ -113,9 +112,8 @@ class TestQueryApi: # would have created using the MediaWiki API. The Site.images attribute is # normally populated during Site init, but since we're not doing that, a mock # dict is created for query_api to parse. - mock_site = MagicMock(Site) - mock_image = MagicMock(Image) - mock_site.images = {"Example.jpg": mock_image} + mock_site = MagicMock() + mock_site.images = {"Example.jpg": sentinel.mock_image} image = query_api("Example.jpg", mock_site) - assert image == mock_image + assert image == sentinel.mock_image -- cgit v1.2.3