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

Compare commits

...

6 Commits

Author SHA1 Message Date
Kevin McCarthy
c79a06f639 release version 4.1.1 2020-10-09 15:38:37 -05:00
Jair Henrique
4991d3d22b Fix tornado tests 2020-10-05 09:45:55 -05:00
Jair Henrique
b2193828ab Fix matrix of tests 2020-10-05 09:45:55 -05:00
Jair Henrique
9d414c8841 Fix lint erros 2020-10-05 09:45:55 -05:00
Jair Henrique
a172207df0 Fix integration with httpx>0.15.0 2020-10-05 09:45:55 -05:00
Aaron Robson
1d0fdbaa13 fix #429: include a trailing newline in the JSON cassette format
It is a common convention for text files (esp. in Linux) to end with a newline.
2020-08-05 17:27:30 -05:00
12 changed files with 28 additions and 30 deletions

View File

@@ -1,33 +1,26 @@
dist: xenial
language: python
before_install: openssl version
env:
# global:
# - secure: AifoKzwhjV94cmcQZrdQmqRu/9rkZZvWpwBv1daeAQpLOKFPGsOm3D+x2cSw9+iCfkgDZDfqQVv1kCaFVxTll8v8jTq5SJdqEY0NmGWbj/UkNtShh609oRDsuzLxAEwtVKYjf/h8K2BRea+bl1tGkwZ2vtmYS6dxNlAijjWOfds=
# - secure: LBSEg/gMj4u4Hrpo3zs6Y/1mTpd2RtcN49mZIFgTdbJ9IhpiNPqcEt647Lz94F9Eses2x2WbNuKqZKZZReY7QLbEzU1m0nN5jlaKrjcG5NR5clNABfFFyhgc0jBikyS4abAG8jc2efeaTrFuQwdoF4sE8YiVrkiVj2X5Xoi6sBk=
matrix:
- TOX_SUFFIX="requests"
- TOX_SUFFIX="httplib2"
- TOX_SUFFIX="boto3"
- TOX_SUFFIX="urllib3"
- TOX_SUFFIX="tornado4"
- TOX_SUFFIX="aiohttp"
- TOX_SUFFIX="httpx"
matrix:
include:
# Only run lint on a single 3.x
- env: TOX_SUFFIX="lint"
python: "3.7"
python:
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "pypy3"
before_install:
- openssl version
- sudo apt-get install libgnutls28-dev
install:
- pip install tox-travis codecov
- if [[ $TOX_SUFFIX != 'lint' ]]; then python setup.py install ; fi
script:
- tox -e "${TOX_SUFFIX}"
- tox
after_success:
- codecov

View File

@@ -7,6 +7,9 @@ For a full list of triaged issues, bugs and PRs and what release they are target
All help in providing PRs to close out bug issues is appreciated. Even if that is providing a repo that fully replicates issues. We have very generous contributors that have added these to bug issues which meant another contributor picked up the bug and closed it out.
- 4.1.1
- Fix HTTPX support for versions greater than 0.15 (thanks @jairhenrique)
- Include a trailing newline on json cassettes (thanks @AaronRobson)
- 4.1.0
- Add support for httpx!! (thanks @herdigiorgi)
- Add the new `allow_playback_repeats` option (thanks @tysonholub)

View File

@@ -4,4 +4,4 @@
# If you are getting an INVOCATION ERROR for this script then there is
# a good chance you are running on Windows.
# You can and should use WSL for running tox on Windows when it calls bash scripts.
REQUESTS_CA_BUNDLE=`python -m pytest_httpbin.certs` py.test $*
REQUESTS_CA_BUNDLE=`python -m pytest_httpbin.certs` pytest $*

View File

@@ -292,9 +292,9 @@ def test_not_modified(aiohttp_client, tmpdir):
def test_double_requests(tmpdir):
"""We should capture, record, and replay all requests and response chains,
even if there are duplicate ones.
even if there are duplicate ones.
We should replay in the order we saw them.
We should replay in the order we saw them.
"""
url = "https://httpbin.org/get"

View File

@@ -13,7 +13,9 @@ def test_set_serializer_default_config(tmpdir, httpbin):
urlopen(httpbin.url + "/get")
with open(str(tmpdir.join("test.json"))) as f:
assert json.loads(f.read())
file_content = f.read()
assert file_content.endswith("\n")
assert json.loads(file_content)
def test_default_set_cassette_library_dir(tmpdir, httpbin):

View File

@@ -12,7 +12,7 @@ from vcr.persisters.filesystem import FilesystemPersister
class CustomFilesystemPersister(object):
"""Behaves just like default FilesystemPersister but adds .test extension
to the cassette file"""
to the cassette file"""
@staticmethod
def load_cassette(cassette_path, serializer):

View File

@@ -90,10 +90,10 @@ def test_body(get_client, tmpdir, scheme):
@pytest.mark.gen_test
def test_effective_url(get_client, scheme, tmpdir):
"""Ensure that the effective_url is captured"""
url = scheme + "://httpbin.org/redirect-to?url=/html"
url = scheme + "://mockbin.org/redirect/301?url=/html"
with vcr.use_cassette(str(tmpdir.join("url.yaml"))):
effective_url = (yield get(get_client(), url)).effective_url
assert effective_url == scheme + "://httpbin.org/html"
assert effective_url == scheme + "://mockbin.org/redirect/301/0"
with vcr.use_cassette(str(tmpdir.join("url.yaml"))) as cass:
assert effective_url == (yield get(get_client(), url)).effective_url
@@ -156,7 +156,7 @@ def test_post(get_client, tmpdir, scheme):
@pytest.mark.gen_test
def test_redirects(get_client, tmpdir, scheme):
"""Ensure that we can handle redirects"""
url = scheme + "://httpbin.org/redirect-to?url=bytes/1024"
url = scheme + "://mockbin.org/redirect/301?url=bytes/1024"
with vcr.use_cassette(str(tmpdir.join("requests.yaml"))):
content = (yield get(get_client(), url)).body

View File

@@ -80,6 +80,7 @@ deps =
aiohttp: aiohttp
aiohttp: pytest-asyncio
aiohttp: pytest-aiohttp
httpx: httpx
{py36,py37,py38}-{httpx}: httpx
{py36,py37,py38}-{httpx}: pytest-asyncio
depends =

View File

@@ -3,7 +3,7 @@ from .config import VCR
from logging import NullHandler
from .record_mode import RecordMode as mode # noqa import is not used in this file
__version__ = "4.1.0"
__version__ = "4.1.1"
logging.getLogger(__name__).addHandler(NullHandler())

View File

@@ -16,7 +16,7 @@ def serialize(cassette_dict):
)
try:
return json.dumps(cassette_dict, indent=4)
return json.dumps(cassette_dict, indent=4) + "\n"
except UnicodeDecodeError as original: # py2
raise UnicodeDecodeError(
original.encoding,

View File

@@ -91,9 +91,9 @@ def build_response(vcr_request, vcr_response, history):
def _serialize_headers(headers):
"""Serialize CIMultiDictProxy to a pickle-able dict because proxy
objects forbid pickling:
objects forbid pickling:
https://github.com/aio-libs/multidict/issues/340
https://github.com/aio-libs/multidict/issues/340
"""
# Mark strings as keys so 'istr' types don't show up in
# the cassettes as comments.
@@ -170,9 +170,9 @@ async def record_response(cassette, vcr_request, response):
async def record_responses(cassette, vcr_request, response):
"""Because aiohttp follows redirects by default, we must support
them by default. This method is used to write individual
request-response chains that were implicitly followed to get
to the final destination.
them by default. This method is used to write individual
request-response chains that were implicitly followed to get
to the final destination.
"""
for past_response in response.history:

View File

@@ -52,7 +52,6 @@ def _from_serialized_response(request, serialized_response, history=None):
response = httpx.Response(
status_code=serialized_response.get("status_code"),
request=request,
http_version=serialized_response.get("http_version"),
headers=_from_serialized_headers(serialized_response.get("headers")),
content=content,
history=history or [],