changeset 515:9ddab670f8c4

how binding works
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 18 Sep 2013 12:45:13 -0700
parents 1303f1f90a90
children c78da6f7ca79
files python/example/howbindingworks.py
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/example/howbindingworks.py	Wed Sep 18 12:45:13 2013 -0700
@@ -0,0 +1,25 @@
+def environment():
+    print 'hi'
+
+class Foo(object):
+    environment = environment
+
+foo = Foo()
+
+class Bar(object):
+    def __init__(self):
+        self.environment = environment
+bar = Bar()
+
+import unittest
+class TestBinding(unittest.TestCase):
+    """weird!"""
+    def test_binding(self):
+        self.assertEqual(foo.environment, environment)
+    def test_class_level(self):
+        self.assertEqual(Foo.environment, environment)
+    def test_on_init(self):
+        self.assertEqual(bar.environment, environment)
+
+if __name__ == '__main__':
+    unittest.main()