示例#1
0
 def test_load_string(self):
     """
     Test that InterWikiMap.from_unicode correctly loads unicode objects.
     """
     # test for void wiki maps
     assert InterWikiMap.from_string(u'').iwmap == dict()
     assert InterWikiMap.from_string(u'#spam\r\n').iwmap == dict()
     # test for comments
     s = ('# foo bar\n'
          '#spamham\r\n'
          '#       space     space\n'
          'foo bar\r\n'
          'ham spam # this is a valid description')
     assert InterWikiMap.from_string(s).iwmap == dict(foo='bar', ham='spam')
     # test for valid strings
     s = ('link1 http://link1.com/\r\n' 'link2 http://link2.in/\r\n')
     assert (InterWikiMap.from_string(s).iwmap == dict(
         link1='http://link1.com/', link2='http://link2.in/'))
     # test invalid strings
     with pytest.raises(ValueError):
         InterWikiMap.from_string(u'foobarbaz')
示例#2
0
 def test_load_string(self):
     """
     Test that InterWikiMap.from_unicode correctly loads unicode objects.
     """
     # test for void wiki maps
     assert InterWikiMap.from_string(u'').iwmap == dict()
     assert InterWikiMap.from_string(u'#spam\r\n').iwmap == dict()
     # test for comments
     s = ('# foo bar\n'
          '#spamham\r\n'
          '#       space     space\n'
          'foo bar\r\n'
          'ham spam # this is a valid description')
     assert InterWikiMap.from_string(s).iwmap == dict(foo='bar', ham='spam')
     # test for valid strings
     s = ('link1 http://link1.com/\r\n'
          'link2 http://link2.in/\r\n')
     assert (InterWikiMap.from_string(s).iwmap ==
             dict(link1='http://link1.com/',
                  link2='http://link2.in/'))
     # test invalid strings
     with pytest.raises(ValueError):
         InterWikiMap.from_string(u'foobarbaz')