@@ -337,6 +337,73 @@ def test_set_indent_error(self):
337
337
with pytest .raises (TypeError , match = "'size' argument cannot be used when providing an 'Indent' object." ):
338
338
sl .set_indent (Indent (0 , " " ), 5 )
339
339
340
+ def test_extend (self ):
341
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
342
+ sl .extend (["\n foo\n bar\n baz" ])
343
+
344
+ assert sl == ["" , '' , "hello" , "world" , '' , '' , '' , "1234" , '' , "foo" , "bar" , " baz" ]
345
+
346
+ def test_clear (self ):
347
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
348
+ sl .clear ()
349
+
350
+ assert sl == []
351
+
352
+ def test_copy (self ):
353
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
354
+ sl2 = sl .copy ()
355
+
356
+ assert sl == sl2
357
+ assert sl2 == ["" , '' , "hello" , "world" , '' , '' , '' , "1234" ]
358
+ assert isinstance (sl2 , StringList )
359
+
360
+ def test_count (self ):
361
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
362
+ assert sl .count ("hello" ) == 1
363
+
364
+ def test_count_blanklines (self ):
365
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
366
+ assert sl .count_blanklines () == 5
367
+
368
+ def test_index (self ):
369
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
370
+ assert sl .index ("hello" ) == 2
371
+
372
+ def test_pop (self ):
373
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
374
+ assert sl .pop (2 ) == "hello"
375
+ assert sl == ["" , '' , "world" , '' , '' , '' , "1234" ]
376
+ assert isinstance (sl , StringList )
377
+
378
+ def test_remove (self ):
379
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
380
+ sl .remove ("hello" )
381
+ assert sl == ["" , '' , "world" , '' , '' , '' , "1234" ]
382
+ assert isinstance (sl , StringList )
383
+
384
+ def test_reverse (self ):
385
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
386
+ sl .reverse ()
387
+ assert sl == ["1234" , '' , '' , '' , "world" , "hello" , '' , '' ]
388
+ assert isinstance (sl , StringList )
389
+
390
+ def test_sort (self ):
391
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
392
+ sl .sort ()
393
+ assert sl == ['' , '' , '' , '' , '' , "1234" , "hello" , "world" ]
394
+ assert isinstance (sl , StringList )
395
+
396
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
397
+ sl .sort (reverse = True )
398
+ assert sl == ["world" , "hello" , "1234" , '' , '' , '' , '' , '' ]
399
+ assert isinstance (sl , StringList )
400
+
401
+ def test_str (self ):
402
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
403
+ assert str (sl ) == "\n \n hello\n world\n \n \n \n 1234"
404
+ sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" , '' ])
405
+ assert str (sl ) == "\n \n hello\n world\n \n \n \n 1234\n "
406
+
340
407
341
408
class TestIndent :
342
409
@@ -418,70 +485,3 @@ def test_eq(self):
418
485
assert Indent (2 , "\t " ) == '\t \t '
419
486
420
487
assert not Indent () == 1
421
-
422
- def test_extend (self ):
423
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
424
- sl .extend (["\n foo\n bar\n baz" ])
425
-
426
- assert sl == ["" , '' , "hello" , "world" , '' , '' , '' , "1234" , '' , "foo" , "bar" , " baz" ]
427
-
428
- def test_clear (self ):
429
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
430
- sl .clear ()
431
-
432
- assert sl == []
433
-
434
- def test_copy (self ):
435
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
436
- sl2 = sl .copy ()
437
-
438
- assert sl == sl2
439
- assert sl2 == ["" , '' , "hello" , "world" , '' , '' , '' , "1234" ]
440
- assert isinstance (sl2 , StringList )
441
-
442
- def test_count (self ):
443
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
444
- assert sl .count ("hello" ) == 1
445
-
446
- def test_count_blanklines (self ):
447
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
448
- assert sl .count_blanklines () == 5
449
-
450
- def test_index (self ):
451
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
452
- assert sl .index ("hello" ) == 2
453
-
454
- def test_pop (self ):
455
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
456
- assert sl .pop (2 ) == "hello"
457
- assert sl == ["" , '' , "world" , '' , '' , '' , "1234" ]
458
- assert isinstance (sl , StringList )
459
-
460
- def test_remove (self ):
461
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
462
- sl .remove ("hello" )
463
- assert sl == ["" , '' , "world" , '' , '' , '' , "1234" ]
464
- assert isinstance (sl , StringList )
465
-
466
- def test_reverse (self ):
467
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
468
- sl .reverse ()
469
- assert sl == ["1234" , '' , '' , '' , "world" , "hello" , '' , '' ]
470
- assert isinstance (sl , StringList )
471
-
472
- def test_sort (self ):
473
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
474
- sl .sort ()
475
- assert sl == ['' , '' , '' , '' , '' , "1234" , "hello" , "world" ]
476
- assert isinstance (sl , StringList )
477
-
478
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
479
- sl .sort (reverse = True )
480
- assert sl == ["world" , "hello" , "1234" , '' , '' , '' , '' , '' ]
481
- assert isinstance (sl , StringList )
482
-
483
- def test_str (self ):
484
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" ])
485
- assert str (sl ) == "\n \n hello\n world\n \n \n \n 1234"
486
- sl = StringList (["" , '' , "hello" , "world" , '' , '' , '' , "1234" , '' ])
487
- assert str (sl ) == "\n \n hello\n world\n \n \n \n 1234\n "
0 commit comments