I want to test my application API using Flask + Werkzeug + SQLite in memory.
The application was configured using application factory pattern, like this:
def create_app(config_name):
application = Flask(__name__)
application.config.from_object(config_name)
db = FlaskDB(application)
database.initialize(db.database)
db.database.commit()
register_admin_blueprints(application)
*****
return application
And in the test I use:
def setUp(self):
app = create_app('config.test')
self.app = app.test_client()
self.app.testing = True
self.headers = [('Content-Type', 'application/json')]
def test_should_be_possible_list_all_areas(self):
response = self.app.get('/api/1/area')
response_json = json.loads(response.data.decode('utf-8'))
###
In 'config.test' file has the variable DATABASE.
In ***** I register data in the DB
and in ### I assert my test.
When I use DATABASE = 'sqlite:///test.db' works fine, but when change to DATABASE = 'sqlite:///:memory:' I get error.
Any ideias to solve this problem?
Tks.