Example #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
Example #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
Example #3
0
 def test_get_entries(self):
     parser = QLCParserWithRowsAndCols(test_data('KSL.qlc'), 'gloss', 'cogid', {})
     assert parser.get_entries('cogid')
Example #4
0
 def test_get_entries(self):
     parser = QLCParserWithRowsAndCols(test_data('KSL.qlc'), 'concept',
                                       'cogid', {})
     assert parser.get_entries('cogid')