Exemple #1
0
 def _eval_name(self, node):
     lowernames = {k.lower(): v for k, v in self.names.items()}
     try:
         return lowernames[node.id.lower()]
     except KeyError:
         if node.id in self.functions:
             return self.functions[node.id]
     raise NameNotDefined(node.id, self.expr)
 def test_namenotdefined(self):
     try:
         raise NameNotDefined("foo", "foo in bar")
     except NameNotDefined as e:
         assert hasattr(e, 'name')
         assert getattr(e, 'name') == 'foo'
         assert hasattr(e, 'expression')
         assert getattr(e, 'expression') == 'foo in bar'