]> git.ipfire.org Git - thirdparty/patchwork.git/commit
tests: Close XML-RPC client when done
authorStephen Finucane <stephen@that.guru>
Thu, 9 Apr 2020 09:46:13 +0000 (10:46 +0100)
committerStephen Finucane <stephen@that.guru>
Thu, 9 Apr 2020 09:49:23 +0000 (10:49 +0100)
commita2b08509275be5ab08d61e54fa2e430cef0b3442
tree87145161296d77cf07afc52d1cdf2cf7c85df4c7
parentabfd2df5485d313a2835b60afdeb40731448b5b0
tests: Close XML-RPC client when done

This resolves the following irritating warnings that were popping up on
Python 3.7 and 3.8 and were silenced on 3.6:

  /usr/lib/python3.7/unittest/suite.py:107: ResourceWarning: unclosed <socket.socket ...>

Note that we need to use a subclass because the 'ServerProxy' class,
rather annoyingly, does not expose a 'close()' method. Instead, you're
expected to use a context manager, which isn't useful from the context
of a 'setUp' call. We could call '__enter__' and '__exit__' manually but
this seems cleaner. Also note that 'Server' was an alias of
'ServerProxy' [1], and we're taking the opportunity to switch here.

[1] https://docs.python.org/3/library/xmlrpc.client.html#xmlrpc.client.ServerProxy

Signed-off-by: Stephen Finucane <stephen@that.guru>
patchwork/tests/test_xmlrpc.py
tox.ini