1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 09:13:23 +00:00

Fix failing unit test on Windows

test_xmlrpclib was failing with "can't pickle thread.lock objects" on Windows.
Other small issues were related to backslashes in paths and different line endings.
This commit is contained in:
Martin Valgur
2018-09-06 19:10:05 +03:00
parent aff71c5107
commit 895850b197
4 changed files with 14 additions and 7 deletions

View File

@@ -254,7 +254,7 @@ def test_nested_cassettes_with_session_created_before_nesting(httpbin_both, tmpd
def test_post_file(tmpdir, httpbin_both):
'''Ensure that we handle posting a file.'''
url = httpbin_both + '/post'
with vcr.use_cassette(str(tmpdir.join('post_file.yaml'))) as cass, open('tox.ini') as f:
with vcr.use_cassette(str(tmpdir.join('post_file.yaml'))) as cass, open('tox.ini', 'rb') as f:
original_response = requests.post(url, f).content
# This also tests that we do the right thing with matching the body when they are files.

View File

@@ -81,16 +81,23 @@ def test_amazon_doctype(tmpdir):
assert 'html' in r.text
def start_rpc_server(q):
httpd = xmlrpc_server.SimpleXMLRPCServer(('127.0.0.1', 0))
httpd.register_function(pow)
q.put('http://{}:{}'.format(*httpd.server_address))
httpd.serve_forever()
@pytest.yield_fixture(scope='session')
def rpc_server():
httpd = xmlrpc_server.SimpleXMLRPCServer(('', 0))
httpd.register_function(pow)
q = multiprocessing.Queue()
proxy_process = multiprocessing.Process(
target=httpd.serve_forever,
target=start_rpc_server,
args=(q,)
)
try:
proxy_process.start()
yield 'http://{}:{}'.format(*httpd.server_address)
yield q.get()
finally:
proxy_process.terminate()

View File

@@ -5,7 +5,7 @@ from vcr.request import Request, HeadersDict
def test_str():
req = Request('GET', 'http://www.google.com/', '', {})
str(req) == '<Request (GET) http://www.google.com/>'
assert str(req) == '<Request (GET) http://www.google.com/>'
def test_headers():

View File

@@ -147,7 +147,7 @@ def test_vcr_path_transformer():
# and it should still work with cassette_library_dir
vcr = VCR(cassette_library_dir='/foo')
with vcr.use_cassette('test') as cassette:
assert cassette._path == '/foo/test'
assert os.path.abspath(cassette._path) == os.path.abspath('/foo/test')
@pytest.fixture