Changeset: a545d928db63 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a545d928db63
Modified Files:
        testing/sqllogictest.py
Branch: default
Log Message:

Add "secret" --pdb option + some layout changes.


diffs (147 lines):

diff --git a/testing/sqllogictest.py b/testing/sqllogictest.py
--- a/testing/sqllogictest.py
+++ b/testing/sqllogictest.py
@@ -115,6 +115,7 @@ class SQLLogicConnection(object):
 def is_copyfrom_stmt(stmt:[str]=[]):
     return '<COPY_INTO_DATA>' in stmt
 
+
 def prepare_copyfrom_stmt(stmt:[str]=[]):
     index = stmt.index('<COPY_INTO_DATA>')
     head = stmt[:index]
@@ -133,9 +134,11 @@ def prepare_copyfrom_stmt(stmt:[str]=[])
     tail='\n'.join(tail)
     return head + '\n' + tail, head, stmt
 
+
 def dq(s):
     return s.replace('"', '""')
 
+
 class SQLLogic:
     def __init__(self, srcdir='.', report=None, out=sys.stdout):
         self.dbh = None
@@ -403,7 +406,7 @@ class SQLLogic:
             return ['statement', 'crash'] # should never be approved
         except KeyboardInterrupt:
             raise
-        except:
+        except Exception:
             type, value, traceback = sys.exc_info()
             self.query_error(statement, 'unexpected error from pymonetdb', 
str(value))
             return ['statement', 'error']
@@ -505,7 +508,8 @@ class SQLLogic:
             print("query text:", file=self.out)
             print(query, file=self.out)
 
-    def exec_query(self, query, columns, sorting, pyscript, hashlabel, 
nresult, hash, expected, conn=None, verbose=False) -> bool:
+    def exec_query(self, query, columns, sorting, pyscript, hashlabel, nresult,
+                   hash, expected, conn=None, verbose=False) -> bool:
         err = False
         crs = conn.cursor() if conn else self.crs
         if '<LAST_PREPARE_ID>' in query:
@@ -524,13 +528,15 @@ class SQLLogic:
             raise
         except TimeoutError as e:
             self.query_error(query, 'Timeout', str(e))
-            return ['statement', 'crash'] # should never be approved
+            return ['statement', 'crash']  # should never be approved
         except ConnectionError as e:
-            self.query_error(query, 'Timeout or server may have crashed', 
str(e))
-            return ['statement', 'crash'] # should never be approved
-        except:
+            self.query_error(query, 'Timeout or server may have crashed',
+                             str(e))
+            return ['statement', 'crash']  # should never be approved
+        except Exception:
             tpe, value, traceback = sys.exc_info()
-            self.query_error(query, 'unexpected error from pymonetdb', 
str(value))
+            self.query_error(query, 'unexpected error from pymonetdb',
+                             str(value))
             return ['statement', 'error'], []
         if crs.description is None:
             # it's not a query, it's a statement
@@ -540,9 +546,10 @@ class SQLLogic:
             data = crs.fetchall()
         except KeyboardInterrupt:
             raise
-        except:
+        except Exception:
             tpe, value, traceback = sys.exc_info()
-            self.query_error(query, 'unexpected error from pymonetdb', 
str(value))
+            self.query_error(query, 'unexpected error from pymonetdb',
+                             str(value))
             return ['statement', 'error'], []
         if crs.lastrowid is not None:
             # it was a PREPARE query
@@ -678,13 +685,13 @@ class SQLLogic:
             if not err:
                 try:
                     ndata = pyfnc(data)
-                except:
+                except Exception:
                     self.query_error(query, 'filter function failed')
                     err = True
                 if resdata is not None:
                     try:
                         resdata = pyfnc(resdata)
-                    except:
+                    except Exception:
                         resdata = None
             ncols = 1
             if (len(ndata)):
@@ -879,13 +886,13 @@ class SQLLogic:
                 assert k in ['conn_id', 'username', 'password']
                 assert res.get(k) is None
                 res[k] = v
-            except (ValueError, AssertionError) as e:
+            except (ValueError, AssertionError):
                 self.raise_error('invalid connection parameters definition!')
         if len(res.keys()) > 1:
             try:
                 assert res.get('username')
                 assert res.get('password')
-            except AssertionError as e:
+            except AssertionError:
                 self.raise_error('invalid connection parameters definition, 
username or password missing!')
         return res
 
@@ -1089,7 +1096,8 @@ class SQLLogic:
         if approve:
             approve.flush()
 
-if __name__ == '__main__':
+
+def main():
     import argparse
     parser = argparse.ArgumentParser(description='Run a Sqllogictest')
     parser.add_argument('--host', action='store', default='localhost',
@@ -1106,11 +1114,13 @@ if __name__ == '__main__':
                         help='language to use for testing')
     parser.add_argument('--data-dir', action='store',
                         type=Path,
-                        help='directory for relative paths in ON CLIENT 
processing (default: directory of test script)')
+                        help='directory for relative paths in ON CLIENT'
+                        ' processing (default: directory of test script)')
     parser.add_argument('--nodrop', action='store_true',
                         help='do not drop tables at start of test')
     parser.add_argument('--timeout', action='store', type=int, default=0,
-                        help='timeout in seconds (<= 0 is no timeout) after 
which test is terminated')
+                        help='timeout in seconds (<= 0 is no timeout) after'
+                        ' which test is terminated')
     parser.add_argument('--verbose', action='store_true',
                         help='be a bit more verbose')
     parser.add_argument('--results', action='store',
@@ -1161,3 +1171,12 @@ if __name__ == '__main__':
         sys.exit(2)
     if sql.timedout:
         sys.exit(1)
+
+
+if __name__ == '__main__':
+    if sys.argv[1] == '--pdb':
+        del sys.argv[1]
+        import pdb
+        pdb.run('main()')
+    else:
+        main()
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to