]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Fix compatibility with Python 3.7
authorFelix Yan <felixonmars@archlinux.org>
Sat, 21 Jul 2018 09:03:19 +0000 (17:03 +0800)
committerLuiz Menezes <luiz.menezesf@gmail.com>
Tue, 18 Sep 2018 18:04:43 +0000 (15:04 -0300)
setup.py
tests/integration/test_urllib2.py
vcr/cassette.py

index 3935af62e6266770e09219643a3063cd1030b3d2..65c07736b6fb8347223ddafbf17bca42c23199d9 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -62,6 +62,7 @@ setup(
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.7',
         'Programming Language :: Python :: Implementation :: CPython',
         'Programming Language :: Python :: Implementation :: PyPy',
         'Topic :: Software Development :: Testing',
index 8a633ba9041b8a349562fdaa2984cb8cec12f780..3c0b021dc15bbc688a37d3bf164e4f770fccb1bc 100644 (file)
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 '''Integration tests with urllib2'''
 
+import ssl
 from six.moves.urllib.request import urlopen
 from six.moves.urllib_parse import urlencode
 import pytest_httpbin.certs
@@ -12,7 +13,9 @@ from assertions import assert_cassette_has_one_response
 
 
 def urlopen_with_cafile(*args, **kwargs):
-    kwargs['cafile'] = pytest_httpbin.certs.where()
+    context = ssl.create_default_context(cafile=pytest_httpbin.certs.where())
+    context.check_hostname = False
+    kwargs['context'] = context
     try:
         return urlopen(*args, **kwargs)
     except TypeError:
index d64dec67a55e578b968567f566176ede2b633e9c..3b6f54ec695296239dcc992fe11a959b03183c9d 100644 (file)
@@ -136,7 +136,10 @@ class CassetteContextDecorator(object):
                 except Exception:
                     to_yield = coroutine.throw(*sys.exc_info())
                 else:
-                    to_yield = coroutine.send(to_send)
+                    try:
+                        to_yield = coroutine.send(to_send)
+                    except StopIteration:
+                        break
 
     def _handle_function(self, fn):
         with self as cassette: