DEV Community


Discussion on: Capturing print statements while debugging

victorcosta profile image
Victor Costa

Hey, @wangonya

Great tutorial series :D. Thanks for writing such a useful content.

I just would like to make a little suggestion regarding the assertion of the captured print output.

You're using

assert "<SOME_STRING>" in captured.out

The in statement verifies whether captured.out contains <SOME_STRING>, which means that if <SOME_STRING> is aa and the captured.out was aaaaaa the test would pass.

I would suggest to change that assertion to

assert "<SOME_STRING>\n" == captured.out

What do you say?