Complete the code to define a smoke test function that checks if the main page loads.
def test_main_page_loads(): response = client.get('/') assert response.status_code == [1]
The HTTP status code 200 means the page loaded successfully, which is what a smoke test checks.
Complete the code to perform a sanity test that verifies a feature flag is enabled.
def test_feature_flag_enabled(): feature_flag = get_feature_flag('new_ui') assert feature_flag is [1]
Sanity tests check specific functionality. Here, the feature flag should be True to confirm the feature is enabled.
Fix the error in the test that checks if the login page contains the text 'Welcome'.
def test_login_page_text(): response = client.get('/login') assert 'Welcome' [1] response.text
To check if 'Welcome' is part of the page text, use the 'in' keyword in Python.
Fill both blanks to create a dictionary comprehension that maps test names to their pass status only if they passed.
results = {test[1]: status for test, status in test_results.items() if status [2] True}The test names are converted to uppercase with .upper(). The condition uses is True to check status.
Fill both blanks to create a test report dictionary with test names in lowercase, their results, and only include failed tests.
failed_tests = {test[1]: result for test, result in all_tests.items() if result[2] False}Test names are converted to lowercase with .lower(). The result is used as is (no change). The condition checks if result is False to find failed tests.