title: Peewee Flask Test API in memory
body: <p>I want to test my application API using Flask + Werkzeug + SQLite in memory.</p>
  
  <p>The application was configured using application factory pattern, like this:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>And in the test I use:</p>
  
  <pre><code>   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'))
        ###
  </code></pre>
  
  <p>In '<em>config.test</em>' file has the variable DATABASE.</p>
  
  <p>In ***** I register data in the DB </p>
  
  <p>and in ### I assert my test.</p>
  
  <p>When I use <em>DATABASE = 'sqlite:///test.db'</em> works fine, but when change to DATABASE = '<em>sqlite:///:memory:'</em> I get error.</p>
  
  <p>Any ideias to solve this problem?</p>
  
  <p>Tks.</p>