0
0
PyTesttesting~10 mins

Why configuration standardizes test behavior in PyTest - Test Your Understanding

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

Complete the code to import the pytest module correctly.

PyTest
import [1]
Drag options to blanks, or click blank then click option'
Apytest
Bunittest
Crequests
Dos
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong module like unittest or os.
2fill in blank
medium

Complete the code to define a pytest fixture that provides a fixed value.

PyTest
@pytest.fixture
def fixed_value():
    return [1]
Drag options to blanks, or click blank then click option'
A'random'
B42
CNone
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Returning None or a string instead of a fixed number.
3fill in blank
hard

Fix the error in the test function to use the fixture correctly.

PyTest
def test_fixed(fixed_value):
    assert fixed_value [1] 42
Drag options to blanks, or click blank then click option'
A<
B!=
C==
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using != or comparison operators that cause test failure.
4fill in blank
hard

Fill both blanks to configure pytest to stop after first failure and show detailed info.

PyTest
def pytest_addoption(parser):
    parser.addoption('--maxfail', default=[1], help='Stop after max failures')
    parser.addoption('--tb', default=[2], help='Traceback style')
Drag options to blanks, or click blank then click option'
A1
B'short'
C'long'
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using maxfail=0 (no stop) or tb='short' (less info).
5fill in blank
hard

Fill all three blanks to create a pytest.ini file content that sets test paths, disables warnings, and sets log level.

PyTest
[pytest]
testpaths = [1]
filterwarnings = [2]
log_cli_level = [3]
Drag options to blanks, or click blank then click option'
Atests
Bignore::DeprecationWarning
CINFO
Dsrc
Attempts:
3 left
💡 Hint
Common Mistakes
Setting testpaths to 'src' or not filtering warnings.