From: Max Bernstein Date: Sat, 2 Jan 2021 18:19:19 +0000 (-0800) Subject: Add test for keys not in __dict__ X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=64c56911941b80fefceb72502c245759ef5c4663;p=chevron.git Add test for keys not in __dict__ See https://github.com/noahmorrison/chevron/pull/87 --- 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__":