jenkins-bot merged this change.

View Change

Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
[tests] Add unittest_print statements for debugging

Bug: T249090
Change-Id: I5172d2bbb3b324018c12a8e8fb235e9f0c798c2c
---
M pywikibot/data/api.py
M tests/api_tests.py
2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 609c9f5..d65bf7e 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1171,7 +1171,8 @@
"""
if site is None:
self.site = pywikibot.Site()
- warn('Request() invoked without a site', RuntimeWarning, 2)
+ warn('Request() invoked without a site; setting to {}'
+ .format(self.site), RuntimeWarning, 2)
else:
self.site = site
if mime_params is not None:
diff --git a/tests/api_tests.py b/tests/api_tests.py
index bd3b310..f8f5da9 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -17,6 +17,7 @@
import pywikibot.page
import pywikibot.site

+from pywikibot import config
from pywikibot.throttle import Throttle
from pywikibot.tools import (
suppress_warnings,
@@ -24,7 +25,7 @@
UnicodeType,
)

-from tests import patch
+from tests import patch, unittest_print
from tests.aspects import (
unittest,
TestCase,
@@ -136,12 +137,25 @@

"""API Request object test class."""

- @suppress_warnings(r'Request\(\) invoked without a site', RuntimeWarning)
+ # @suppress_warnings(r'Request\(\) invoked without a site', RuntimeWarning)
def testObjectCreation(self):
"""Test api.Request() constructor with implicit site creation."""
+ unittest_print('\n\n>>> Debugging stuff (T249090) ----')
+ unittest_print('config at method start:', config.mylang, config.family)
+ unittest_print('<<< ------------------------------\n')
+
req = api.Request(parameters={'action': 'test', 'foo': '',
'bar': 'test'})
self.assertTrue(req)
+
+ unittest_print('>>> Debugging stuff (T249090) ----')
+ unittest_print('config:', config.mylang, config.family)
+ unittest_print('Request:', req)
+ unittest_print(req.__dict__)
+ unittest_print('config before asserting:',
+ config.mylang, config.family)
+ unittest_print('<<< ------------------------------')
+
self.assertEqual(req.site, self.get_site())



To view, visit change 593917. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5172d2bbb3b324018c12a8e8fb235e9f0c798c2c
Gerrit-Change-Number: 593917
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)