def test_title_and_fragment_setters():
    # no frag, no pipe
    wl = WikiLink('[[a]]')
    wl.title = 'b'
    assert wl.string == '[[b]]'
    wl.fragment = 'c'
    assert wl.string == '[[b#c]]'

    # frag, no pipe
    wl.fragment = 'c'
    assert wl.string == '[[b#c]]'
    wl.title = 'a'
    assert wl.string == '[[a#c]]'

    # frag, pipe
    wl.text = ''  # [[d#c|]]
    wl.fragment = 'e'
    assert wl.string == '[[a#e|]]'
    wl.title = 'b'
    assert wl.string == '[[b#e|]]'

    # no frag, pipe
    del wl.fragment
    wl.fragment = 'e'
    assert wl.string == '[[b#e|]]'
    del wl.fragment
    wl.title = 'a'
    assert wl.string == '[[a|]]'

    # no frag after pipe
    wl = WikiLink('[[a|#]]')
    wl.title = 'b'
    assert wl.string == '[[b|#]]'
    wl.fragment = 'f'
    assert wl.string == '[[b#f|#]]'
Beispiel #2
0
    def test_title_and_fragment_setters(self):
        ae = self.assertEqual

        # no frag, no pipe
        wl = WikiLink('[[a]]')
        wl.title = 'b'
        ae(wl.string, '[[b]]')
        wl.fragment = 'c'
        ae(wl.string, '[[b#c]]')

        # frag, no pipe
        wl.fragment = 'c'
        ae(wl.string, '[[b#c]]')
        wl.title = 'a'
        ae(wl.string, '[[a#c]]')

        # frag, pipe
        wl.text = ''  # [[d#c|]]
        wl.fragment = 'e'
        ae(wl.string, '[[a#e|]]')
        wl.title = 'b'
        ae(wl.string, '[[b#e|]]')

        # no frag, pipe
        del wl.fragment
        wl.fragment = 'e'
        ae(wl.string, '[[b#e|]]')
        del wl.fragment
        wl.title = 'a'
        ae(wl.string, '[[a|]]')

        # no frag after pipe
        wl = WikiLink('[[a|#]]')
        wl.title = 'b'
        ae(wl.string, '[[b|#]]')
        wl.fragment = 'f'
        ae(wl.string, '[[b#f|#]]')