Complete the code to set the test environment variable.
import os os.environ[[1]] = 'test'
The environment variable for the test environment is usually named 'TEST_ENV'. Setting it helps the application know it is running in test mode.
Complete the code to initialize the test database connection.
def setup_database(): connection = create_connection([1]) return connection
When setting up a test environment, the database connection should point to the test database URL to avoid affecting production data.
Fix the error in the test environment cleanup function.
def cleanup(): if os.path.exists([1]): os.remove('test_data.db')
The cleanup function should check if the test database file exists before removing it. The filename must match the test data file.
Fill both blanks to create a test configuration dictionary with environment and debug mode.
test_config = {
'environment': [1],
'debug': [2]
}The test configuration should set the environment to 'test' and enable debug mode by setting it to True.
Fill all three blanks to define a test setup function that sets environment, initializes database, and returns config.
def test_setup(): env = [1] db = create_connection([2]) config = {'env': env, 'db': db, 'debug': [3] return config
The test setup function sets the environment to 'test', connects to the test database URL, and enables debug mode by setting it to True.