mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 00:22:04 +02:00
Avoid trailing whitespace in pretty-printed JSON
Fixes a failing test on Python 3.3:
======================================================================
FAIL: test_json_dumps_pretty (acme.jose.interfaces_test.JSONDeSerializableTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mg/src/letsencrypt/acme/acme/jose/interfaces_test.py", line 97, in test_json_dumps_pretty
'[\n "foo1",{0}\n "foo2"\n]'.format(filler))
AssertionError: '[\n "foo1", \n "foo2"\n]' != '[\n "foo1",\n "foo2"\n]'
[
- "foo1",
? -
+ "foo1",
"foo2"
]
----------------------------------------------------------------------
(The test expected trailing whitespace on Python < 3.0, while it
should've been checking for Python < 3.4.)
This commit is contained in:
@@ -194,7 +194,7 @@ class JSONDeSerializable(object):
|
|||||||
:rtype: str
|
:rtype: str
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.json_dumps(sort_keys=True, indent=4)
|
return self.json_dumps(sort_keys=True, indent=4, separators=(',', ': '))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def json_dump_default(cls, python_object):
|
def json_dump_default(cls, python_object):
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
"""Tests for acme.jose.interfaces."""
|
"""Tests for acme.jose.interfaces."""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
|
|
||||||
class JSONDeSerializableTest(unittest.TestCase):
|
class JSONDeSerializableTest(unittest.TestCase):
|
||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes
|
||||||
@@ -92,9 +90,8 @@ class JSONDeSerializableTest(unittest.TestCase):
|
|||||||
self.assertEqual('["foo1", "foo2"]', self.seq.json_dumps())
|
self.assertEqual('["foo1", "foo2"]', self.seq.json_dumps())
|
||||||
|
|
||||||
def test_json_dumps_pretty(self):
|
def test_json_dumps_pretty(self):
|
||||||
filler = ' ' if six.PY2 else ''
|
|
||||||
self.assertEqual(self.seq.json_dumps_pretty(),
|
self.assertEqual(self.seq.json_dumps_pretty(),
|
||||||
'[\n "foo1",{0}\n "foo2"\n]'.format(filler))
|
'[\n "foo1",\n "foo2"\n]')
|
||||||
|
|
||||||
def test_json_dump_default(self):
|
def test_json_dump_default(self):
|
||||||
from acme.jose.interfaces import JSONDeSerializable
|
from acme.jose.interfaces import JSONDeSerializable
|
||||||
|
|||||||
Reference in New Issue
Block a user