Denis Bilenko committed 6e74c53 unless --db option is provided, create sqlite db in /tmp/ and remove it every time

Comments (0)

Files changed (1)


 # Known issues:
 # - screws up warnings location, causing them to appear as originated from
+DEFAULT_FILENAME = '/tmp/gevent-testrunner.sqlite3'
 # the number of seconds each test script is allowed to run
     return core.get_version()
-def get_tempnam():
-    import warnings
-    warnings.filterwarnings('ignore', 'tempnam is a potential security risk to your program')
-    try:
-        tempnam = os.tempnam()
-    finally:
-        del warnings.filters[0]
-    return os.path.join(os.path.dirname(tempnam), 'testresults.sqlite3')
 def execfile_as_main(path):
     import __builtin__
     oldmain = sys.modules["__main__"]
     return False
+def unlink(path):
+    try:
+        os.unlink(path)
+    except OSError, ex:
+        if ex.errno == 2:  # No such file or directory
+            return
+        raise
 def main():
     import optparse
     parser = optparse.OptionParser()
     parser.add_option('-v', '--verbose', default=0, action='count')
     parser.add_option('-q', '--quiet', default=0, action='count')
     parser.add_option('--verbosity', default=0, type='int', help=optparse.SUPPRESS_HELP)
-    parser.add_option('--db', default='testresults.sqlite3')
+    parser.add_option('--db')
     parser.add_option('--no-db', dest='db', action='store_false')
     parser.add_option('--record', default=False, action='store_true')
     options, args = parser.parse_args()
     options.verbosity += options.verbose - options.quiet
+    if options.db is None:
+        unlink(DEFAULT_FILENAME)
+        options.db = DEFAULT_FILENAME
     if options.db:
         if sqlite3:
             options.db = os.path.abspath(options.db)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.