Capture and verify printed output using capsys in pytest
Preconditions (2)
Step 1: Write a test function that calls the target function which prints to stdout and stderr
Step 2: Use the capsys fixture to capture the output
Step 3: After calling the function, use capsys.readouterr() to get the captured stdout and stderr
Step 4: Assert that the captured stdout contains the expected printed text
Step 5: Assert that the captured stderr contains the expected error text
✅ Expected Result: The test passes if the captured stdout and stderr match the expected printed messages