Skip to content

Commit

Permalink
Adding tests and another line normalization for stderr.
Browse files Browse the repository at this point in the history
  • Loading branch information
jstenar committed Aug 25, 2012
1 parent ced21cc commit fd8a171
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions IPython/testing/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,27 @@ def func():
print b"ghi"

self.assertRaises(AssertionError, func)


class Test_ipexec_validate(unittest.TestCase, tt.TempFileMixin):
def test_main_path(self):
"""Test with only stdout results.
"""
self.mktmp("print('A')\n"
"print('B')\n"
)
out = "A\nB"
tt.ipexec_validate(self.fname, out)

def test_exception_path(self):
"""Test exception path in exception_validate.
"""
self.mktmp("from __future__ import print_function\n"
"import sys\n"
"print('A')\n"
"print('B')\n"
"print('C', file=sys.stderr)\n"
"print('D', file=sys.stderr)\n"
)
out = "A\nB"
tt.ipexec_validate(self.fname, expected_out=out, expected_err="C\nD")
2 changes: 1 addition & 1 deletion IPython/testing/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def ipexec_validate(fname, expected_out, expected_err='',
# more informative than simply having an empty stdout.
if err:
if expected_err:
nt.assert_equal(err.strip(), expected_err.strip())
nt.assert_equal("\n".join(err.strip().splitlines()), "\n".join(expected_err.strip().splitlines()))
else:
raise ValueError('Running file %r produced error: %r' %
(fname, err))
Expand Down

0 comments on commit fd8a171

Please sign in to comment.