Beispiel #1
0
 def setUp(self):
     # テスト用DBを作成
     self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
     flaskr.app.testing = True
     self.app = flaskr.app.test_client()
     with flaskr.app.app_context():
         flaskr.init_db()
Beispiel #2
0
def client():
    db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
    flaskr.app.config['TESTING'] = True
    client = flaskr.app.test_client()
    with flaskr.app.app_context():
        flaskr.init_db()
    yield client
    os.close(db_fd)
    os.unlink(flaskr.app.config['DATABASE'])
Beispiel #3
0
def client():
    db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
    flaskr.app.config['TESTING'] = True
    client = flaskr.app.test_client()
    with flaskr.app.app_context():
        flaskr.init_db()
    yield client
    os.close(db_fd)
    os.unlink(flaskr.app.config['DATABASE'])
def client():
    db_fd, flaskr.app.config['BACKEND'] = tempfile.mkstemp()
    flaskr.app.config['TESTING'] = True

    with flaskr.app.test_client() as client:
        with flaskr.app.app_context():
            flaskr.init_db()
        yield client

    os.close(db_fd)
    os.unlink(flaskr.app.config['BACKEND'])
Beispiel #5
0
def client(request):
    db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
    flaskr.app.config['TESTING'] = True
    client = flaskr.app.test_client()
    with flaskr.app.app_context():
        flaskr.init_db()
    def teardown():
        os.close(db_fd)
        os.unlink(flaskr.app.config['DATABASE'])
    request.addfinalizer(teardown)
    return client
def app(request):
    db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
    flaskr.app.config['TESTING'] = True
    with flaskr.app.app_context():
        flaskr.init_db()

    def teardown():
        os.close(db_fd)
        os.unlink(flaskr.app.config['DATABASE'])
    request.addfinalizer(teardown)

    return flaskr.app
Beispiel #7
0
 def setUp(self):
     self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
     """Because SQLite3 is filesystem-based we can easily use the tempfile module 
     to create a temporary database and initialize it. 
     The mkstemp() function does two things for us: 
     it returns a low-level file handle and a random file name, 
     the latter we use as database name. 
     We just have to keep the db_fd around 
     so that we can use the os.close() function to close the file."""
     flaskr.app.testing = True
     self.app = flaskr.app.test_client()
     with flaskr.app.app_context():
         flaskr.init_db()
Beispiel #8
0
 def setUp(self):
     self.db_fd,flaskr.app.config['DATABASE'] = tempfile.mkstemp()
     flaskr.app.config['TESTING'] = True
     self.app = flaskr.app.test_client()
     flaskr.init_db()
Beispiel #9
0
 def setup(self):
     self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
     flaskr.app.config['TESTING'] = True
     self.app = flaskr.app.test_client()
     with flaskr.app.app_context():
         flaskr.init_db()