def db(test_app, request): """initialize the entries table and drop it when finished""" init_db() def cleanup(): clear_db() request.addfinalizer(cleanup)
def test_app(): """configure our app for use in testing""" app.config['DATABASE'] = TEST_DSN app.config['TESTING'] = True init_db() with app.test_request_context('/'): app.test_client().post( '/add', data=lettuce.world.entry_data, follow_redirects=True) # manually commit transaction here to avoid rollback # due to handled Exception get_database_connection().commit()
def test_app(): """configure our app for use in testing""" app.config['DATABASE'] = TEST_DSN app.config['TESTING'] = True init_db() with app.test_request_context('/'): app.test_client().post('/add', data=lettuce.world.entry_data, follow_redirects=True) # manually commit transaction here to avoid rollback # due to handled Exception get_database_connection().commit()
def db(test_app, request): ''' Initialize the entries table and drop it when finished. ''' # This is the "fixture function" with its "registered fixture" parameters. # The request parameter is a fixture that pytest gives you; you use it # to connect the cleanup() function to the db fixture. init_db() # Unexplained methods: cleardb addfinalizer cleanup # "The request parameter is a fixture that pytest registers. # You use it to connect the cleanup function to the db fixture. # This means that cleanup will be run after tests are complete # as a tear-down action." def cleanup(): clear_db() # I THINK @app.teardown_request is a finalizer? Maaaaybe... ??? request.addfinalizer(cleanup)
def configure_app_and_db(): """configure our app for use in testing""" app.config['DATABASE'] = TEST_DSN app.config['TESTING'] = True """initialize the entries table and drop it when finished""" init_db()
def setup_app(): print "Database initialized." app.config['DATABASE'] = TEST_DSN app.config['TESTING'] = True init_db()
def setup_app(): app.config['DATABASE'] = TEST_DSN app.config['TESTING'] = True init_db()
def setup_app(): print "This happens before all the lettuce tests begin" app.config['DATABASE'] = TEST_DSN app.config['TESTING'] = True init_db()
def db(test_app, request): init_db() def cleanup(): clear_db() request.addfinalizer(cleanup)