Skip to content

Commit

Permalink
fix #429: include a trailing newline in the JSON cassette format
Browse files Browse the repository at this point in the history
It is a common convention for text files (esp. in Linux) to end with a newline.
  • Loading branch information
AaronRobson authored and kevin1024 committed Aug 5, 2020
1 parent a351621 commit 1d0fdba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/integration/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def test_set_serializer_default_config(tmpdir, httpbin):
urlopen(httpbin.url + "/get")

with open(str(tmpdir.join("test.json"))) as f:
assert json.loads(f.read())
file_content = f.read()
assert file_content.endswith("\n")
assert json.loads(file_content)


def test_default_set_cassette_library_dir(tmpdir, httpbin):
Expand Down
2 changes: 1 addition & 1 deletion vcr/serializers/jsonserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def serialize(cassette_dict):
)

try:
return json.dumps(cassette_dict, indent=4)
return json.dumps(cassette_dict, indent=4) + "\n"
except UnicodeDecodeError as original: # py2
raise UnicodeDecodeError(
original.encoding,
Expand Down

0 comments on commit 1d0fdba

Please sign in to comment.