VCR doesn't replay cassettes in the same order they were played in.
Wyko opened this issue · comments
Wyko commented
I'm using pytest-recording
.
When running a test that uses multiple identical requests, VCR will always replay the first entry, rather than playing them in order. This causes a lot of my tests to fail unexpectedly during playback.
Example:
import httpx
import pytest
from pytest_httpserver import HTTPServer
@pytest.mark.vcr(allow_playback_repeats=False, match_on=["method", "uri"], record_mode="new_episodes")
def test_two_identical_requests_return_different_results(httpserver: HTTPServer) -> None:
"""Test that we can log out of the LTM API."""
httpserver.expect_ordered_request("/foo", method="GET").respond_with_data("bar")
httpserver.expect_ordered_request("/foo", method="GET").respond_with_data("whee")
with httpx.Client() as client:
response = client.get(httpserver.url_for("/foo"))
assert response.text == "bar"
response = client.get(httpserver.url_for("/foo"))
assert response.text == "whee"
Wyko commented
Ah, match parameters were wrong here. Ignore.