Example #1
0
    def test_Dictionary(self):
        from clldutils.sfm import SFM

        d = SFM.from_file(FIXTURES.joinpath('test.sfm'))
        self.assertEquals(len(d), 2)
        tmp = self.tmp_path('test')
        d.write(tmp)
        d2 = SFM()
        d2.read(tmp)
        self.assertEquals(d[0].get('marker'), d2[0].get('marker'))
        self.assertEquals(d[1].get('marker'), d2[1].get('marker'))

        self.assertEquals(d[0].get('key'), None)
        d.visit(lambda e: e.append(('key', 'value')))
        self.assertEquals(d[0].get('key'), 'value')
Example #2
0
def test_Dictionary(tmppath):
    p = Path(__file__).parent.joinpath('fixtures', 'test.sfm')
    d = SFM.from_file(p, keep_empty=True)
    assert d[1].get('empty') is not None

    d = SFM.from_file(p)
    assert len(d) == 2
    assert d[1].get('empty') is None
    tmp = tmppath / 'test'
    d.write(tmp)
    d2 = SFM()
    d2.read(tmp)
    assert d[0].get('marker') == d2[0].get('marker')
    assert d[1].get('marker') == d2[1].get('marker')

    assert d[0].get('key') is None
    d.visit(lambda e: e.append(('key', 'value')))
    assert d[0].get('key') == 'value'
Example #3
0
 def read(self, filename, **kw):
     return SFM.read(self, filename, entry_impl=Example, **kw)
Example #4
0
 def read(self, filename, **kw):
     return SFM.read(self, filename, entry_impl=Example, **kw)