@@ -346,7 +346,7 @@ def __exit__(self, exc_type, exc_value, exc_tb):
346
346
self ._stack .pop ()
347
347
348
348
def __repr__ (self ):
349
- return "<HTML {} 0x{:x}>" . format ( self . _name , id ( self ))
349
+ return f "<HTML { self . _name } 0x{ id ( self ) :x} >"
350
350
351
351
def _stringify (self , str_type ):
352
352
# turn me and my content into text
@@ -424,19 +424,19 @@ def _stringify(self, str_type):
424
424
class TestCase (unittest .TestCase ):
425
425
def test_empty_tag (self ):
426
426
"generation of an empty HTML tag"
427
- self .assertEquals (str (HTML ().br ), "<br>" )
427
+ self .assertEqual (str (HTML ().br ), "<br>" )
428
428
429
429
def test_empty_tag_xml (self ):
430
430
"generation of an empty XHTML tag"
431
- self .assertEquals (str (XHTML ().br ), "<br />" )
431
+ self .assertEqual (str (XHTML ().br ), "<br />" )
432
432
433
433
def test_tag_add (self ):
434
434
"test top-level tag creation"
435
- self .assertEquals (str (HTML ("html" , "text" )), "<html>\n text\n </html>" )
435
+ self .assertEqual (str (HTML ("html" , "text" )), "<html>\n text\n </html>" )
436
436
437
437
def test_tag_add_no_newline (self ):
438
438
"test top-level tag creation"
439
- self .assertEquals (
439
+ self .assertEqual (
440
440
str (HTML ("html" , "text" , newlines = False )), "<html>text</html>"
441
441
)
442
442
@@ -445,7 +445,7 @@ def test_iadd_tag(self):
445
445
h = XML ("xml" )
446
446
h += XML ("some-tag" , "spam" , newlines = False )
447
447
h += XML ("text" , "spam" , newlines = False )
448
- self .assertEquals (
448
+ self .assertEqual (
449
449
str (h ),
450
450
"<xml>\n <some-tag>spam</some-tag>\n <text>spam</text>\n </xml>" ,
451
451
)
@@ -455,79 +455,79 @@ def test_iadd_text(self):
455
455
h = HTML ("html" , newlines = False )
456
456
h += "text"
457
457
h += "text"
458
- self .assertEquals (str (h ), "<html>texttext</html>" )
458
+ self .assertEqual (str (h ), "<html>texttext</html>" )
459
459
460
460
def test_xhtml_match_tag (self ):
461
461
"check forced generation of matching tag when empty"
462
- self .assertEquals (str (XHTML ().p ), "<p></p>" )
462
+ self .assertEqual (str (XHTML ().p ), "<p></p>" )
463
463
464
464
if sys .version_info [0 ] == 2 :
465
465
466
466
def test_empty_tag_unicode (self ):
467
467
"generation of an empty HTML tag"
468
- self .assertEquals (unicode (HTML ().br ), unicode ("<br>" ))
468
+ self .assertEqual (unicode (HTML ().br ), unicode ("<br>" ))
469
469
470
470
def test_empty_tag_xml_unicode (self ):
471
471
"generation of an empty XHTML tag"
472
- self .assertEquals (unicode (XHTML ().br ), unicode ("<br />" ))
472
+ self .assertEqual (unicode (XHTML ().br ), unicode ("<br />" ))
473
473
474
474
def test_xhtml_match_tag_unicode (self ):
475
475
"check forced generation of matching tag when empty"
476
- self .assertEquals (unicode (XHTML ().p ), unicode ("<p></p>" ))
476
+ self .assertEqual (unicode (XHTML ().p ), unicode ("<p></p>" ))
477
477
478
478
def test_just_tag (self ):
479
479
"generate HTML for just one tag"
480
- self .assertEquals (str (HTML ().br ), "<br>" )
480
+ self .assertEqual (str (HTML ().br ), "<br>" )
481
481
482
482
def test_just_tag_xhtml (self ):
483
483
"generate XHTML for just one tag"
484
- self .assertEquals (str (XHTML ().br ), "<br />" )
484
+ self .assertEqual (str (XHTML ().br ), "<br />" )
485
485
486
486
def test_xml (self ):
487
487
"generate XML"
488
- self .assertEquals (str (XML ().br ), "<br />" )
489
- self .assertEquals (str (XML ().p ), "<p />" )
490
- self .assertEquals (str (XML ().br ("text" )), "<br>text</br>" )
488
+ self .assertEqual (str (XML ().br ), "<br />" )
489
+ self .assertEqual (str (XML ().p ), "<p />" )
490
+ self .assertEqual (str (XML ().br ("text" )), "<br>text</br>" )
491
491
492
492
def test_para_tag (self ):
493
493
"generation of a tag with contents"
494
494
h = HTML ()
495
495
h .p ("hello" )
496
- self .assertEquals (str (h ), "<p>hello</p>" )
496
+ self .assertEqual (str (h ), "<p>hello</p>" )
497
497
498
498
def test_escape (self ):
499
499
"escaping of special HTML characters in text"
500
500
h = HTML ()
501
501
h .text ("<>&" )
502
- self .assertEquals (str (h ), "<>&" )
502
+ self .assertEqual (str (h ), "<>&" )
503
503
504
504
def test_no_escape (self ):
505
505
"no escaping of special HTML characters in text"
506
506
h = HTML ()
507
507
h .text ("<>&" , False )
508
- self .assertEquals (str (h ), "<>&" )
508
+ self .assertEqual (str (h ), "<>&" )
509
509
510
510
def test_escape_attr (self ):
511
511
"escaping of special HTML characters in attributes"
512
512
h = HTML ()
513
513
h .br (id = '<>&"' )
514
- self .assertEquals (str (h ), '<br id="<>&"">' )
514
+ self .assertEqual (str (h ), '<br id="<>&"">' )
515
515
516
516
def test_subtag_context (self ):
517
517
'generation of sub-tags using "with" context'
518
518
h = HTML ()
519
519
with h .ol :
520
520
h .li ("foo" )
521
521
h .li ("bar" )
522
- self .assertEquals (str (h ), "<ol>\n <li>foo</li>\n <li>bar</li>\n </ol>" )
522
+ self .assertEqual (str (h ), "<ol>\n <li>foo</li>\n <li>bar</li>\n </ol>" )
523
523
524
524
def test_subtag_direct (self ):
525
525
"generation of sub-tags directly on the parent tag"
526
526
h = HTML ()
527
527
l = h .ol
528
528
l .li ("foo" )
529
529
l .li .b ("bar" )
530
- self .assertEquals (
530
+ self .assertEqual (
531
531
str (h ), "<ol>\n <li>foo</li>\n <li><b>bar</b></li>\n </ol>"
532
532
)
533
533
@@ -537,7 +537,7 @@ def test_subtag_direct_context(self):
537
537
with h .ol as l :
538
538
l .li ("foo" )
539
539
l .li .b ("bar" )
540
- self .assertEquals (
540
+ self .assertEqual (
541
541
str (h ), "<ol>\n <li>foo</li>\n <li><b>bar</b></li>\n </ol>"
542
542
)
543
543
@@ -547,35 +547,35 @@ def test_subtag_no_newlines(self):
547
547
l = h .ol (newlines = False )
548
548
l .li ("foo" )
549
549
l .li ("bar" )
550
- self .assertEquals (str (h ), "<ol><li>foo</li><li>bar</li></ol>" )
550
+ self .assertEqual (str (h ), "<ol><li>foo</li><li>bar</li></ol>" )
551
551
552
552
def test_add_text (self ):
553
553
"add text to a tag"
554
554
h = HTML ()
555
555
p = h .p ("hello, world!\n " )
556
556
p .text ("more text" )
557
- self .assertEquals (str (h ), "<p>hello, world!\n more text</p>" )
557
+ self .assertEqual (str (h ), "<p>hello, world!\n more text</p>" )
558
558
559
559
def test_add_text_newlines (self ):
560
560
"add text to a tag with newlines for prettiness"
561
561
h = HTML ()
562
562
p = h .p ("hello, world!" , newlines = True )
563
563
p .text ("more text" )
564
- self .assertEquals (str (h ), "<p>\n hello, world!\n more text\n </p>" )
564
+ self .assertEqual (str (h ), "<p>\n hello, world!\n more text\n </p>" )
565
565
566
566
def test_doc_newlines (self ):
567
567
"default document adding newlines between tags"
568
568
h = HTML ()
569
569
h .br
570
570
h .br
571
- self .assertEquals (str (h ), "<br>\n <br>" )
571
+ self .assertEqual (str (h ), "<br>\n <br>" )
572
572
573
573
def test_doc_no_newlines (self ):
574
574
"prevent document adding newlines between tags"
575
575
h = HTML (newlines = False )
576
576
h .br
577
577
h .br
578
- self .assertEquals (str (h ), "<br><br>" )
578
+ self .assertEqual (str (h ), "<br><br>" )
579
579
580
580
def test_unicode (self ):
581
581
"make sure unicode input works and results in unicode output"
@@ -588,7 +588,7 @@ def test_unicode(self):
588
588
unicode = str
589
589
TEST = "euro €"
590
590
h .p (TEST )
591
- self .assertEquals (unicode (h ), "<p>%s</p>" % TEST )
591
+ self .assertEqual (unicode (h ), "<p>%s</p>" % TEST )
592
592
593
593
def test_table (self ):
594
594
'multiple "with" context blocks'
@@ -598,7 +598,7 @@ def test_table(self):
598
598
with h .tr :
599
599
h .td ("column 1" )
600
600
h .td ("column 2" )
601
- self .assertEquals (
601
+ self .assertEqual (
602
602
str (h ),
603
603
"""<table border="1">
604
604
<tr><td>column 1</td><td>column 2</td></tr>
0 commit comments