Show More
@@ -88,3 +88,27 b' class TestAssertPrints(unittest.TestCase):' | |||
|
88 | 88 | print b"ghi" |
|
89 | 89 | |
|
90 | 90 | self.assertRaises(AssertionError, func) |
|
91 | ||
|
92 | ||
|
93 | class Test_ipexec_validate(unittest.TestCase, tt.TempFileMixin): | |
|
94 | def test_main_path(self): | |
|
95 | """Test with only stdout results. | |
|
96 | """ | |
|
97 | self.mktmp("print('A')\n" | |
|
98 | "print('B')\n" | |
|
99 | ) | |
|
100 | out = "A\nB" | |
|
101 | tt.ipexec_validate(self.fname, out) | |
|
102 | ||
|
103 | def test_exception_path(self): | |
|
104 | """Test exception path in exception_validate. | |
|
105 | """ | |
|
106 | self.mktmp("from __future__ import print_function\n" | |
|
107 | "import sys\n" | |
|
108 | "print('A')\n" | |
|
109 | "print('B')\n" | |
|
110 | "print('C', file=sys.stderr)\n" | |
|
111 | "print('D', file=sys.stderr)\n" | |
|
112 | ) | |
|
113 | out = "A\nB" | |
|
114 | tt.ipexec_validate(self.fname, expected_out=out, expected_err="C\nD") |
@@ -235,7 +235,7 b" def ipexec_validate(fname, expected_out, expected_err=''," | |||
|
235 | 235 | # more informative than simply having an empty stdout. |
|
236 | 236 | if err: |
|
237 | 237 | if expected_err: |
|
238 | nt.assert_equal(err.strip(), expected_err.strip()) | |
|
238 | nt.assert_equal("\n".join(err.strip().splitlines()), "\n".join(expected_err.strip().splitlines())) | |
|
239 | 239 | else: |
|
240 | 240 | raise ValueError('Running file %r produced error: %r' % |
|
241 | 241 | (fname, err)) |
General Comments 0
You need to be logged in to leave comments.
Login now