PyTest - Basics and SetupWhy does pytest automatically discover tests without explicit test suites or main functions?ABecause pytest requires tests to be registered manuallyBBecause pytest uses naming conventions and introspection to find testsCBecause pytest only runs tests defined in __main__DBecause pytest uses XML configuration files to list testsCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand pytest test discovery mechanismPytest finds tests by looking for files and functions matching naming patterns using introspection.Step 2: Eliminate incorrect optionsPytest does not require manual registration, does not run only __main__, and does not rely on XML files for discovery.Final Answer:Because pytest uses naming conventions and introspection to find tests -> Option BQuick Check:Test discovery = naming + introspection [OK]Quick Trick: pytest finds tests by name and introspection automatically [OK]Common Mistakes:MISTAKESThinking tests must be registered manuallyAssuming tests run only in main moduleBelieving XML files control test discovery
Master "Basics and Setup" in PyTest9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepTraceTryChallengeAutomateRecallFrame
More PyTest Quizzes Fixtures - Fixture scope (function, class, module, session) - Quiz 7medium Fixtures - Fixture factories - Quiz 15hard Fixtures - Fixture finalization (request.addfinalizer) - Quiz 15hard Markers - @pytest.mark.skipif with condition - Quiz 14medium Markers - Registering markers in pytest.ini - Quiz 7medium Parametrize - Combining multiple parametrize decorators - Quiz 11easy PyTest Basics and Setup - PyTest installation (pip install pytest) - Quiz 9hard Test Organization - Test classes - Quiz 3easy Writing Assertions - Checking identity (is, is not) - Quiz 1easy Writing Assertions - Why assert is PyTest's core mechanism - Quiz 2easy