Skip to content
Myr

test_db.py

This file

Path

examples/tutorial/tests/test_db.py

29 lines · 616 bytes · Python

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 694eb84 point at it.

reword changelog for importlib.resourcesDavid Lordbefore adoption694eb84

lines 1–29why, one step back
1import sqlite3
23import pytest45from flaskr.db import get_db678def test_get_close_db(app):9 with app.app_context():10 db = get_db()11 assert db is get_db()1213 with pytest.raises(sqlite3.ProgrammingError) as e:14 db.execute("SELECT 1")1516 assert "closed" in str(e.value)171819def test_init_db_command(runner, monkeypatch):20 class Recorder:21 called = False2223 def fake_init_db():24 Recorder.called = True2526 monkeypatch.setattr("flaskr.db.init_db", fake_init_db)27 result = runner.invoke(args=["init-db"])28 assert "Initialized" in result.output29 assert Recorder.called