From bd112a2385d089d349e86db61cffa9965cbb42e2 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 16 Jun 2023 14:04:42 +0200 Subject: [PATCH] docs/usage.rst: Fix assertions Symptom was: > Traceback (most recent call last): > File "/tmp/tmp.kJAKlLngAX/foo.py", line 6, in > assert 'Example domains' in response > TypeError: a bytes-like object is required, not 'str' --- docs/usage.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 48fd0d2..64537ff 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -8,7 +8,7 @@ Usage with vcr.use_cassette('fixtures/vcr_cassettes/synopsis.yaml'): response = urllib.request.urlopen('http://www.iana.org/domains/reserved').read() - assert 'Example domains' in response + assert b'Example domains' in response Run this test once, and VCR.py will record the HTTP request to ``fixtures/vcr_cassettes/synopsis.yaml``. Run it again, and VCR.py will @@ -26,7 +26,7 @@ look like this: @vcr.use_cassette('fixtures/vcr_cassettes/synopsis.yaml') def test_iana(): response = urllib.request.urlopen('http://www.iana.org/domains/reserved').read() - assert 'Example domains' in response + assert b'Example domains' in response When using the decorator version of ``use_cassette``, it is possible to omit the path to the cassette file. @@ -36,7 +36,7 @@ omit the path to the cassette file. @vcr.use_cassette() def test_iana(): response = urllib.request.urlopen('http://www.iana.org/domains/reserved').read() - assert 'Example domains' in response + assert b'Example domains' in response In this case, the cassette file will be given the same name as the test function, and it will be placed in the same directory as the file in