3
0
Fork 0

fix: add get_value() convenience function

This commit is contained in:
Lance Edgar 2026-02-16 18:11:11 -06:00
parent fb1a7b22d8
commit 5ec0a8e82d
5 changed files with 102 additions and 1 deletions

View file

@ -48,6 +48,32 @@ class TestAppHandler(FileTestCase):
def test_get_enum(self):
self.assertIs(self.app.get_enum(), wuttjamaican.enum)
def test_get_value(self):
class Object:
def __init__(self, **kw):
self.__dict__.update(kw)
class Dict(dict):
pass
# dict object
obj = {"foo": "bar"}
self.assertEqual(self.app.get_value(obj, "foo"), "bar")
# object w/ attrs
obj = Object(foo="bar")
self.assertEqual(self.app.get_value(obj, "foo"), "bar")
# dict-like w/ attrs
obj = Dict({"foo": "bar"})
obj.baz = "yyy"
self.assertEqual(self.app.get_value(obj, "baz"), "yyy")
# missing attr
obj = Object(foo="bar")
self.assertRaises(AttributeError, self.app.get_value, obj, "baz")
def test_load_object(self):
# just confirm the method works on a basic level; the