From 64c56911941b80fefceb72502c245759ef5c4663 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Sat, 2 Jan 2021 10:19:19 -0800 Subject: [PATCH] Add test for keys not in __dict__ See https://github.com/noahmorrison/chevron/pull/87 --- test_spec.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test_spec.py b/test_spec.py index ad19d8b..08ee2ec 100755 --- a/test_spec.py +++ b/test_spec.py @@ -466,6 +466,22 @@ class ExpandedCoverage(unittest.TestCase): self.assertEqual(result, expected) + def test_get_key_not_in_dunder_dict_returns_attribute(self): + class C: + foo = "bar" + + instance = C() + self.assertTrue("foo" not in instance.__dict__) + + args = { + 'template': '{{foo}}', + 'data': instance + } + result = chevron.render(**args) + expected = 'bar' + + self.assertEqual(result, expected) + # Run unit tests from command line if __name__ == "__main__": -- 2.47.3