# HG changeset patch # User Jeff Hammel # Date 1379533513 25200 # Node ID 9ddab670f8c46073c69c067068982bc03b19a859 # Parent 1303f1f90a90dc73908af537d59b65f31e428ef8 how binding works diff -r 1303f1f90a90 -r 9ddab670f8c4 python/example/howbindingworks.py --- /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()