jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/753989 )
Change subject: [IMPR] import unittest code parts directly instead through tests
......................................................................
[IMPR] import unittest code parts directly instead through tests
Change-Id: I79e36039a18e46afe84a20d1f908584da5f795b0
---
M tests/README.rst
M tests/api_tests.py
M tests/category_bot_tests.py
M tests/diff_tests.py
M tests/dry_api_tests.py
M tests/edit_failure_tests.py
M tests/eventstreams_tests.py
M tests/http_tests.py
M tests/login_tests.py
M tests/page_tests.py
M tests/pagegenerators_tests.py
M tests/redirect_bot_tests.py
M tests/site_tests.py
M tests/siteinfo_tests.py
M tests/sparql_tests.py
M tests/textlib_tests.py
M tests/tools_tests.py
M tests/user_tests.py
M tests/wikibase_tests.py
19 files changed, 29 insertions(+), 20 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/README.rst b/tests/README.rst
index c356cde..22ffc07 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -181,7 +181,7 @@
::
- from tests import patch
+ from unittest.mock import patch
def fake_ping(url):
diff --git a/tests/api_tests.py b/tests/api_tests.py
index 2464186..ae1d958 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -9,6 +9,7 @@
import types
from collections import defaultdict
from contextlib import suppress
+from unittest.mock import patch
import pywikibot.family
import pywikibot.login
@@ -18,7 +19,6 @@
from pywikibot.exceptions import APIError, NoUsernameError
from pywikibot.throttle import Throttle
from pywikibot.tools import suppress_warnings
-from tests import patch
from tests.aspects import (
DefaultDrySiteTestCase,
DefaultSiteTestCase,
diff --git a/tests/category_bot_tests.py b/tests/category_bot_tests.py
index aa58282..4ad45a0 100644
--- a/tests/category_bot_tests.py
+++ b/tests/category_bot_tests.py
@@ -7,11 +7,11 @@
#
import unittest
from contextlib import suppress
+from unittest.mock import Mock, patch
import pywikibot
from pywikibot import BaseSite
from scripts.category import CategoryMoveRobot, CategoryPreprocess
-from tests import Mock, patch
from tests.aspects import DefaultSiteTestCase, TestCase
diff --git a/tests/diff_tests.py b/tests/diff_tests.py
index 5e7ecfb..adc51e8 100644
--- a/tests/diff_tests.py
+++ b/tests/diff_tests.py
@@ -1,13 +1,14 @@
#!/usr/bin/python3
"""Test diff module."""
#
-# (C) Pywikibot team, 2016-2021
+# (C) Pywikibot team, 2016-2022
#
# Distributed under the terms of the MIT license.
from contextlib import suppress
+from unittest.mock import patch
from pywikibot.diff import PatchManager, cherry_pick, html_comparator
-from tests import join_html_data_path, patch
+from tests import join_html_data_path
from tests.aspects import TestCase, require_modules, unittest
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index 9fc9175..ddf9c84 100644
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -6,6 +6,7 @@
# Distributed under the terms of the MIT license.
#
import datetime
+from unittest.mock import patch
import pywikibot
from pywikibot.data.api import (
@@ -18,7 +19,7 @@
from pywikibot.family import Family
from pywikibot.login import LoginStatus
from pywikibot.tools import suppress_warnings
-from tests import join_images_path, patch
+from tests import join_images_path
from tests.aspects import (
DefaultDrySiteTestCase,
SiteAttributeTestCase,
diff --git a/tests/edit_failure_tests.py b/tests/edit_failure_tests.py
index cb927c9..331bc0c 100644
--- a/tests/edit_failure_tests.py
+++ b/tests/edit_failure_tests.py
@@ -14,6 +14,7 @@
#
import unittest
from contextlib import suppress
+from unittest.mock import patch
import pywikibot
from pywikibot import config
@@ -28,7 +29,6 @@
SpamblacklistError,
TitleblacklistError,
)
-from tests import patch
from tests.aspects import TestCase, WikibaseTestCase
diff --git a/tests/eventstreams_tests.py b/tests/eventstreams_tests.py
index 61262b6..9a1ede8 100644
--- a/tests/eventstreams_tests.py
+++ b/tests/eventstreams_tests.py
@@ -8,11 +8,11 @@
import json
import unittest
from contextlib import suppress
+from unittest import mock
from pywikibot import config
from pywikibot.comms.eventstreams import EventSource, EventStreams
from pywikibot.family import WikimediaFamily
-from tests import mock
from tests.aspects import DefaultSiteTestCase, TestCase, require_modules
diff --git a/tests/http_tests.py b/tests/http_tests.py
index e1096cf..62b066e 100644
--- a/tests/http_tests.py
+++ b/tests/http_tests.py
@@ -10,6 +10,7 @@
import warnings
from contextlib import suppress
from http import HTTPStatus
+from unittest.mock import patch
import requests
@@ -18,7 +19,7 @@
from pywikibot.comms import http
from pywikibot.exceptions import FatalServerError, Server504Error
from pywikibot.tools import PYTHON_VERSION, suppress_warnings
-from tests import join_images_path, patch
+from tests import join_images_path
from tests.aspects import HttpbinTestCase, TestCase, require_modules, unittest
diff --git a/tests/login_tests.py b/tests/login_tests.py
index be4e8c5..005ea66 100644
--- a/tests/login_tests.py
+++ b/tests/login_tests.py
@@ -11,10 +11,10 @@
#
from collections import defaultdict
from io import StringIO
+from unittest import mock
from pywikibot.exceptions import NoUsernameError
from pywikibot.login import LoginManager
-from tests import mock
from tests.aspects import DefaultDrySiteTestCase, unittest
diff --git a/tests/page_tests.py b/tests/page_tests.py
index 9a37684..3693826 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -8,6 +8,7 @@
import pickle
import re
from contextlib import suppress
+from unittest import mock
import pywikibot
import pywikibot.page
@@ -21,7 +22,7 @@
UnknownExtensionError,
)
from pywikibot.tools import suppress_warnings
-from tests import WARN_SITE_CODE, mock
+from tests import WARN_SITE_CODE
from tests.aspects import (
DefaultDrySiteTestCase,
DefaultSiteTestCase,
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index d515f7c..df6af2d 100644
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -11,6 +11,7 @@
import unittest
from contextlib import suppress
from typing import Optional
+from unittest import mock
import pywikibot
from pywikibot import date, pagegenerators
@@ -22,7 +23,7 @@
WikibaseItemFilterPageGenerator,
)
from pywikibot.tools import has_module, suppress_warnings
-from tests import join_data_path, mock
+from tests import join_data_path
from tests.aspects import (
DefaultSiteTestCase,
DeprecationTestCase,
diff --git a/tests/redirect_bot_tests.py b/tests/redirect_bot_tests.py
index f7aa2a9..e41fdc9 100644
--- a/tests/redirect_bot_tests.py
+++ b/tests/redirect_bot_tests.py
@@ -7,11 +7,11 @@
#
import unittest
from contextlib import suppress
+from unittest.mock import Mock, patch
import pywikibot
from pywikibot import Page, i18n
from scripts.redirect import RedirectRobot
-from tests import Mock, patch
from tests.aspects import DefaultSiteTestCase
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 7ffb9a2..13ed4ed 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -13,6 +13,7 @@
from collections.abc import Iterable, Mapping
from contextlib import suppress
from http import HTTPStatus
+from unittest.mock import patch
import pywikibot
from pywikibot import config
@@ -29,7 +30,7 @@
UnknownSiteError,
)
from pywikibot.tools import suppress_warnings
-from tests import WARN_SITE_CODE, patch, unittest_print
+from tests import WARN_SITE_CODE, unittest_print
from tests.aspects import (
AlteredDefaultSiteTestCase,
DefaultDrySiteTestCase,
diff --git a/tests/siteinfo_tests.py b/tests/siteinfo_tests.py
index 9b0e099..7c7c36a 100644
--- a/tests/siteinfo_tests.py
+++ b/tests/siteinfo_tests.py
@@ -9,10 +9,10 @@
import unittest
from contextlib import suppress
from datetime import datetime
+from unittest.mock import MagicMock, patch
import pywikibot
from pywikibot import async_request, page_put_queue
-from tests import MagicMock, patch
from tests.aspects import DefaultDrySiteTestCase, DefaultSiteTestCase
from tests.utils import entered_loop
diff --git a/tests/sparql_tests.py b/tests/sparql_tests.py
index 15724d8..4f9b808 100644
--- a/tests/sparql_tests.py
+++ b/tests/sparql_tests.py
@@ -7,10 +7,10 @@
#
import unittest
from contextlib import suppress
+from unittest.mock import patch
import pywikibot
import pywikibot.data.sparql as sparql
-from tests import patch
from tests.aspects import TestCase, WikidataTestCase
from tests.utils import skipping
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index f52dc4d..3ac42f5 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -12,6 +12,7 @@
import unittest
from collections import OrderedDict
from contextlib import suppress
+from unittest import mock
import pywikibot
from pywikibot import textlib
@@ -20,7 +21,6 @@
from pywikibot.site._interwikimap import _IWEntry
from pywikibot.textlib import MultiTemplateMatchBuilder, extract_sections
from pywikibot.tools import has_module
-from tests import mock
from tests.aspects import (
DefaultDrySiteTestCase,
SiteAttributeTestCase,
diff --git a/tests/tools_tests.py b/tests/tools_tests.py
index 4b073a5..c6fb4c0 100644
--- a/tests/tools_tests.py
+++ b/tests/tools_tests.py
@@ -9,6 +9,7 @@
import subprocess
import tempfile
import unittest
+from unittest import mock
from collections import Counter, OrderedDict
from collections.abc import Mapping
@@ -23,7 +24,7 @@
is_ip_address,
suppress_warnings,
)
-from tests import join_xml_data_path, mock
+from tests import join_xml_data_path
from tests.aspects import TestCase, require_modules
diff --git a/tests/user_tests.py b/tests/user_tests.py
index 67b1479..23afe79 100644
--- a/tests/user_tests.py
+++ b/tests/user_tests.py
@@ -6,11 +6,11 @@
# Distributed under the terms of the MIT license.
#
from contextlib import suppress
+from unittest.mock import patch
import pywikibot
from pywikibot import Page, Timestamp, User
from pywikibot.exceptions import AutoblockUserError
-from tests import patch
from tests.aspects import DefaultSiteTestCase, TestCase, unittest
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index b60a18b..edf2541 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -10,6 +10,7 @@
import unittest
from contextlib import suppress
from decimal import Decimal
+from unittest import mock
import pywikibot
from pywikibot import pagegenerators
@@ -24,7 +25,8 @@
from pywikibot.page import ItemPage, Page, PropertyPage, WikibasePage
from pywikibot.site import Namespace, NamespacesDict
from pywikibot.tools import MediaWikiVersion, suppress_warnings
-from tests import WARN_SITE_CODE, join_pages_path, mock
+
+from tests import WARN_SITE_CODE, join_pages_path
from tests.aspects import TestCase, WikidataTestCase
from tests.basepage import (
BasePageLoadRevisionsCachingTestBase,
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/753989
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I79e36039a18e46afe84a20d1f908584da5f795b0
Gerrit-Change-Number: 753989
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged