def new_backend(url, backend_args=None): """Return a new database backend instance for a file. - `url`: URL of the database to open with the backend. If given as just a filename, and the file already exists, then the backend is auto-detected if possible, or an exception is raised. If the file does not already exist and `None` is given, an exception is raised. - `backend_args`: (optional) Additional arguments to pass to the backend. """ if backend_args is None: backend_args = {} else: backend_args = backend_args.copy() if '://' not in url: # Assume filename, try to find backend. from schevo.backend import backends usable = False for backend_name, backend_class in backends.iteritems(): try: usable = backend_class.usable_by_backend(url) except IOError: usable = False else: if usable: usable, additional_args = usable backend_args.update(additional_args) # Convert to proper URL form. url = '%s:///%s' % (backend_name, url) break if not usable: raise IOError('No suitable backends found for %r' % url) # Convert to URL object. url = make_url(url) # Convert backend args to a dictionary. backend_args.update(url.translate_connect_args()) return url.backend_class()(**backend_args)
def backend_class(self): return make_url( self.backend_url).backend_class().TestMethods_EvolvesSchemata
def backend_class(self): """Return the appropriate backend class for this type of test.""" return make_url( self.backend_url).backend_class().TestMethods_CreatesDatabase