INNER CODE UNIT · Python

TestPrecedingComment

connectbot/connectbot · translations/test_translate.py:63

class TestPrecedingComment:
    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]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…