示例#1
0
def test_write(tmpdir):
    fname = pathlib.Path(str(tmpdir)) / 'profile.tsv'
    prf = Profile({
        'Grapheme': 'ab',
        'IPA': 'z'
    }, {
        'Grapheme': 'x',
        'IPA': 'y'
    })
    prf.write(fname)
    assert Profile.from_file(fname).graphemes == prf.graphemes
示例#2
0
def test_write(tmp_path):
    fname = tmp_path / 'profile.tsv'
    prf = Profile({
        'Grapheme': 'ab',
        'IPA': 'z'
    }, {
        'Grapheme': 'x',
        'IPA': 'y'
    })
    prf.write(fname)
    assert Profile.from_file(fname).graphemes == prf.graphemes
示例#3
0
    def orthography_profile_dict(self):
        res = {}
        profile = self.etc_dir / 'orthography.tsv'
        profile_dir = self.etc_dir / 'orthography'
        if profile.exists():
            res[None] = profile
        if profile_dir.exists() and profile_dir.is_dir():
            for p in profile_dir.glob('*.tsv'):
                res[p.stem] = p

        return {
            k: Profile.from_file(str(p), form='NFC')
            for k, p in res.items()
        }
示例#4
0
def test_check(caplog, tmpdir, clts):
    prf_path = pathlib.Path(str(tmpdir)) / 'profile.tsv'

    prf_path.write_text('Grapheme\tIPA\na\tx\na\tx\n')
    prf = Profile.from_file(prf_path)
    prf.check(log=logging.getLogger(__name__))
    assert caplog.records[-1].levelname == 'WARNING'

    prf_path.write_text('Grapheme\tIPA\na\tx\na\ty\n')
    prf.check(log=logging.getLogger(__name__))
    assert caplog.records[-1].levelname == 'ERROR'

    prf_path.write_text('Grapheme\tIPA\na\t°\n')
    prf.check(clts=clts, log=logging.getLogger(__name__))
    assert caplog.records[-1].levelname == 'ERROR'