def test_dictionary_considers_dictzip_as_valid(fs): fs.create_file("/tmp/valid_path/foo.ifo") fs.create_file("/tmp/valid_path/foo.idx") fs.create_file("/tmp/valid_path/foo.dict.dz") d = stargaze.Dictionary("/tmp/valid_path") assert len(d.configs) == 1
def test_dictionary_considers_syn_file_optional(fs): fs.create_file("/tmp/valid_path/foo.ifo") fs.create_file("/tmp/valid_path/foo.idx") fs.create_file("/tmp/valid_path/foo.dict") d = stargaze.Dictionary("/tmp/valid_path") assert len(d.configs) == 1
def test_dictionary_lookup(): d = stargaze.Dictionary("./docs/words") r = d.lookup("word1") assert r == "word1_defn"
def test_dictionary_throws_for_directory_without_dict(fs): fs.create_file("/tmp/invalid_path/foo.ifo") fs.create_file("/tmp/invalid_path/foo.idx") with pytest.raises(stargaze.DictionaryError): stargaze.Dictionary("/tmp/invalid_path")
def test_dictionary_throws_for_invalid_path(fs): with pytest.raises(ValueError): stargaze.Dictionary("/tmp/nonexistent_path")