Commits

Olemis Lang committed b276c16

GViz QL : Rewrite some tests for malformed queries.

gvizql.py Total tests : 62 , Failures : 2 , Errors : 9

  • Participants
  • Parent commits 0a24e95
  • Branches gviz_ql

Comments (0)

Files changed (2)

trac-dev/gviz/tracgviz/testing/test_gvizql.py

       *****
       * Parsing
       *****
-      Syntax error or unsupported feature. Unexpected token <EOL>.
+      Unexpected token <EOL>.
 
       >>> parse("  select 7group ", 'cols', fail=True)
       *****
       *****
       * Parsing
       *****
-      Syntax error or unsupported feature. Unexpected token 7group.
+      Unexpected token 7group.
 
       >>> parse("  select $group ", 'cols', fail=True)
       *****
       *****
       * Parsing
       *****
-      Syntax error or unsupported feature. Unexpected token $.
+      Unexpected token $.
 
       >>> parse("  select group ", 'cols', fail=True)
       *****
       *****
       * Parsing
       *****
-      Syntax error or unsupported feature. Unexpected token group.
+      Unexpected token group.
       """
   }

trac-dev/gviz/tracgviz/util/parsing.py

     r"""Initialize with empty precendence table and skeletal grammar.
     """
     self.set_productions()
+    self.verbose = False
 
   def set_productions(self, start_state=None, *productions):
     r"""Rebuild precedence and production look up tree according to 
             (self.precedence.get(c) for c in candidates)).next()
       except StopIteration:
         if tkn is EndMarker:
-          raise SyntaxError("Unexpected EOL\n\n" + str(pushdown_list) )
+          raise SyntaxError("Unexpected EOL" + 
+              ("\n\n" + str(pushdown_list) if self.verbose else "") )
         else:
-          raise SyntaxError("Unexpected token %s\n\n%s" % (val, pushdown_list) )
+          raise SyntaxError("Unexpected token %s.%s" % (val, 
+              ("\n\n" + unicode(pushdown_list) if self.verbose else "") ) )
       else:
         logging.debug('Precedence %s,%s |--> %s,%s: %s', 
             last_tkn, last_val, tkn, val, precedence)
         try:
           prod_id, args = self._match_production(pushdown_list)
         except LookupError:
-          raise SyntaxError('Unexpected token %s\n\n%s' % 
-              (last_val, pushdown_list))
+          raise SyntaxError('Unexpected token %s.%s' % 
+              (last_val, ("\n\n" + pushdown_list if self.verbose else "") ) )
         pushdown_list.append((NonTerminal, on_reduce(prod_id, *args)))
         last_tkn, last_val = pushdown_list[-1]
       else: