From 4b2b5a1b0ad1229e6051578021eb5688f3627eba Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 24 Aug 2022 14:17:40 -0700 Subject: [PATCH] make sure json encoding fails on unhandled classes.. --- ui/medashare/cli.py | 7 +++++++ ui/medashare/tests.py | 1 + 2 files changed, 8 insertions(+) diff --git a/ui/medashare/cli.py b/ui/medashare/cli.py index ce655e0..d61dad9 100644 --- a/ui/medashare/cli.py +++ b/ui/medashare/cli.py @@ -278,6 +278,13 @@ class _JSONEncoder(json.JSONEncoder): _jsonencoder = _JSONEncoder() +class _TestJSONEncoder(unittest.TestCase): + def test_defaultfailure(self): + class Foo: + pass + + self.assertRaises(TypeError, _jsonencoder.encode, Foo()) + class Persona(object): '''The object that represents a persona, or identity. It will create the proper identity object, serialize for saving keys, diff --git a/ui/medashare/tests.py b/ui/medashare/tests.py index 93147be..db68722 100644 --- a/ui/medashare/tests.py +++ b/ui/medashare/tests.py @@ -1,3 +1,4 @@ from .cli import _TestCononicalCoder, _TestCases as cli_test_cases +from .cli import _TestJSONEncoder from .mtree import Test from .server import _TestCases, _TestPostConfig