def test_method_call_syntax(self): grammar = self._make_method_call_grammar() ok, result = grammar.start.parse('foo.bar(a, b)') if not ok: easyparse.print_backtrace(result) self.assertTrue(ok) self.assertEqual(['foo', 'bar', ('a', 'b')], result) self.assertFalse(grammar.start.parse('foo. bar(a)')[0]) self.assertFalse(grammar.start.parse('foo .bar(a)')[0]) self.assertTrue(grammar.start.parse('foo.bar( a)')[0])
def _print_backtrace_to_string(self, backtrace): s = StringIO() easyparse.print_backtrace(backtrace, fout=s) ret = s.getvalue() s.close() return ret