コード例 #1
0
ファイル: test_python.py プロジェクト: dokai/lingua
def test_multiline_string():
    global source
    options = mock.Mock()
    options.keywords = []
    source = b"""_('one two '\n'three')"""
    messages = list(extract_python("filename", options))
    assert len(messages) == 1
    assert messages[0].msgid == "one two three"
コード例 #2
0
ファイル: test_python.py プロジェクト: dokai/lingua
def test_syntax_error():
    global source
    options = mock.Mock()
    options.keywords = []
    source = b"""def class xya _('foo')"""
    with pytest.raises(SystemExit):
        generator = extract_python("filename", options)
        list(generator)
コード例 #3
0
def test_multiline_string():
    global source
    options = mock.Mock()
    options.keywords = []
    source = b'''_('one two '\n'three')'''
    messages = list(extract_python('filename', options))
    assert len(messages) == 1
    assert messages[0].msgid == 'one two three'
コード例 #4
0
def test_syntax_error():
    global source
    options = mock.Mock()
    options.keywords = []
    source = b'''def class xya _('foo')'''
    with pytest.raises(SystemExit):
        generator = extract_python('filename', options)
        list(generator)
コード例 #5
0
ファイル: test_python.py プロジェクト: dokai/lingua
def test_plural():
    global source
    options = mock.Mock()
    options.keywords = []
    source = b"""ngettext('one cow', '%d cows', 5)"""
    messages = list(extract_python("filename", options))
    assert len(messages) == 1
    assert messages[0].msgid == "one cow"
    assert messages[0].msgid_plural == "%d cows"
コード例 #6
0
def test_plural():
    global source
    options = mock.Mock()
    options.keywords = []
    source = b'''ngettext('one cow', '%d cows', 5)'''
    messages = list(extract_python('filename', options))
    assert len(messages) == 1
    assert messages[0].msgid == 'one cow'
    assert messages[0].msgid_plural == '%d cows'
コード例 #7
0
ファイル: test_python.py プロジェクト: AnneGilles/lingua
 def extract(self, snippet):
     from lingua.extractors.python import extract_python
     from StringIO import StringIO
     snippet = StringIO(snippet)
     return list(extract_python(snippet, ['_'], None, None))
コード例 #8
0
 def extract(self, snippet):
     from lingua.extractors.python import extract_python
     from StringIO import StringIO
     snippet = StringIO(snippet)
     return list(extract_python(snippet, ['_'], None, None))
コード例 #9
0
ファイル: test_python.py プロジェクト: MatthewWilkes/lingua
 def extract(self, snippet):
     from lingua.extractors.python import extract_python
     from StringIO import StringIO
     snippet = StringIO(snippet)
     return list(extract_python(snippet, {'_':None, 'pluralize':(1,2)}, None, None))