Skip to content

Commit 8a5b9d0

Browse files
committed
Update test to use context manager for StringIO
1 parent fcafc37 commit 8a5b9d0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/issue0079.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ def runTest(self):
1212

1313
p = Preprocessor()
1414
p.parse(self.input)
15-
oh = StringIO()
16-
p.write(oh)
17-
print("ok")
18-
if oh.getvalue() != self.output:
19-
print("Should be:\n" + self.output + "EOF\n", file = sys.stderr)
20-
print("\nWas:\n" + oh.getvalue()+"EOF\n", file = sys.stderr)
21-
self.assertEqual(p.return_code, 0)
22-
self.assertEqual(oh.getvalue(), self.output)
15+
with StringIO() as oh:
16+
p.write(oh)
17+
print("ok")
18+
if oh.getvalue() != self.output:
19+
print("Should be:\n" + self.output + "EOF\n", file = sys.stderr)
20+
print("\nWas:\n" + oh.getvalue()+"EOF\n", file = sys.stderr)
21+
self.assertEqual(p.return_code, 0)
22+
self.assertEqual(oh.getvalue(), self.output)
2323

2424
class pp_number_pasting(unittest.TestCase, runner):
25-
input = r"""#define CAT_(A,B)A##B
25+
input = """#define CAT_(A,B)A##B
2626
#define CAT(A,B)CAT_(A,B)
2727
#define Ox 0x
2828
#if CAT(Ox,1)
@@ -31,7 +31,7 @@ class pp_number_pasting(unittest.TestCase, runner):
3131
PP_NUMBER paste fail
3232
#endif
3333
"""
34-
output = r"""
34+
output = """
3535
3636
3737

0 commit comments

Comments
 (0)