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.

Event Timeline

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 subscribed.

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

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

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

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

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?

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!

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 subscribed.

py2.6 will be dropped, see T154771