Skip to content

Instantly share code, notes, and snippets.

@okken
Last active December 8, 2021 19:26
Show Gist options
  • Save okken/d45ecedf3fcfdd8516e49ce8f5290f99 to your computer and use it in GitHub Desktop.
Save okken/d45ecedf3fcfdd8516e49ce8f5290f99 to your computer and use it in GitHub Desktop.
textwrap.dedent for testing example
from textwrap import dedent
def multiline_hello_world():
print("hello")
print(" world")
def test_multiline_hello_world(capsys):
expected = dedent('''\
hello
world
''')
multiline_hello_world()
actual = capsys.readouterr().out
assert actual == expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment