Back to Tech Interviews

PyTest Python Testing Interview

Curated 20+ questions covering PyTest assertions, fixtures, yield teardowns, parameterization, markers, and plugins.

Total: 20 QuestionsLearned: 0 / 20 (0%)
Difficulty Filters

Tools & Options
Showing 20 of 20 questions
Beginner
What is PyTest, and what makes it preferred over Python's built-in `unittest` library?
Beginner
How does PyTest handle assertions? What is assertion introspection?
Intermediate
What are PyTest Fixtures, and how are they defined?
Intermediate
What is `conftest.py` in PyTest?
Advanced
Explain the scope of a PyTest Fixture.
Intermediate
How do you perform teardown or cleanup actions in a PyTest Fixture?
Intermediate
Explain Parameterized Tests in PyTest.
Beginner
What are PyTest Markers?
Intermediate
How do you test that a function raises an exception in PyTest?
Intermediate
What is PyTest autouse fixture?
Beginner
How do you execute specific tests in PyTest?
Beginner
What is `pytest.ini`?
Advanced
What is the difference between `pytest.fixture(scope="session")` and global variables?
Intermediate
How do you mock or patch dependencies in PyTest?
Beginner
What is the difference between `xfail` and `skip` markers?
Advanced
Explain PyTest fixtures dependency injection (fixtures using other fixtures).
Advanced
What is the `capfd` or `capsys` fixture in PyTest?
Beginner
How do you generate HTML test reports in PyTest?
Intermediate
What are pytest plugins? List common ones.
Advanced
Explain the `pytest-xdist` plugin and parallel execution.