Exemplo n.º 1
0
 def test_nested_element(self):
     result = flatten_xml_from_string('<a><b/></a>')
     expected = [
         ['a'],
         ['a', 'b'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 2
0
 def test_nested_element(self):
     result = flatten_xml_from_string('<a><b/></a>')
     expected = [
         ['a'],
         ['a', 'b'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 3
0
 def test_triple_nested(self):
     result = flatten_xml_from_string('<a><b><c/><d/></b><e/></a>')
     expected = [
         ['a'],
         ['a', 'b'],
         ['a', 'b', 'c'],
         ['a', 'b', 'd'],
         ['a', 'e'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 4
0
 def test_triple_nested(self):
     result = flatten_xml_from_string('<a><b><c/><d/></b><e/></a>')
     expected = [
         ['a'],
         ['a', 'b'],
         ['a', 'b', 'c'],
         ['a', 'b', 'd'],
         ['a', 'e'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 5
0
 def test_with_text_multiple(self):
     result = flatten_xml_from_string('<a>foo<b>bar</b><b>baz</b></a>', )
     expected = [
         ['a'],
         ['a', '!foo'],
         ['a', 'b'],
         ['a', 'b', '!bar'],
         ['a', 'b'],
         ['a', 'b', '!baz'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 6
0
 def test_with_text_multiple(self):
     result = flatten_xml_from_string(
         '<a>foo<b>bar</b><b>baz</b></a>',
     )
     expected = [
         ['a'],
         ['a', '!foo'],
         ['a', 'b'],
         ['a', 'b', '!bar'],
         ['a', 'b'],
         ['a', 'b', '!baz'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 7
0
 def test_with_text_and_tail(self):
     result = flatten_xml_from_string(
         '<a>foo<b>bar</b>baz<c>cat</c>dog</a>', )
     expected = [
         ['a'],
         ['a', '!foo'],
         ['a', 'b'],
         ['a', 'b', '!bar'],
         ['a', '!baz'],
         ['a', 'c'],
         ['a', 'c', '!cat'],
         ['a', '!dog'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 8
0
 def test_with_text_and_tail(self):
     result = flatten_xml_from_string(
         '<a>foo<b>bar</b>baz<c>cat</c>dog</a>',
     )
     expected = [
         ['a'],
         ['a', '!foo'],
         ['a', 'b'],
         ['a', 'b', '!bar'],
         ['a', '!baz'],
         ['a', 'c'],
         ['a', 'c', '!cat'],
         ['a', '!dog'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 9
0
 def test_single_element(self):
     result = flatten_xml_from_string('<p/>')
     expected = [
         ['p'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 10
0
 def test_empty_string(self):
     result = flatten_xml_from_string('')
     self.assertEqual(result, '')
Exemplo n.º 11
0
 def test_single_element(self):
     result = flatten_xml_from_string('<p/>')
     expected = [
         ['p'],
     ]
     self.assertEqual(result, expected)
Exemplo n.º 12
0
 def test_empty_string(self):
     result = flatten_xml_from_string('')
     self.assertEqual(result, '')