@@ -231,113 +231,113 @@ def assert_runs_after(self, *names):
231231#
232232# s = "reduce()"
233233# self.unchanged(s)
234- #
235- # class Test_print(FixerTestCase):
236- # fixer = "print"
237- #
238- # def test_prefix_preservation(self):
239- # b = """print 1, 1+1, 1+1+1"""
240- # a = """print(1, 1+1, 1+1+1)"""
241- # self.check(b, a)
242- #
243- # def test_idempotency(self):
244- # s = """print()"""
245- # self.unchanged(s)
246- #
247- # s = """print('')"""
248- # self.unchanged(s)
249- #
250- # def test_idempotency_print_as_function(self):
251- # self.refactor.driver.grammar = pygram.python_grammar_no_print_statement
252- # s = """print(1, 1+1, 1+1+1)"""
253- # self.unchanged(s)
254- #
255- # s = """print()"""
256- # self.unchanged(s)
257- #
258- # s = """print('')"""
259- # self.unchanged(s)
260- #
261- # def test_1(self):
262- # b = """print 1, 1+1, 1+1+1"""
263- # a = """print(1, 1+1, 1+1+1)"""
264- # self.check(b, a)
265- #
266- # def test_2(self):
267- # b = """print 1, 2"""
268- # a = """print(1, 2)"""
269- # self.check(b, a)
270- #
271- # def test_3(self):
272- # b = """print"""
273- # a = """print()"""
274- # self.check(b, a)
275- #
276- # def test_4(self):
277- # # from bug 3000
278- # b = """print whatever; print"""
279- # a = """print(whatever); print()"""
280- # self.check(b, a)
281- #
282- # def test_5(self):
283- # b = """print; print whatever;"""
284- # a = """print(); print(whatever);"""
285- # self.check(b, a)
286- #
287- # def test_tuple(self):
288- # b = """print (a, b, c)"""
289- # a = """print((a, b, c))"""
290- # self.check(b, a)
291- #
292- # # trailing commas
293- #
294- # def test_trailing_comma_1(self):
295- # b = """print 1, 2, 3,"""
296- # a = """print(1, 2, 3, end=' ')"""
297- # self.check(b, a)
298- #
299- # def test_trailing_comma_2(self):
300- # b = """print 1, 2,"""
301- # a = """print(1, 2, end=' ')"""
302- # self.check(b, a)
303- #
304- # def test_trailing_comma_3(self):
305- # b = """print 1,"""
306- # a = """print(1, end=' ')"""
307- # self.check(b, a)
308- #
309- # # >> stuff
310- #
311- # def test_vargs_without_trailing_comma(self):
312- # b = """print >>sys.stderr, 1, 2, 3"""
313- # a = """print(1, 2, 3, file=sys.stderr)"""
314- # self.check(b, a)
315- #
316- # def test_with_trailing_comma(self):
317- # b = """print >>sys.stderr, 1, 2,"""
318- # a = """print(1, 2, end=' ', file=sys.stderr)"""
319- # self.check(b, a)
320- #
321- # def test_no_trailing_comma(self):
322- # b = """print >>sys.stderr, 1+1"""
323- # a = """print(1+1, file=sys.stderr)"""
324- # self.check(b, a)
325- #
326- # def test_spaces_before_file(self):
327- # b = """print >> sys.stderr"""
328- # a = """print(file=sys.stderr)"""
329- # self.check(b, a)
330- #
331- # def test_with_future_print_function(self):
332- # s = "from __future__ import print_function\n" \
333- # "print('Hai!', end=' ')"
334- # self.unchanged(s)
335- #
336- # b = "print 'Hello, world!'"
337- # a = "print('Hello, world!')"
338- # self.check(b, a)
339- #
340- #
234+
235+ class Test_print (FixerTestCase ):
236+ fixer = "print"
237+
238+ def test_prefix_preservation (self ):
239+ b = """print 1, 1+1, 1+1+1"""
240+ a = """print(1, 1+1, 1+1+1)"""
241+ self .check (b , a )
242+
243+ def test_idempotency (self ):
244+ s = """print()"""
245+ self .unchanged (s )
246+
247+ s = """print('')"""
248+ self .unchanged (s )
249+
250+ def test_idempotency_print_as_function (self ):
251+ self .refactor .driver .grammar = pygram .python_grammar_no_print_statement
252+ s = """print(1, 1+1, 1+1+1)"""
253+ self .unchanged (s )
254+
255+ s = """print()"""
256+ self .unchanged (s )
257+
258+ s = """print('')"""
259+ self .unchanged (s )
260+
261+ def test_1 (self ):
262+ b = """print 1, 1+1, 1+1+1"""
263+ a = """print(1, 1+1, 1+1+1)"""
264+ self .check (b , a )
265+
266+ def test_2 (self ):
267+ b = """print 1, 2"""
268+ a = """print(1, 2)"""
269+ self .check (b , a )
270+
271+ def test_3 (self ):
272+ b = """print"""
273+ a = """print()"""
274+ self .check (b , a )
275+
276+ def test_4 (self ):
277+ # from bug 3000
278+ b = """print whatever; print"""
279+ a = """print(whatever); print()"""
280+ self .check (b , a )
281+
282+ def test_5 (self ):
283+ b = """print; print whatever;"""
284+ a = """print(); print(whatever);"""
285+ self .check (b , a )
286+
287+ def test_tuple (self ):
288+ b = """print (a, b, c)"""
289+ a = """print((a, b, c))"""
290+ self .check (b , a )
291+
292+ # trailing commas
293+
294+ def test_trailing_comma_1 (self ):
295+ b = """print 1, 2, 3,"""
296+ a = """print(1, 2, 3, end=' ')"""
297+ self .check (b , a )
298+
299+ def test_trailing_comma_2 (self ):
300+ b = """print 1, 2,"""
301+ a = """print(1, 2, end=' ')"""
302+ self .check (b , a )
303+
304+ def test_trailing_comma_3 (self ):
305+ b = """print 1,"""
306+ a = """print(1, end=' ')"""
307+ self .check (b , a )
308+
309+ # >> stuff
310+
311+ def test_vargs_without_trailing_comma (self ):
312+ b = """print >>sys.stderr, 1, 2, 3"""
313+ a = """print(1, 2, 3, file=sys.stderr)"""
314+ self .check (b , a )
315+
316+ def test_with_trailing_comma (self ):
317+ b = """print >>sys.stderr, 1, 2,"""
318+ a = """print(1, 2, end=' ', file=sys.stderr)"""
319+ self .check (b , a )
320+
321+ def test_no_trailing_comma (self ):
322+ b = """print >>sys.stderr, 1+1"""
323+ a = """print(1+1, file=sys.stderr)"""
324+ self .check (b , a )
325+
326+ def test_spaces_before_file (self ):
327+ b = """print >> sys.stderr"""
328+ a = """print(file=sys.stderr)"""
329+ self .check (b , a )
330+
331+ def test_with_future_print_function (self ):
332+ s = "from __future__ import print_function\n " \
333+ "print('Hai!', end=' ')"
334+ self .unchanged (s )
335+
336+ b = "print 'Hello, world!'"
337+ a = "print('Hello, world!')"
338+ self .check (b , a )
339+
340+
341341# class Test_exec(FixerTestCase):
342342# fixer = "exec"
343343#
0 commit comments