import unittest
from util import eval_code, eval_raises_code

class test_opcodes_attrs(unittest.TestCase):
    def test_load_attr(self):
        self.failUnless(eval_code("__name__.lower.__name__","'lower'\n",title="test_opcodes_attrs: __name__.lower.__name__"))
        self.failUnless(eval_code("def foo():\n\tpass\n\nfoo.b='111'\nprint foo.b\n\n","111\n", "exec",title="test_opcodes_attrs: foo.b"))

    def test_bad_attr(self):
        self.failUnlessRaises(AttributeError, eval_raises_code,"x=1;x.b=1")
    
if __name__ == "__main__":
    unittest.main()

