def test_combine_label_accesskey(): """ test that we can combine accesskey and label to create a label+accesskey string """ assert accesskey.combine("File", "F") == "&File" assert accesskey.combine("File", "F", "~") == "~File"
def test_combine_label_accesskey_different_capitals(): """test that we can combine accesskey and label to create a label+accesskey string when we have more then one case or case is wrong.""" # Prefer the correct case, even when an alternate case occurs first assert accesskey.combine(u"Close Other Tabs", u"o") == u"Cl&ose Other Tabs" assert accesskey.combine(u"Other Closed Tab", u"o") == u"Other Cl&osed Tab" assert accesskey.combine(u"Close Other Tabs", u"O") == u"Close &Other Tabs" # Correct case is missing from string, so use alternate case assert accesskey.combine(u"Close Tabs", u"O") == u"Cl&ose Tabs" assert accesskey.combine(u"Other Tabs", u"o") == u"&Other Tabs"
def convertmixedunit(self, labeldtd, accesskeydtd): labelpo = self.convertunit(labeldtd) accesskeypo = self.convertunit(accesskeydtd) if labelpo is None: return accesskeypo if accesskeypo is None: return labelpo thepo = po.pounit(encoding="UTF-8") thepo.addlocations(labelpo.getlocations()) thepo.addlocations(accesskeypo.getlocations()) thepo.msgidcomment = thepo._extract_msgidcomments() + labelpo._extract_msgidcomments() thepo.msgidcomment = thepo._extract_msgidcomments() + accesskeypo._extract_msgidcomments() thepo.addnote(labelpo.getnotes("developer"), "developer") thepo.addnote(accesskeypo.getnotes("developer"), "developer") thepo.addnote(labelpo.getnotes("translator"), "translator") thepo.addnote(accesskeypo.getnotes("translator"), "translator") # redo the strings from original dtd... label = dtd.unquotefromdtd(labeldtd.definition).decode('UTF-8') accesskey = dtd.unquotefromdtd(accesskeydtd.definition).decode('UTF-8') label = accesskeyfn.combine(label, accesskey) if label is None: return None thepo.source = label thepo.target = "" return thepo
def test_unicode(): """test that we can do the same with unicode strings""" assert accesskey.extract(u"Eḓiṱ") == (u"Eḓiṱ", u"") assert accesskey.extract(u"E&ḓiṱ") == (u"Eḓiṱ", u"ḓ") assert accesskey.extract(u"E_ḓiṱ", u"_") == (u"Eḓiṱ", u"ḓ") label, akey = accesskey.extract(u"E&ḓiṱ") assert label, akey == (u"Eḓiṱ", u"ḓ") assert isinstance(label, unicode) and isinstance(akey, unicode) assert accesskey.combine(u"Eḓiṱ", u"ḓ") == (u"E&ḓiṱ")
def test_unicode(): """test that we can do the same with unicode strings""" assert accesskey.extract(u"Eḓiṱ") == (u"Eḓiṱ", u"") assert accesskey.extract(u"E&ḓiṱ") == (u"Eḓiṱ", u"ḓ") assert accesskey.extract(u"E_ḓiṱ", u"_") == (u"Eḓiṱ", u"ḓ") label, akey = accesskey.extract(u"E&ḓiṱ") assert label, akey == (u"Eḓiṱ", u"ḓ") assert isinstance(label, six.text_type) and isinstance(akey, six.text_type) assert accesskey.combine(u"Eḓiṱ", u"ḓ") == (u"E&ḓiṱ")
def test_uncombinable(): """test our behaviour when we cannot combine label and accesskey""" assert accesskey.combine(u"File", u"D") is None assert accesskey.combine(u"File", u"") is None assert accesskey.combine(u"", u"") is None
def test_combine_label_accesskey(): """test that we can combine accesskey and label to create a label+accesskey string""" assert accesskey.combine(u"File", u"F") == u"&File" assert accesskey.combine(u"File", u"F", u"~") == u"~File"
def test_numeric(): """test combining and extracting numeric markers""" assert accesskey.extract(u"&100%") == (u"100%", u"1") assert accesskey.combine(u"100%", u"1") == u"&100%"
def test_accesskey_already_in_text(): """test that we can combine if the accesskey is already in the text""" assert accesskey.combine(u"Mail & Newsgroups", u"N") == u"Mail & &Newsgroups"
def test_uncombinable(): """test our behaviour when we cannot combine label and accesskey""" assert accesskey.combine(u"File", u"D") is None
def test_accesskey_already_in_text(): """test that we can combine if the accesskey is already in the text""" assert accesskey.combine(u"Mail & Newsgroups", u"N") == u"Mail & &Newsgroups" assert accesskey.extract(u"Mail & &Newsgroups") == (u"Mail & Newsgroups", u"N")