Skip to content
Myr

Fixed flask tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent e059bf3 · Browse files · 5 files+23 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+23 added−10 removed

  • other:+23 added−10 removed

5 files+23 added−10 removed

modified:examples/flaskr/flaskr_tests.py+2 added-1 removed
19 unmodified lines
20 """Before each test, set up a blank database"""21 self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()22 flaskr.app.config['TESTING'] = True23 self.app = flaskr.app.test_client()24 with flaskr.app.app_context():24 flaskr.init_db()25 flaskr.init_db()2627 def tearDown(self):28 """Get rid of the database again after each test."""29 os.close(self.db_fd)
47 unmodified lines
modified:examples/flaskr/flaskr.py+8 added-3 removed
35 unmodified lines
36 rv.row_factory = sqlite3.Row37 return rv383940@app.cli.command()41def initdb():42 """Creates the database tables."""40def init_db():41 """Initializes the database."""42 db = get_db()43 with app.open_resource('schema.sql', mode='r') as f:44 db.cursor().executescript(f.read())45 db.commit()464748@app.cli.command('initdb')49def initdb_command():50 """Creates the database tables."""51 init_db()52 print('Initialized the database.')535455def get_db():
55 unmodified lines
modified:examples/minitwit/minitwit_tests.py+2 added-1 removed
18 unmodified lines
19 def setUp(self):20 """Before each test, set up a blank database"""21 self.db_fd, minitwit.app.config['DATABASE'] = tempfile.mkstemp()22 self.app = minitwit.app.test_client()23 with minitwit.app.app_context():23 minitwit.init_db()24 minitwit.init_db()2526 def tearDown(self):27 """Get rid of the database again after each test."""28 os.close(self.db_fd)
122 unmodified lines
modified:examples/minitwit/minitwit.py+9 added-3 removed
47 unmodified lines
48 if hasattr(top, 'sqlite_db'):49 top.sqlite_db.close()505152@app.cli.command()53def initdb():54 """Creates the database tables."""52def init_db():53 """Initializes the database."""54 db = get_db()55 with app.open_resource('schema.sql', mode='r') as f:56 db.cursor().executescript(f.read())57 db.commit()585960@app.cli.command('initdb')61def initdb_command():62 """Creates the database tables."""63 init_db()64 print('Initialized the database.')656667def query_db(query, args=(), one=False):68 """Queries the database and returns a list of dictionaries."""69 cur = get_db().execute(query, args)70 rv = cur.fetchall()
186 unmodified lines
modified:flask/cli.py+2 added-2 removed
197 unmodified lines
198 if os.path.isfile(value):199 value = prepare_exec_for_file(value)200 elif '.' not in sys.path:201 sys.path.insert(0, '.')202 ctx.obj.app_import_path = value202 ctx.ensure_object(ScriptInfo).app_import_path = value203 def set_debug(ctx, value):204 ctx.obj.debug = value204 ctx.ensure_object(ScriptInfo).debug = value205206 click.Group.__init__(self, help=help, params=[207 click.Option(['-a', '--app'],208 help='The application to run',
148 unmodified lines