Skip to content
Myr

Database improperly closed in example code

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

os.unlink(flaskr.DATABASE) causes the actual application database to be purged; whereas, I reckon, one wants the _test_ database to be removed. So every time I ran it, the test passed, but ended up crashing the live app for want of a valid database. I avoided using the sample code in examples/flaskr thus far, as I chose to type out code from the turorial docs. The actual example code looks good - at least to my beginner's eye.

authored by lambdadi · committed by lambdadi · parent 61d3bbf · Browse files · 1 file+1 added−1 removed
This commit

State

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

Diff stats

1 file+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:docs/testing.rst+1 added-1 removed
100 unmodified lines
101 flaskr.init_db()102103 def tearDown(self):104 os.close(self.db_fd)105 os.unlink(flaskr.DATABASE)105 os.unlink(flaskr.app.config['DATABASE'])106107 def test_empty_db(self):108 rv = self.app.get('/')109 assert 'No entries here so far' in rv.data
194 unmodified lines