kevin1024 / vcrpy

Automatically mock your HTTP interactions to simplify and speed up testing
MIT License
2.72k stars 388 forks source link

Fix docs/usage.rst code examples #717

Closed hartwork closed 1 year ago

hartwork commented 1 year ago

Hi! :wave:

When running the example from…

https://github.com/kevin1024/vcrpy/blob/e3aae34ef7bf45f01ebff19fe72757c30a847735/docs/usage.rst?plain=1#L6-L11

…I get two errors:

The first is:

Traceback (most recent call last):
  File "/tmp/tmp.kJAKlLngAX/foo.py", line 5, in <module>
    response = urllib.request.urlopen('http://www.iana.org/domains/reserved').read()
AttributeError: module 'urllib' has no attribute 'request'

After fixing the import, the second is:

Traceback (most recent call last):
  File "/tmp/tmp.kJAKlLngAX/foo.py", line 6, in <module>
    assert 'Example domains' in response
TypeError: a bytes-like object is required, not 'str'

This pull request fixes both of these issues.

codecov-commenter commented 1 year ago

Codecov Report

Merging #717 (71415d0) into master (e3aae34) will not change coverage. The diff coverage is n/a.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@           Coverage Diff           @@
##           master     #717   +/-   ##
=======================================
  Coverage   90.30%   90.30%           
=======================================
  Files          28       28           
  Lines        1774     1774           
  Branches      313      313           
=======================================
  Hits         1602     1602           
  Misses        137      137           
  Partials       35       35           

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more