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_deleters(self):
        ae = self.assertEqual

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

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

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

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

        # pipe, no frag, special case
        wl = WikiLink('[[a|#]]')
        del wl.fragment
        del wl.title
        ae(wl.string, '[[|#]]')
Beispiel #3
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|#]]')
def test_title_and_fragment_deleters():
    # no pipe, no frag
    wl = WikiLink('[[a]]')
    del wl.fragment
    assert wl.string == '[[a]]'
    del wl.title
    assert wl.string == '[[]]'

    # no pipe, frag
    wl = WikiLink('[[a#]]')
    del wl.fragment
    assert wl.string == '[[a]]'
    wl.fragment = 'f'
    del wl.title
    assert wl.string == '[[f]]'

    # pipe, no frag
    wl = WikiLink('[[a|]]')
    del wl.fragment
    assert wl.string == '[[a|]]'
    del wl.title
    assert wl.string == '[[|]]'

    # pipe, frag
    wl = WikiLink('[[a#|]]')
    del wl.fragment
    assert wl.string == '[[a|]]'
    wl.fragment = 'f'
    del wl.title
    assert wl.string == '[[f|]]'

    # pipe, no frag, special case
    wl = WikiLink('[[a|#]]')
    del wl.fragment
    del wl.title
    assert wl.string == '[[|#]]'