forked from orbit-oss/flask
Make the example tests pass on Windows.
Also updated the documentation regarding that.
This commit is contained in:
parent
af3b73f70d
commit
3053fcdb0d
3 changed files with 37 additions and 17 deletions
|
|
@ -8,6 +8,7 @@
|
|||
:copyright: (c) 2010 by Armin Ronacher.
|
||||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
import os
|
||||
import flaskr
|
||||
import unittest
|
||||
import tempfile
|
||||
|
|
@ -17,11 +18,15 @@ class FlaskrTestCase(unittest.TestCase):
|
|||
|
||||
def setUp(self):
|
||||
"""Before each test, set up a blank database"""
|
||||
self.db = tempfile.NamedTemporaryFile()
|
||||
self.db_fd, flaskr.DATABASE = tempfile.mkstemp()
|
||||
self.app = flaskr.app.test_client()
|
||||
flaskr.DATABASE = self.db.name
|
||||
flaskr.init_db()
|
||||
|
||||
def tearDown(self):
|
||||
"""Get rid of the database again after each test."""
|
||||
os.close(self.db_fd)
|
||||
os.unlink(flaskr.DATABASE)
|
||||
|
||||
def login(self, username, password):
|
||||
return self.app.post('/login', data=dict(
|
||||
username=username,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
:copyright: (c) 2010 by Armin Ronacher.
|
||||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
import os
|
||||
import minitwit
|
||||
import unittest
|
||||
import tempfile
|
||||
|
|
@ -17,11 +18,15 @@ class MiniTwitTestCase(unittest.TestCase):
|
|||
|
||||
def setUp(self):
|
||||
"""Before each test, set up a blank database"""
|
||||
self.db = tempfile.NamedTemporaryFile()
|
||||
self.db_fd, minitwit.DATABASE = tempfile.mkstemp()
|
||||
self.app = minitwit.app.test_client()
|
||||
minitwit.DATABASE = self.db.name
|
||||
minitwit.init_db()
|
||||
|
||||
def tearDown(self):
|
||||
"""Get rid of the database again after each test."""
|
||||
os.close(self.db_fd)
|
||||
os.unlink(minitwit.DATABASE)
|
||||
|
||||
# helper functions
|
||||
|
||||
def register(self, username, password, password2=None, email=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue