Beispiel #1
0
def test_init(test_data):
    p = QLCParser({0: ['a']})
    QLCParser(p)
    with pytest.raises(IOError):
        QLCParser('not-extisting-file')
    with pytest.raises(TypeError):
        QLCParser(None)
    with pytest.raises(ValueError):
        QLCParserWithRowsAndCols({0: ['a']}, 'x', 'y', {})

    with pytest.raises(ValueError):
        QLCParserWithRowsAndCols(
            {
                0: ['concept', 'language', 'bla'],
                1: ['bla', 'blu']
            }, 'concept', 'language', '')

    p2 = QLCParserWithRowsAndCols(str(test_data / 'bad_file2.tsv'), 'concept',
                                  'language', data_path('conf', 'wordlist.rc'))

    assert p2.get_entries('cogid')[0][-1] == 'ff'
    with pytest.raises(KeyError):
        p2.__getitem__(tuple([2000, 'bla']))
    assert p2[3, 'language'] == 'l3'
    assert p2[3, 'nothing'] is None
Beispiel #2
0
 def test_init(self):
     p = QLCParser({0: ['a']})
     QLCParser(p)
     self.assertRaises(IOError, QLCParser, 'not-extisting-file')
     self.assertRaises(TypeError, QLCParser, None)
     self.assertRaises(ValueError, QLCParserWithRowsAndCols, {0: ['a']}, 'x', 'y', {})
     
     self.assertRaises(ValueError, QLCParserWithRowsAndCols, 
             {0: ['concept', 'language', 'bla'],
                 1 : ['bla', 'blu']}, 'concept', 'language', '')
     
     p2 = QLCParserWithRowsAndCols(test_data('bad_file2.tsv'), 'concept',
         'language', data_path('conf', 'wordlist.rc'))
     assert p2.get_entries('cogid')[0][-1] == 'ff'
     self.assertRaises(KeyError, p2.__getitem__, tuple([2000, 'bla']))
     assert p2[3, 'language'] == 'l3'
     assert p2[3, 'nothing'] is None
Beispiel #3
0
    def setUp(self):
        from lingpy.basic.parser import QLCParser

        self.parser = QLCParser(test_data('KSL.qlc'))
 def setUp(self):
     self.parser = QLCParser(test_data('KSL.qlc'))
Beispiel #5
0
def parser(test_data):
    return QLCParser(str(test_data / 'KSL.qlc'))