diff python/example/howbindingworks.py @ 515:9ddab670f8c4

how binding works
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 18 Sep 2013 12:45:13 -0700
parents
children
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()