Page MenuHomePhabricator

site_tests.TestDeprecatedEditTokenFunctions.test_token failes sometimes with AssertionError due to unclosed socket.socket ResourceWarning
Closed, ResolvedPublic

Description

_________________ TestDeprecatedEditTokenFunctions.test_token __________________

self = <tests.site_tests.TestDeprecatedEditTokenFunctions testMethod=test_token>

    def test_token(self):
        """Test ability to get page tokens using site.tokens."""
        token = self.token
        mysite = self.get_site()
        mainpage = self.get_mainpage()
        ttype = "edit"
        self.assertEqual(token, mysite.token(mainpage, ttype))
        self.assertOneDeprecationParts('pywikibot.site.APISite.token',
>                                      "the 'tokens' property")

tests/site_tests.py:2129: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/aspects.py:1603: in assertOneDeprecationParts
    count)
tests/aspects.py:1607: in assertOneDeprecation
    self.assertDeprecation(msg)
tests/aspects.py:1594: in assertDeprecation
    self.assertDeprecationFile(self.expect_warning_filename)
tests/aspects.py:1637: in assertDeprecationFile
    % (filename, item))
E   AssertionError: expected warning filename /home/travis/build/wikimedia/pywikibot/tests/site_tests.py; warning item: {message : ResourceWarning("unclosed <socket.socket fd=8, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('172.17.0.3', 59372), raddr=('208.80.154.224', 443)>",), category : 'ResourceWarning', filename : '/opt/python/3.4.6/lib/python3.4/socket.py', lineno : 451, line : None}

Details

Related Gerrit Patches:

Revisions and Commits

Event Timeline

Xqt created this task.Dec 26 2017, 11:24 AM
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptDec 26 2017, 11:24 AM
Xqt triaged this task as Medium priority.Dec 26 2017, 11:24 AM
Xqt claimed this task.Dec 26 2017, 12:10 PM

Change 400228 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Ignore foreign package warnings

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

Xqt added a comment.Dec 26 2017, 12:22 PM

This also occured in tests.site_tests.TestSiteObjectDeprecatedFunctions.test_allpages_filterredir_False
Maybe we should always ignore those socket warnings

Dalba added a comment.EditedDec 26 2017, 12:47 PM

This seems to be a problem in requests package and they are doing it intentionally. See Lukasa comment on issue 3912.

This also occured in tests.site_tests.TestSiteObjectDeprecatedFunctions.test_allpages_filterredir_False
Maybe we should always ignore those socket warnings

Either that, or, if possible and easy enough, we should find a way to always close requests sessions properly.

Xqt added a comment.Dec 26 2017, 12:56 PM

I did the first one because it was easier to solve instead of digging deeper to find the corresponding requests to close.

Change 400228 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Ignore unclosed socket warnings

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

Dalba closed this task as Resolved.Jan 8 2018, 4:43 PM

🎄