Beispiel #1
0
def test_catalog_write_mo(dir):
    (dir / 'test.po').write_text('#')
    cat = i18n.CatalogInfo(dir, 'test', 'utf-8')
    cat.write_mo('en')
    assert path.exists(cat.mo_path)
    with open(cat.mo_path, 'rb') as f:
        assert read_mo(f) is not None
Beispiel #2
0
def test_catalog_write_mo(tempdir):
    (tempdir / 'test.po').write_text('#')
    cat = i18n.CatalogInfo(tempdir, 'test', 'utf-8')
    cat.write_mo('en', lambda *a, **kw: None)
    assert os.path.exists(cat.mo_path)
    with open(cat.mo_path, 'rb') as f:
        assert read_mo(f) is not None
Beispiel #3
0
def test_catalog_outdated(dir):
    (dir / 'test.po').write_text('#')
    cat = i18n.CatalogInfo(dir, 'test', 'utf-8')
    assert cat.is_outdated()  # if mo is not exist

    mo_file = (dir / 'test.mo')
    mo_file.write_text('#')
    assert not cat.is_outdated()  # if mo is exist and newer than po

    os.utime(mo_file, (os.stat(mo_file).st_mtime - 10,) * 2) # to be outdate
    assert cat.is_outdated()  # if mo is exist and older than po
Beispiel #4
0
def test_catalog_info_for_sub_domain_file_and_path():
    cat = i18n.CatalogInfo('path', 'sub/domain', 'utf-8')
    assert cat.po_file == 'sub/domain.po'
    assert cat.mo_file == 'sub/domain.mo'
    assert cat.po_path == path.join('path', 'sub/domain.po')
    assert cat.mo_path == path.join('path', 'sub/domain.mo')
Beispiel #5
0
def test_catalog_info_for_file_and_path():
    cat = i18n.CatalogInfo('path', 'domain')
    assert cat.po_file == 'domain.po'
    assert cat.mo_file == 'domain.mo'
    assert cat.po_path == path.join('path', 'domain.po')
    assert cat.mo_path == path.join('path', 'domain.mo')