]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
update old cassette detection
authorKevin McCarthy <me@kevinmccarthy.org>
Wed, 7 May 2014 05:37:46 +0000 (19:37 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Sat, 10 May 2014 21:52:35 +0000 (11:52 -1000)
tests/fixtures/migration/new_cassette.json
tests/fixtures/migration/new_cassette.yaml
vcr/serialize.py

index c23262ea84221789ef62892eadd4cbe7535bdcb4..2b1bac6424aebfcdbe0e6667dd51ddd1742ac652 100644 (file)
@@ -1,31 +1,35 @@
-[
-    {
-        "request": {
-            "body": null,
-            "headers": {
-                "Accept": ["*/*"],
-                "Accept-Encoding": ["gzip, deflate, compress"],
-                "User-Agent": ["python-requests/2.2.1 CPython/2.6.1 Darwin/10.8.0"]
+{
+    "version": 1,
+    "interactions":
+    [
+        {
+            "request": {
+                "body": null,
+                "headers": {
+                    "Accept": ["*/*"],
+                    "Accept-Encoding": ["gzip, deflate, compress"],
+                    "User-Agent": ["python-requests/2.2.1 CPython/2.6.1 Darwin/10.8.0"]
+                },
+                "method": "GET",
+                "uri": "http://httpbin.org/ip"
             },
-            "method": "GET",
-            "uri": "http://httpbin.org/ip"
-        },
-        "response": {
-            "status": {
-                "message": "OK", 
-                "code": 200
-            }, 
-            "headers": {
-                "access-control-allow-origin": ["*"],
-                "content-type": ["application/json"],
-                "date": ["Mon, 21 Apr 2014 23:13:40 GMT"],
-                "server": ["gunicorn/0.17.4"],
-                "content-length": ["32"],
-                "connection": ["keep-alive"]
-            }, 
-            "body": {
-                "string": "{\n  \"origin\": \"217.122.164.194\"\n}"
+            "response": {
+                "status": {
+                    "message": "OK", 
+                    "code": 200
+                }, 
+                "headers": {
+                    "access-control-allow-origin": ["*"],
+                    "content-type": ["application/json"],
+                    "date": ["Mon, 21 Apr 2014 23:13:40 GMT"],
+                    "server": ["gunicorn/0.17.4"],
+                    "content-length": ["32"],
+                    "connection": ["keep-alive"]
+                }, 
+                "body": {
+                    "string": "{\n  \"origin\": \"217.122.164.194\"\n}"
+                }
             }
         }
-    }
-]
+    ]
+}
index 49a4e1a036c8a2a6dca66cb404b48fdf12c3fd5a..b76eef91848947f67f35007676260ff779aac6ca 100644 (file)
@@ -1,3 +1,5 @@
+version: 1
+interactions:
 - request:
     body: null
     headers: 
index d49a7da45e292d0dcaaca337d9811ec60868b3cc..36275b4a0fa109c09789e3e75b73c9a8e296e624 100644 (file)
@@ -19,6 +19,13 @@ Deserializing: string (yaml converts from utf-8) -> bytestring
 
 def deserialize(cassette_string, serializer):
     data = serializer.deserialize(cassette_string)
+    if not isinstance(data, dict):
+        raise ValueError(
+            "Your cassette files were generated in an older version "
+            "of VCR. Delete your cassettes or run the migration script."
+            "See http://git.io/mHhLBg for more details."
+        )
+
     requests = [Request._from_dict(r['request']) for r in data['interactions']]
     responses = [compat.convert_to_bytes(r['response']) for r in data['interactions']]
     return requests, responses