0
0
PyTesttesting~10 mins

Test file and function naming conventions in PyTest - Interactive Code Practice

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

Complete the code to name the test file correctly for pytest.

PyTest
File name should start with [1] to be recognized by pytest.
Drag options to blanks, or click blank then click option'
Atest_
Bcheck_
Crun_
Dverify_
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'check_' or 'run_' as file prefixes which pytest does not recognize automatically.
2fill in blank
medium

Complete the code to name the test function correctly for pytest.

PyTest
Test functions should start with [1] to be discovered by pytest.
Drag options to blanks, or click blank then click option'
Atest_
Bverify_
Crun_
Dcheck_
Attempts:
3 left
💡 Hint
Common Mistakes
Naming test functions without the 'test_' prefix, so pytest skips them.
3fill in blank
hard

Fix the error in the test function name to make pytest recognize it.

PyTest
def [1]_example():
    assert 1 + 1 == 2
Drag options to blanks, or click blank then click option'
Acheck
Btest
Crun
Dverify
Attempts:
3 left
💡 Hint
Common Mistakes
Using prefixes like 'check' or 'run' which pytest does not recognize.
4fill in blank
hard

Fill both blanks to write a correct pytest test function name and file name.

PyTest
File: [1]example.py
Function: def [2]_addition():
    assert 2 + 2 == 4
Drag options to blanks, or click blank then click option'
Atest_
Bcheck_
Ctest
Drun_
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing prefixes or missing underscores in file or function names.
5fill in blank
hard

Fill all three blanks to write a pytest test file and function with correct naming conventions and an assertion.

PyTest
File: [1]math_ops.py

def [2]_multiply():
    result = 3 * 3
    assert result [3] 9
Drag options to blanks, or click blank then click option'
Atest_
Btest
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong prefixes or wrong assertion operators.