old_contents: import os
  from subprocess import check_call
  import sys
  import sqlite3
  import csv
  from verifier import verify
  import osutils
  
  def testdbname():
      return 'test.db'
  
  def readquery(fname):
      query_path = "./"
      return file(os.path.join(query_path, fname)).read()
  
  def make_query(name, query, delim=','):
  
      template = """
      %(query)s
      """ 
  
      outputname = "%s.sqlite.out" % (name)
  
      query_modified = template % locals()
  
      return query_modified
  
  
  def checkquery(name, tmppath="tmp", querypath="testqueries"):
      
      """
      @param name: name of query
      @param tmppath: existing directory for temporary files
      """
   
      osutils.mkdir_p(tmppath)
      envir = os.environ.copy()
  
      # cpp -> exe
      exe_name = './%s.exe' % (name)
      check_call(['make', exe_name], env=envir)
      
      # run cpp
      testoutfn = '%s/%s.out' % (tmppath, name)
      with open(testoutfn, 'w') as outs:
          check_call(['./%s' % (exe_name)], stdout=outs, env=envir)
  
      querycode  = readquery("%s/%s.sql" % (querypath,name))
      querystr = make_query(name, querycode)
  
      # run sql
      conn = sqlite3.connect(testdbname())
      c = conn.cursor()
      expectedfn = '%s/%s.sqlite.csv' % (tmppath, name)
      with open(expectedfn, 'w') as csvfile:
          wr = csv.writer(csvfile, delimiter=' ')
          for row in c.execute(querystr):
              wr.writerow(list(row))
      
      print "test: %s" % (name)
      verify(testoutfn, expectedfn, False)
  
  
  if __name__ == "__main__":
      if len(sys.argv) < 2:
          print "usage %s <query name>" % (sys.argv[0])
          exit(1)
  
      name = sys.argv[1]
  
      checkquery(name)
  
  
new_contents: import os
  from subprocess import check_call
  import sys
  import sqlite3
  import csv
  from verifier import verify
  import osutils
  
  def testdbname():
      return 'test.db'
  
  def readquery(fname):
      query_path = "./"
      return file(os.path.join(query_path, fname)).read()
  
  def make_query(name, query, delim=','):
  
      template = """
      %(query)s
      """ 
  
      outputname = "%s.sqlite.out" % (name)
  
      query_modified = template % locals()
  
      return query_modified
  
  
  def checkquery(name, tmppath="tmp", querypath="testqueries"):
      
      """
      @param name: name of query
      @param tmppath: existing directory for temporary files
      """
   
      osutils.mkdir_p(tmppath)
      envir = os.environ.copy()
  
      # cpp -> exe
      exe_name = './%s.exe' % (name)
      check_call(['make', exe_name], env=envir)
      
      # run cpp
      testoutfn = '%s/%s.out' % (tmppath, name)
      with open(testoutfn, 'w') as outs:
          check_call(['%s' % (exe_name)], stdout=outs, env=envir)
  
      querycode  = readquery("%s/%s.sql" % (querypath,name))
      querystr = make_query(name, querycode)
  
      # run sql
      conn = sqlite3.connect(testdbname())
      c = conn.cursor()
      expectedfn = '%s/%s.sqlite.csv' % (tmppath, name)
      with open(expectedfn, 'w') as csvfile:
          wr = csv.writer(csvfile, delimiter=' ')
          for row in c.execute(querystr):
              wr.writerow(list(row))
      
      print "test: %s" % (name)
      verify(testoutfn, expectedfn, False)
  
  
  if __name__ == "__main__":
      if len(sys.argv) < 2:
          print "usage %s <query name>" % (sys.argv[0])
          exit(1)
  
      name = sys.argv[1]
  
      checkquery(name)
  
  
subject: remove bug introduced earlier today