Page MenuHomePhabricator

_test_logevent sometimes fails with AssertionError: Regex didn't match
Closed, ResolvedPublic

Description

https://travis-ci.org/5j9/pywikibot-core/jobs/414377042#L3778

self = <tests.logentry_tests.TestLogentries testMethod=test_BlockEntry_tewp>
logtype = 'block'
    def _test_logevent(self, logtype):
        """Test a single logtype entry."""
        logentry = self._get_logentry(logtype)
        self.assertIn(logtype, logentry.__class__.__name__.lower())
        self.assertEqual(logentry._expectedType, logtype)
        if logtype not in LogEntryFactory._logtypes:
            self.assertIsInstance(logentry, OtherLogEntry)
        if self.site_key == 'old':
            self.assertNotIn('params', logentry.data)
        else:
            self.assertNotIn(logentry.type(), logentry.data)
        self.assertIsInstance(logentry.action(), unicode)
        try:
>           self.assertIsInstance(logentry.comment(), unicode)
tests/logentry_tests.py:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <BlockEntry(wikipedia:test, logid=215655)>
    def comment(self):
        """Return the logentry's comment.
    
            @rtype: str
            """
>       return self.data['comment']
pywikibot/logentries.py:157: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = {'params': {'flags': ['noautoblock'], 'duration': 'infinite'}, 'logpage': 100557, 'action': 'block', 'pageid': 100557,...estaccount-1', 'timestamp': '2018-08-08T21:52:56Z', 'logid': 215655, 'ns': 2, 'user': "There'sNoTime", 'type': 'block'}
key = 'comment'
    def __missing__(self, key):
        """Debug when the key is missing."""
        pywikibot.debug(u"API log entry received:\n" + repr(self),
                        _logger)
        if ((key in ('ns', 'title', 'pageid', 'logpage', 'params', 'action')
             and 'actionhidden' in self)
                or (key == 'comment' and 'commenthidden' in self)
                or (key == 'user' and 'userhidden' in self)):
            raise HiddenKeyError(
                "Log entry ({0}) has a hidden '{1}' key and you don't have "
>               'permission to view it.'.format(self._type, key))
E           pywikibot.exceptions.HiddenKeyError: Log entry (block) has a hidden 'comment' key and you don't have permission to view it.
pywikibot/logentries.py:43: HiddenKeyError
During handling of the above exception, another exception occurred:
self = <tests.logentry_tests.TestLogentries testMethod=test_BlockEntry_tewp>
    def wrapped_method(self):
        sitedata = self.sites[key]
        self.site_key = key
        self.family = sitedata['family']
        self.code = sitedata['code']
        self.site = sitedata['site']
>       func(self, key)
tests/aspects.py:783: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/logentry_tests.py:122: in test_logevent
    self._test_logevent(logtype)
tests/logentry_tests.py:85: in _test_logevent
    "Log entry ([^)]+) has a hidden 'comment' key, and you don't "
E   AssertionError: Regex didn't match: "Log entry ([^)]+) has a hidden 'comment' key, and you don't have permission to view it." not found in "Log entry (block) has a hidden 'comment' key and you don't have permission to view it."
------------------------------ Captured log call -------------------------------
logging.py                 109 VERBOSE  Found 1 wikipedia:test processes running, including this one.

Event Timeline

Change 451827 had a related patch set uploaded (by Dalba; owner: dalba):
[pywikibot/core@master] TestLogentriesBase._test_logevent: Fix the HiddenKeyError error message regex

https://gerrit.wikimedia.org/r/451827

Xqt triaged this task as High priority.

Change 451827 merged by jenkins-bot:
[pywikibot/core@master] TestLogentriesBase._test_logevent: Fix the HiddenKeyError error message regex

https://gerrit.wikimedia.org/r/451827