From 2a128893cc3e7686a97d5d15d9ebb77c947f7b7d Mon Sep 17 00:00:00 2001 From: Nithin Reddy Date: Fri, 21 Nov 2014 09:47:28 -0800 Subject: [PATCH] Adds a test to ensure that the cassette created with "new_episodes" has different expected behavior when opened with "once". --- tests/integration/test_record_mode.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/integration/test_record_mode.py b/tests/integration/test_record_mode.py index f658adf..4424f97 100644 --- a/tests/integration/test_record_mode.py +++ b/tests/integration/test_record_mode.py @@ -87,6 +87,22 @@ def test_new_episodes_record_mode_two_times(tmpdir): response = urlopen('http://httpbin.org/').read() +def test_once_mode_after_new_episodes(tmpdir): + testfile = str(tmpdir.join('recordmode.yml')) + with vcr.use_cassette(testfile, record_mode="new_episodes"): + # cassette file doesn't exist, so create. + response1 = urlopen('http://httpbin.org/').read() + + with vcr.use_cassette(testfile, record_mode="once") as cass: + # make the same request again + response = urlopen('http://httpbin.org/').read() + + # now that we are back in once mode, this should raise + # an error. + with pytest.raises(Exception): + response = urlopen('http://httpbin.org/').read() + + def test_all_record_mode(tmpdir): testfile = str(tmpdir.join('recordmode.yml'))