INNER CODE UNIT · Python
test_picks_up_comment_before_element
connectbot/connectbot · translations/test_translate.py:64
def test_picks_up_comment_before_element(self):
root = resources_elem('<!-- Window title -->\n<string name="title">Hello</string>')
elem = root.find("string")
assert preceding_comment(elem) == "Window title"
def test_returns_empty_when_no_comment(self):
root = resources_elem('<string name="title">Hello</string>')
elem = root.find("string")
assert preceding_comment(elem) == ""
def test_stops_at_intervening_element(self):
root = resources_elem(
'<!-- Old comment -->\n'
'<string name="other">Other</string>\n'
'<string name="title">Hello</string>'
)
elem = root.findall("string")[1]
assert preceding_comment(elem) == ""