0
0
Testing Fundamentalstesting~10 mins

Regression testing in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the regression testing module.

Testing Fundamentals
import [1]
Drag options to blanks, or click blank then click option'
Amock
Bunittest
Cpytest
Dregression_testing
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'unittest' which is a testing framework but less common for regression testing.
Trying to import a non-existent module named 'regression_testing'.
2fill in blank
medium

Complete the code to define a regression test function that checks if the output matches expected.

Testing Fundamentals
def test_model_output():
    result = model.predict(data)
    assert result == [1]
Drag options to blanks, or click blank then click option'
ANone
Bdata
Cmodel
Dexpected_output
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing result to the input data instead of expected output.
Using None which would always fail the test.
3fill in blank
hard

Fix the error in the test assertion to correctly check if the model's accuracy is above 90%.

Testing Fundamentals
def test_accuracy():
    accuracy = model.evaluate(test_data)
    assert accuracy [1] 0.9
Drag options to blanks, or click blank then click option'
A>=
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which would fail even if accuracy is good.
Using '==' which is too strict for floating point values.
4fill in blank
hard

Fill both blanks to create a regression test that filters results and checks if all are above threshold.

Testing Fundamentals
filtered_results = [r for r in results if r [1] threshold]
assert all(r [2] threshold for r in filtered_results)
Drag options to blanks, or click blank then click option'
A>
B>=
C<
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' in the filter which selects wrong results.
Using '<=' in the assertion which may allow lower values.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps features to values only if value is above limit.

Testing Fundamentals
filtered_dict = [1]: [2] for [3], [2] in features.items() if [2] > limit}
Drag options to blanks, or click blank then click option'
Afeature
Bvalue
Ck
Dv
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently causing errors.
Not matching the key and value names in the comprehension.