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