Testing de apps Flask

De WikiEducator
Saltar a: navegación, buscar


Documentación

Ejemplos

Esqueleto

# -*- coding: utf-8 -*-
import os
import flaskr
import unittest
import tempfile
 
class FlaskrTestCase(unittest.TestCase):
 
    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()
 
    def tearDown(self):
        os.close(self.db_fd)
        os.unlink(flaskr.app.config['DATABASE'])
 
if __name__ == '__main__':
    unittest.main()