Skip to content
CodeKruPro

Why pytest uses the plain assert statement

QuizEasyPython onlyAsked in: Accenture, Capgemini, TCS, Wipro

Why can pytest tests use a plain assert actual == expected instead of special assert methods?

  • pytest rewrites assert statements in test modules so a failure shows the values on both sides
  • Python asserts always print both values
  • pytest turns asserts into soft assertions
  • pytest ignores failed asserts in CI

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in