def setUp(self):
     """
     Create a temporary url shortener app, and a temporary 
     database to use it.
     """
     # tempfile.mkstemp() returns a tuple containing a file
     # descriptor and the path to the file, so we're using the file
     # as our test-app's database here.
     self.db_fd, url_shortener.app.config["DATABASE"] = tempfile.mkstemp()
     url_shortener.app.config["TESTING"] = True
     # special method to create a test client, used so we can see
     # exceptions thrown by the app.
     self.app = url_shortener.app.test_client()
     url_shortener.init_db()
示例#2
0
    def setUp(self):
        """
        Create a temporary url shortener app, and a temporary 
        database to use it.
        """
        # tempfile.mkstemp() returns a tuple containing a file 
        # descriptor and the path to the file, so we're using the file 
        # as our test-app's database here.
        self.db_fd, url_shortener.app.config['DATABASE'] = tempfile.mkstemp()
        url_shortener.app.config.from_object(url_shortener.config)
        url_shortener.app.config['TESTING'] = True

        # special method to create a test client, used so we can see 
        # exceptions thrown by the app.
        self.app = url_shortener.app.test_client()

        # need a secret key, otherwise Flask will be annoyed:
        url_shortener.app.secret_key = 'testing key'
        url_shortener.init_db()
 def setUp(self):
     self.db_fd, url_shortener.app.config['DATABASE'] = tempfile.mkstemp()
     url_shortener.app.config['TESTING'] = True
     self.app = url_shortener.app.test_client()
     url_shortener.init_db()
 def setUp(self):
     self.db_fd, url_shortener.app.config["DATABASE"] = tempfile.mkstemp()
     url_shortener.app.config["TESTING"] = True
     self.app = url_shortener.app.test_client()
     url_shortener.init_db()
示例#5
0
#! /usr/bin/env python

from url_shortener import init_db

if __name__ == "__main__":
    init_db()