]> Devi Nivas Git - chevron.git/commitdiff
Add test for keys not in __dict__
authorMax Bernstein <emacs@fb.com>
Sat, 2 Jan 2021 18:19:19 +0000 (10:19 -0800)
committerMax Bernstein <emacs@fb.com>
Sat, 2 Jan 2021 18:47:06 +0000 (10:47 -0800)
See https://github.com/noahmorrison/chevron/pull/87

test_spec.py

index ad19d8b278f16a8eb0686bd02f7778904dedcfa3..08ee2ecce6a65a8714f81c079f4c85fa5c05230c 100755 (executable)
@@ -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__":