Skip to content

Instantly share code, notes, and snippets.

@g-fukurowl
Created April 30, 2016 13:37
Show Gist options
  • Select an option

  • Save g-fukurowl/bd5732e6a5bfa0279b3a8d7e4414e818 to your computer and use it in GitHub Desktop.

Select an option

Save g-fukurowl/bd5732e6a5bfa0279b3a8d7e4414e818 to your computer and use it in GitHub Desktop.
def hoge():
print "hoge"
def test_hoge(capsys):
hoge()
out, err = capsys.readouterr()
assert out == "hoge\n"
@g-fukurowl
Copy link
Author

g-fukurowl commented Apr 30, 2016

How to test printing onto stdout with py.test.
For more detail, read http://pytest.org/latest-ja/capture.html#id3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment