@@ -299,40 +299,43 @@ def gen2():
299
299
doc = "print"
300
300
ok = False
301
301
try :
302
- print ("hello" , sep = 1 )
302
+ print ("hello" , sep = 1 , end = "!" )
303
303
except TypeError as e :
304
- # if e.args[0] != "sep must be None or a string , not int":
305
- # raise
304
+ if e .args [0 ] != "print() argument 1 must be str , not int" :
305
+ raise
306
306
ok = True
307
307
assert ok , "TypeError not raised"
308
308
309
309
try :
310
- print ("hello" , sep = " " , end = 1 )
310
+ print ("hello" , sep = ", " , end = 1 )
311
311
except TypeError as e :
312
- # if e.args[0] != "end must be None or a string , not int":
313
- # raise
312
+ if e .args [0 ] != "print() argument 2 must be str , not int" :
313
+ raise
314
314
ok = True
315
315
assert ok , "TypeError not raised"
316
316
317
317
try :
318
- print ("hello" , sep = " " , end = "\n " , file = 1 )
318
+ print ("hello" , sep = ", " , end = "! " , file = 1 )
319
319
except AttributeError as e :
320
- # if e.args[0] != "'int' object has no attribute 'write'":
321
- # raise
320
+ if e .args [0 ] != "'int' has no attribute 'write'" :
321
+ raise
322
322
ok = True
323
323
assert ok , "AttributeError not raised"
324
324
325
325
with open ("testfile" , "w" ) as f :
326
- print ("hello" , "world" , sep = " " , end = "\n " , file = f )
326
+ print ("hello" , "world" , end = "!\n " , file = f , sep = ", " )
327
+ print ("hells" , "bells" , end = "..." , file = f )
328
+ print (" ~" , "Brother " , "Foo" , "bar" , file = f , end = "" , sep = "" )
327
329
328
330
with open ("testfile" , "r" ) as f :
329
- assert f .read () == "hello world\n "
331
+ assert f .read () == "hello, world! \n hells bells... ~Brother Foobar "
330
332
331
333
with open ("testfile" , "w" ) as f :
332
- print (1 ,2 ,3 ,sep = "," ,end = ",\n " , file = f )
334
+ print (1 ,2 ,3 ,sep = "," , flush = False , end = ",\n " , file = f )
335
+ print ("4" ,5 , file = f , end = "!" , flush = True , sep = "," )
333
336
334
337
with open ("testfile" , "r" ) as f :
335
- assert f .read () == "1,2,3,\n "
338
+ assert f .read () == "1,2,3,\n 4,5! "
336
339
337
340
doc = "round"
338
341
assert round (1.1 ) == 1.0
0 commit comments