Changeset: 023893da55b0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/023893da55b0 Modified Files: sql/test/sysmon/Tests/sys_queue_expand.SQL.py Branch: Dec2023 Log Message:
Use f strings, and use " so that ' does not have to be quoted. diffs (81 lines): diff --git a/sql/test/sysmon/Tests/sys_queue_expand.SQL.py b/sql/test/sysmon/Tests/sys_queue_expand.SQL.py --- a/sql/test/sysmon/Tests/sys_queue_expand.SQL.py +++ b/sql/test/sysmon/Tests/sys_queue_expand.SQL.py @@ -9,16 +9,16 @@ import pymonetdb import os import multiprocessing as mp -db = os.environ['TSTDB'] -pt = int(os.environ['MAPIPORT']) -SLEEP_TIME='5000' +db = os.environ["TSTDB"] +pt = int(os.environ["MAPIPORT"]) +SLEEP_TIME = 5000 # milliseconds def worker_task(): dbh = None try: dbh = pymonetdb.connect(database=db, port=pt, autocommit=True) cur = dbh.cursor() - cur.execute('call sys.sleep('+SLEEP_TIME+')') + cur.execute(f"call sys.sleep({SLEEP_TIME})") except pymonetdb.exceptions.Error as e: print(e) finally: @@ -37,11 +37,11 @@ def main(): mstdbh = pymonetdb.connect(database=db, port=pt, autocommit=True) mstcur = mstdbh.cursor() - query = 'create procedure sleep(i int) external name alarm.sleep;' + query = "create procedure sleep(i int) external name alarm.sleep;" mstcur.execute(query) - query = 'select username, status, query from sys.queue() where status = \'running\' order by query' - expected_res = [('monetdb', 'running', 'select username, status, query from sys.queue() where status = \'running\' order by query\n;')] + query = "select username, status, query from sys.queue() where status = 'running' order by query" + expected_res = [("monetdb", "running", "select username, status, query from sys.queue() where status = 'running' order by query\n;")] rowcnt = mstcur.execute(query) res = mstcur.fetchall() if rowcnt != len(expected_res) or res != expected_res: @@ -54,12 +54,12 @@ def main(): # Check the long running query, but lets first wait for a moment for the # workers to start with their queries - mstcur.execute('call sys.sleep(1000)') - query = 'select username, status, query from sys.queue() where query like \'call sys.sleep('+SLEEP_TIME+')%\' order by query' + mstcur.execute("call sys.sleep(1000)") + query = f"select username, status, query from sys.queue() where query like 'call sys.sleep({SLEEP_TIME})%' order by query" expected_res = [ - ('monetdb', 'running', 'call sys.sleep('+SLEEP_TIME+')\n;'), - ('monetdb', 'running', 'call sys.sleep('+SLEEP_TIME+')\n;'), - ('monetdb', 'running', 'call sys.sleep('+SLEEP_TIME+')\n;')] + ("monetdb", "running", f"call sys.sleep({SLEEP_TIME})\n;"), + ("monetdb", "running", f"call sys.sleep({SLEEP_TIME})\n;"), + ("monetdb", "running", f"call sys.sleep({SLEEP_TIME})\n;")] rowcnt = mstcur.execute(query) res = mstcur.fetchall() if rowcnt != len(expected_res) or res != expected_res: @@ -70,10 +70,10 @@ def main(): # sys.queue() should have been expanded from 4 to 8, so we # should be able to have 8 queries in the queue - mstcur.execute('select 6') - mstcur.execute('select 7') - mstcur.execute('select 8') - query = 'select count(*) from sys.queue()' + mstcur.execute("select 6") + mstcur.execute("select 7") + mstcur.execute("select 8") + query = "select count(*) from sys.queue()" expected_res = 8 rowcnt = mstcur.execute(query) res = mstcur.fetchall() @@ -84,7 +84,7 @@ def main(): finally: if mstdbh is not None: if mstcur is not None: - mstcur.execute('drop procedure sleep;') + mstcur.execute("drop procedure sleep") mstdbh.close() if __name__ == "__main__": _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org