0
0
Testing Fundamentalstesting~10 mins

Why test design drives efficiency in Testing Fundamentals - Test Your Understanding

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

Complete the code to create a test case that checks if a function returns the expected result.

Testing Fundamentals
def test_addition():
    result = add(2, 3)
    assert result [1] 5
Drag options to blanks, or click blank then click option'
A==
B=
C!=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '==' in the assertion.
2fill in blank
medium

Complete the code to skip a test when a condition is met.

Testing Fundamentals
import pytest

@pytest.mark.skipif([1], reason="Not supported")
def test_feature():
    assert feature() == True
Drag options to blanks, or click blank then click option'
ATrue
BNone
CFalse
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using False which causes the test to run instead of skipping.
3fill in blank
hard

Fix the error in the assertion to properly check if a list contains an item.

Testing Fundamentals
def test_contains():
    items = ['apple', 'banana', 'cherry']
    assert [1] in items
Drag options to blanks, or click blank then click option'
Aitems
B'banana'
C'grape'
Dbanana
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string item.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Testing Fundamentals
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B<
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as value instead of its length.
Using '<' instead of '>' in the condition.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary with uppercase keys and values greater than 0.

Testing Fundamentals
result = [1]: [2] for [3], v in data.items() if v > 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
Ck
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'value' instead of 'v' for values.
Using 'value' or 'v' instead of 'k' for keys in the loop.