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}

Revisions and Commits

Event Timeline

Xqt triaged this task as Medium priority.Dec 26 2017, 11:24 AM

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

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

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.

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