Page MenuHomePhabricator

test deprecation filename problems
Closed, DeclinedPublic

Description

DeprecationTestCase captures all deprecation warnings, and attempts to verify the filename of the warnings are correct.

When a deprecation warning message occurs in code outside Pywikibot, DeprecationTestCase fails, and the failure error is not informative.

There are several cases where _do_test_warning_filename has been set to False to workaround bugs in the filename detection algorithms.

tests/dry_site_tests.py: self._do_test_warning_filename = False
tests/family_tests.py: self._do_test_warning_filename = False
tests/family_tests.py: self._do_test_warning_filename = False

Another problem started after d4b6c62 , but it may have been something else which caused it, and https://gerrit.wikimedia.org/r/#/c/218102/ adds another _do_test_warning_filename = False to work around the problem.

The build error is

FAIL: test_token (tests.site_tests.TestSiteObjectDeprecatedFunctions)
Test ability to get page tokens.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/wikimedia/pywikibot-core/tests/site_tests.py", line 72, in test_token
    self.assertDeprecation("pywikibot.site.APISite.token is deprecated"
  File "/home/travis/build/wikimedia/pywikibot-core/tests/aspects.py", line 1257, in assertDeprecation
    self.assertDeprecationFile(self.expect_warning_filename)
  File "/home/travis/build/wikimedia/pywikibot-core/tests/aspects.py", line 1271, in assertDeprecationFile
    self.assertEqual(item.filename, filename)
AssertionError: '/home/travis/virtualenv/python2.6.9/lib/python2.6/site[44 chars]_.py' != '/home/travis/build/wikimedia/pywikibot-core/tests/site_tests.py'
- /home/travis/virtualenv/python2.6.9/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py
+ /home/travis/build/wikimedia/pywikibot-core/tests/site_tests.py

To make this more informative, deprecation warnings with a filename not in 'pywikibot' package should be shown on the console so it is easier to debug them.

And possibly these 'other' warnings might be ignored, or we might have a hard coded list of 'other' warnings which we know should be ignored. This would mean we can add these SSL warnings to the list, as they are a known separate issue being worked on.

Details

Event Timeline

jayvdb created this task.Jun 13 2015, 11:30 PM
jayvdb raised the priority of this task from to Needs Triage.
jayvdb updated the task description. (Show Details)
jayvdb added projects: Pywikibot, Pywikibot-tests.
jayvdb added a subscriber: jayvdb.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptJun 13 2015, 11:30 PM
jayvdb triaged this task as Low priority.Jun 13 2015, 11:30 PM

Change 218102 had a related patch set uploaded (by John Vandenberg):
Workaround deprecation filename test breaking 2.6

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

XZise added a subscriber: XZise.Jun 13 2015, 11:31 PM
jayvdb updated the task description. (Show Details)Jun 13 2015, 11:33 PM
jayvdb set Security to None.
jayvdb removed a subscriber: XZise.

Change 218102 merged by jenkins-bot:
Workaround deprecation filename test breaking 2.6

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

jayvdb moved this task from Backlog to Framework on the Pywikibot-tests board.Jun 17 2015, 1:46 AM
XZise added a subscriber: XZise.Jun 17 2015, 4:01 PM

Okay it seems that I've been able to reproduce this bug in Python 3.4.3 too.

XZise added a comment.Jun 17 2015, 4:04 PM

Okay maybe false alarm but I got it because it actually didn't call the deprecated method but something that called the deprecated method (so the caller was no in the tests file). But maybe we have some code that wraps around the deprecated methods in certain cases and just in Python 2.6 screwing up the caller's position?

XZise added a comment.Jun 17 2015, 6:13 PM

Alternatively (if all the failures are related to SSL) it might be related to https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning

jayvdb added a comment.EditedJun 18 2015, 11:02 AM

Another one on py2.6, after several builds where it has not been a problem

https://travis-ci.org/wikimedia/pywikibot-core/jobs/67344240#L3786

And in the next build the problem disappeared!

jayvdb updated the task description. (Show Details)Jul 14 2015, 2:33 AM

Change 225666 had a related patch set uploaded (by John Vandenberg):
remove filename deprecation workaround

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

Change 225667 had a related patch set uploaded (by John Vandenberg):
Revert "Workaround deprecation filename test breaking 2.6"

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

Change 225677 had a related patch set uploaded (by John Vandenberg):
[WIP] Deprecation warning context handler

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

Change 225667 merged by jenkins-bot:
Revert "Workaround deprecation filename test breaking 2.6"

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

Change 225666 merged by jenkins-bot:
remove filename deprecation workaround

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

Change 225677 merged by jenkins-bot:
Deprecation warning context handler

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

Xqt closed this task as Declined.Apr 1 2018, 8:21 PM
Xqt added a subscriber: Xqt.

py2.6 will be dropped, see T154771