Bird
0
0

Given the following test file content:

medium📝 Predict Output Q4 of 15
PyTest - Markers
Given the following test file content:
import pytest

@pytest.mark.api
def test_api_call():
    assert True

@pytest.mark.ui
def test_ui_load():
    assert True

What will be the result of running pytest -m ui?
AOnly test_ui_load will run and pass
BBoth tests will run and pass
COnly test_api_call will run and pass
DNo tests will run
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest -m option

    The -m option runs tests matching the given marker.
  2. Step 2: Identify tests marked with 'ui'

    Only test_ui_load is marked with @pytest.mark.ui.
  3. Final Answer:

    Only test_ui_load will run and pass -> Option A
  4. Quick Check:

    pytest -m ui runs tests with 'ui' marker [OK]
Quick Trick: -m runs tests matching the marker name [OK]
Common Mistakes:
MISTAKES
  • Assuming all tests run regardless of marker
  • Confusing marker names and running wrong tests
  • Expecting no tests to run if marker is used

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes