Bird
0
0

What is the result of running this pytest code?

medium📝 Predict Output Q4 of 15
PyTest - Markers
What is the result of running this pytest code?
import pytest

@pytest.mark.skip(reason="Test disabled")
def test_skip():
    assert False

print("Running tests")
AThe test is skipped and "Running tests" is printed
BThe test fails and "Running tests" is printed
CThe test runs and passes, "Running tests" is printed
DSyntax error due to incorrect decorator usage
Step-by-Step Solution
Solution:
  1. Step 1: Understand skip behavior

    Tests marked with @pytest.mark.skip are not executed.
  2. Step 2: Output analysis

    The print statement runs normally, so "Running tests" is printed.
  3. Final Answer:

    The test is skipped and "Running tests" is printed -> Option A
  4. Quick Check:

    Skipped tests do not run assertions [OK]
Quick Trick: Skipped tests do not execute assertions [OK]
Common Mistakes:
MISTAKES
  • Assuming skipped tests run and fail
  • Confusing print output with test result
  • Thinking skip causes syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes