@@ -396,13 +396,37 @@ def testChangeAttr(self):
396
396
dom .unlink ()
397
397
398
398
def testGetAttrList (self ):
399
- pass
399
+ dom = parseString ("<abc/>" )
400
+ el = dom .documentElement
401
+ el .setAttribute ("spam" , "jam" )
402
+ self .confirm (len (el .attributes .items ()) == 1 )
403
+ el .setAttribute ("foo" , "bar" )
404
+ self .confirm (len (el .attributes .items ()) == 2 )
405
+ self .confirm (('spam' , 'jam' ) in el .attributes .items ())
406
+ self .confirm (('foo' , 'bar' ) in el .attributes .items ())
407
+ dom .unlink ()
400
408
401
409
def testGetAttrValues (self ):
402
- pass
410
+ dom = parseString ("<abc/>" )
411
+ el = dom .documentElement
412
+ el .setAttribute ("spam" , "jam" )
413
+ values = [x .value for x in el .attributes .values ()]
414
+ self .confirm ("jam" in values )
415
+ el .setAttribute ("foo" , "bar" )
416
+ values = [x .value for x in el .attributes .values ()]
417
+ self .confirm ("bar" in values )
418
+ dom .unlink ()
403
419
404
420
def testGetAttrLength (self ):
405
- pass
421
+ dom = parseString ("<abc/>" )
422
+ el = dom .documentElement
423
+ el .setAttribute ("spam" , "jam" )
424
+ self .confirm (len (el .attributes .items ()) == 1 )
425
+ el .setAttribute ("foo" , "bar" )
426
+ self .confirm (len (el .attributes .items ()) == 2 )
427
+ el .removeAttribute ("foo" )
428
+ self .confirm (len (el .attributes .items ()) == 1 )
429
+ dom .unlink ()
406
430
407
431
def testGetAttribute (self ):
408
432
dom = Document ()
@@ -496,7 +520,11 @@ def testAttributeRepr(self):
496
520
self .confirm (str (node ) == repr (node ))
497
521
dom .unlink ()
498
522
499
- def testTextNodeRepr (self ): pass
523
+ def testTextNodeRepr (self ):
524
+ dom = Document ()
525
+ el = dom .appendChild (dom .createElement ("foo" ))
526
+ self .confirm (str (el ) == repr (el ))
527
+ dom .unlink ()
500
528
501
529
def testWriteXML (self ):
502
530
str = '<?xml version="1.0" ?><a b="c"/>'
@@ -601,9 +629,21 @@ def testProcessingInstruction(self):
601
629
and pi .localName is None
602
630
and pi .namespaceURI == xml .dom .EMPTY_NAMESPACE )
603
631
604
- def testProcessingInstructionRepr (self ): pass
632
+ def testProcessingInstructionRepr (self ):
633
+ dom = parseString ('<e><?mypi \t \n data \t \n ?></e>' )
634
+ pi = dom .documentElement .firstChild
635
+ string1 = str (pi .nodeType )
636
+ string2 = repr (pi .nodeType )
637
+ self .assertEqual (string1 , string2 )
605
638
606
- def testTextRepr (self ): pass
639
+ def testTextRepr (self ):
640
+ dom = Document ()
641
+ elem = dom .createElement ('elem' )
642
+ elem .appendChild (dom .createTextNode ("foo" ))
643
+ el = elem .firstChild
644
+ string1 = str (el )
645
+ string2 = repr (el )
646
+ self .assertEqual (string1 , string2 )
607
647
608
648
def testWriteText (self ): pass
609
649
0 commit comments