File tree Expand file tree Collapse file tree 4 files changed +57
-15
lines changed
Expand file tree Collapse file tree 4 files changed +57
-15
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+ #
4+ # File: test_attributes.py
5+ # by Arzaroth Lekva
6+ # arzaroth@arzaroth.com
7+ #
8+
9+ def test_first_attribute (init_rapidxml ):
10+ test = init_rapidxml .first_node ().first_node ("test" )
11+ assert test .first_attribute ().name == "attr1"
12+ assert test .first_attribute ().value == "one"
13+ attr2 = test .first_attribute ("attr2" )
14+ assert attr2 .name == "attr2"
15+ assert attr2 .value == "two"
16+
17+ def test_last_attribute (init_rapidxml ):
18+ test = init_rapidxml .first_node ().first_node ("test" )
19+ assert test .last_attribute ().name == "attr3"
20+ assert test .last_attribute ().value == "three"
21+ attr2 = test .last_attribute ("attr2" )
22+ assert attr2 .name == "attr2"
23+ assert attr2 .value == "two"
Original file line number Diff line number Diff line change @@ -39,19 +39,9 @@ def test_equals(init_rapidxml):
3939 assert root .first_node () != root .first_node ("test2" )
4040 assert (root != root ) == (not (root == root ))
4141
42- def test_first_node (init_rapidxml ):
43- root = init_rapidxml .first_node ()
44- assert root .name == "root"
45- assert root .value == ""
46- assert root .unparse () == init_rapidxml .unparse ()
47-
48- def test_nested_node (init_rapidxml ):
49- test = init_rapidxml .first_node ().first_node ("test" )
50- assert test .name == "test"
51- assert test .value == ""
52- test2 = init_rapidxml .first_node ().first_node ("test2" )
53- assert test2 .name == "test2"
54- assert test2 .value == ""
42+ def test_parent (init_rapidxml ):
43+ assert init_rapidxml .parent is None
44+ assert init_rapidxml .first_node ().parent == init_rapidxml
5545
5646def test_assign (init_rapidxml ):
5747 root = init_rapidxml .first_node ()
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def test_children(init_rapidxml):
1515 assert node .value == ""
1616 i_node = i_node .next_sibling ()
1717 if i_node :
18- assert i_node ! = node
18+ assert i_node . previous_sibling () = = node
1919
2020def test_attributes (init_rapidxml ):
2121 test = init_rapidxml .first_node ().first_node ()
@@ -28,4 +28,4 @@ def test_attributes(init_rapidxml):
2828 assert (i_attr .name , i_attr .value ) == expected_attr
2929 i_attr = i_attr .next_attribute ()
3030 if i_attr :
31- assert i_attr ! = attr
31+ assert i_attr . previous_attribute () = = attr
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+ #
4+ # File: test_nodes.py
5+ # by Arzaroth Lekva
6+ # arzaroth@arzaroth.com
7+ #
8+
9+ def test_first_node (init_rapidxml ):
10+ root = init_rapidxml .first_node ()
11+ assert root .name == "root"
12+ assert root .value == ""
13+ assert root .unparse () == init_rapidxml .unparse ()
14+ assert root .first_node () == root .first_node ("test" )
15+ assert root .first_node () != root .first_node ("test2" )
16+
17+ def test_last_node (init_rapidxml ):
18+ root = init_rapidxml .first_node ()
19+ assert root .first_node () != root .last_node ()
20+ assert root .first_node ("test2" ) == root .last_node ("test2" )
21+ assert root .last_node ().value == "some text"
22+
23+ def test_nested_node (init_rapidxml ):
24+ test = init_rapidxml .first_node ().first_node ("test" )
25+ assert test .name == "test"
26+ assert test .value == ""
27+ test2 = init_rapidxml .first_node ().first_node ("test2" )
28+ assert test2 .name == "test2"
29+ assert test2 .value == ""
You can’t perform that action at this time.
0 commit comments