registry.Json: Fix broken test due to returning the internal state directly

This commit is contained in:
Valentin Lorentz 2025-04-06 10:19:17 +02:00
parent c795cdc655
commit c81ff28697
2 changed files with 6 additions and 3 deletions

View File

@ -31,6 +31,7 @@
import re import re
import os import os
import copy
import time import time
import json import json
import codecs import codecs
@ -921,6 +922,8 @@ class TemplatedString(String):
class Json(String): class Json(String):
__slots__ = () __slots__ = ()
def __call__(self):
return copy.deepcopy(super(Json, self).__call__())
def set(self, v): def set(self, v):
self.setValue(json.loads(v)) self.setValue(json.loads(v))
def __str__(self): def __str__(self):

View File

@ -140,13 +140,13 @@ class ValuesTestCase(SupyTestCase):
self.assertIsNot(v(), data) self.assertIsNot(v(), data)
with v.editable() as dict_: with v.editable() as dict_:
dict_['supy'] = 'bot' dict_['supy'] = ['bot']
del dict_['qux'] del dict_['qux']
self.assertNotIn('supy', v()) self.assertNotIn('supy', v())
self.assertIn('qux', v()) self.assertIn('qux', v())
self.assertIn('supy', v()) self.assertIn('supy', v())
self.assertEqual(v()['supy'], 'bot') self.assertEqual(v()['supy'], ['bot'])
self.assertIsNot(v()['supy'], 'bot') self.assertIsNot(v()['supy'], ['bot'])
self.assertNotIn('qux', v()) self.assertNotIn('qux', v())
def testNormalizedString(self): def testNormalizedString(self):