Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support VCR.py >=5 (fixes #111) #118

Merged
merged 4 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Changelog
-------------

- Drop support for Python 3.5 and 3.6. `#97`_
- Add support for VCR.py 5.0.0. `#118`_

`0.12.2`_ - 2023-02-16
----------------------
Expand Down Expand Up @@ -208,6 +209,7 @@ Added
.. _0.3.0: https://github.com/kiwicom/pytest-recording/compare/v0.2.0...v0.3.0
.. _0.2.0: https://github.com/kiwicom/pytest-recording/compare/v0.1.0...v0.2.0

.. _#118: https://github.com/kiwicom/pytest-recording/pull/118
.. _#99: https://github.com/kiwicom/pytest-recording/pull/99
.. _#97: https://github.com/kiwicom/pytest-recording/issues/97
.. _#82: https://github.com/kiwicom/pytest-recording/pull/82
Expand Down
13 changes: 12 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@

from setuptools import find_packages, setup

install_requires = ["vcrpy>=2.0.1,<5", "pytest>=3.5.0", "attrs"]
install_requires = ["vcrpy>=2.0.1", "pytest>=3.5.0", "attrs"]
tests_require = [
"pytest-httpbin",
"pytest-mock",
"requests",
"Werkzeug==2.0.3", # https://github.com/kevin1024/pytest-httpbin/issues/72
]
extras_require = {
"test": tests_require,
}


def read(fname):
Expand All @@ -28,6 +37,8 @@ def read(fname):
package_dir={"": "src"},
python_requires=">=3.5",
install_requires=install_requires,
tests_require=tests_require,
extras_require=extras_require,
classifiers=[
"Development Status :: 4 - Beta",
"Framework :: Pytest",
Expand Down
9 changes: 8 additions & 1 deletion src/pytest_recording/_vcr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
from vcr.persisters.filesystem import FilesystemPersister
from vcr.serialize import deserialize

try:
# VCR.py >=5
from vcr.cassette import CassetteNotFoundError
except ImportError:
# VCR.py <5
CassetteNotFoundError = ValueError

from .utils import unique, unpack

ConfigType = Dict[str, Any]
Expand Down Expand Up @@ -49,7 +56,7 @@ def load_cassette( # pylint: disable=arguments-differ
requests, responses = starmap(unpack, zip(*all_content))
requests, responses = list(requests), list(responses)
if not requests or not responses:
raise ValueError("No cassettes found.")
raise CassetteNotFoundError("No cassettes found.")
return requests, responses


Expand Down
2 changes: 2 additions & 0 deletions tests/test_replaying.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_combined():
result.assert_outcomes(passed=1)


@pytest.mark.skipif(VCR_VERSION >= (5, 0, 0), reason="TODO Test needs a re-write for VCR.py >=5")
def test_merged_kwargs(testdir, get_response_cassette):
# When there are multiple pytest.mark.vcr with different kwargs
testdir.makepyfile(
Expand Down Expand Up @@ -249,6 +250,7 @@ def test_own():
result.assert_outcomes(passed=1)


@pytest.mark.skipif(VCR_VERSION >= (5, 0, 0), reason="TODO Test needs a re-write for VCR.py >=5")
@pytest.mark.parametrize("scope", ("function", "module", "session"))
def test_global_config(testdir, get_response_cassette, scope):
# When a test doesn't have its own mark
Expand Down