]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Remove dependency on bugs.python.org/xmlrpc: 301 Moved Permanently
authorHugo <hugovk@users.noreply.github.com>
Thu, 7 Dec 2017 14:18:09 +0000 (16:18 +0200)
committerHugo <hugovk@users.noreply.github.com>
Mon, 15 Jan 2018 07:54:11 +0000 (09:54 +0200)
tests/integration/test_wild.py

index a0a5a9a98787905ea0ef5286af4897e32bf44474..65c76e236a54c4d4d10957d82436a6ee35a35896 100644 (file)
@@ -1,5 +1,6 @@
+import multiprocessing
 import pytest
-from six.moves import xmlrpc_client
+from six.moves import xmlrpc_client, xmlrpc_server
 
 requests = pytest.importorskip("requests")
 
@@ -80,13 +81,27 @@ def test_amazon_doctype(tmpdir):
     assert 'html' in r.text
 
 
-def test_xmlrpclib(tmpdir):
+@pytest.yield_fixture(scope='session')
+def rpc_server():
+    httpd = xmlrpc_server.SimpleXMLRPCServer(('', 0))
+    httpd.register_function(pow)
+    proxy_process = multiprocessing.Process(
+        target=httpd.serve_forever,
+    )
+    try:
+        proxy_process.start()
+        yield 'http://{}:{}'.format(*httpd.server_address)
+    finally:
+        proxy_process.terminate()
+
+
+def test_xmlrpclib(tmpdir, rpc_server):
     with vcr.use_cassette(str(tmpdir.join('xmlrpcvideo.yaml'))):
-        roundup_server = xmlrpc_client.ServerProxy('http://bugs.python.org/xmlrpc', allow_none=True)
-        original_schema = roundup_server.schema()
+        roundup_server = xmlrpc_client.ServerProxy(rpc_server, allow_none=True)
+        original_schema = roundup_server.pow(2, 4)
 
     with vcr.use_cassette(str(tmpdir.join('xmlrpcvideo.yaml'))):
-        roundup_server = xmlrpc_client.ServerProxy('http://bugs.python.org/xmlrpc', allow_none=True)
-        second_schema = roundup_server.schema()
+        roundup_server = xmlrpc_client.ServerProxy(rpc_server, allow_none=True)
+        second_schema = roundup_server.pow(2, 4)
 
     assert original_schema == second_schema