fix: improve JSON-safe rendering for sets
This commit is contained in:
parent
22a1c99abe
commit
634c1b1fe5
2 changed files with 31 additions and 0 deletions
|
|
@ -735,6 +735,30 @@ class TestMakeJsonSafe(TestCase):
|
|||
],
|
||||
)
|
||||
|
||||
def test_set(self):
|
||||
model = self.app.model
|
||||
person = model.Person(full_name="Betty Boop")
|
||||
|
||||
data = {
|
||||
"foo",
|
||||
"bar",
|
||||
person,
|
||||
}
|
||||
|
||||
self.assertRaises(TypeError, json.dumps, data)
|
||||
value = mod.make_json_safe(data)
|
||||
self.assertNotIsInstance(value, set)
|
||||
self.assertIsInstance(value, list)
|
||||
# nb. must sort values, otherwise comparison may fail
|
||||
self.assertEqual(
|
||||
sorted(value),
|
||||
[
|
||||
"Betty Boop", # nb. upper-case sorts first
|
||||
"bar",
|
||||
"foo",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class TestRenderVueFinalize(TestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue