MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_expandItem

Method test_expandItem

Lib/test/test_pulldom.py:108–138  ·  view source on GitHub ↗

Ensure expandItem works as expected.

(self)

Source from the content-addressed store, hash-verified

106
107 @unittest.expectedFailure # TODO: RUSTPYTHON; pulldom.parseString(SMALL_SAMPLE) return iterator with tuple with 2 elements
108 def test_expandItem(self):
109 """Ensure expandItem works as expected."""
110 items = pulldom.parseString(SMALL_SAMPLE)
111 # Loop through the nodes until we get to a "title" start tag:
112 for evt, item in items:
113 if evt == pulldom.START_ELEMENT and item.tagName == "title":
114 items.expandNode(item)
115 self.assertEqual(1, len(item.childNodes))
116 break
117 else:
118 self.fail("No \"title\" element detected in SMALL_SAMPLE!")
119 # Loop until we get to the next start-element:
120 for evt, node in items:
121 if evt == pulldom.START_ELEMENT:
122 break
123 self.assertEqual("hr", node.tagName,
124 "expandNode did not leave DOMEventStream in the correct state.")
125 # Attempt to expand a standalone element:
126 items.expandNode(node)
127 self.assertEqual(next(items)[0], pulldom.CHARACTERS)
128 evt, node = next(items)
129 self.assertEqual(node.tagName, "p")
130 items.expandNode(node)
131 next(items) # Skip character data
132 evt, node = next(items)
133 self.assertEqual(node.tagName, "html")
134 with self.assertRaises(StopIteration):
135 next(items)
136 items.clear()
137 self.assertIsNone(items.parser)
138 self.assertIsNone(items.stream)
139
140 @unittest.expectedFailure
141 def test_comment(self):

Callers

nothing calls this directly

Calls 9

lenFunction · 0.85
nextFunction · 0.85
expandNodeMethod · 0.80
assertIsNoneMethod · 0.80
parseStringMethod · 0.45
assertEqualMethod · 0.45
failMethod · 0.45
assertRaisesMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected