Exemplo n.º 1
0
def test_small_vocab():
    l = ["eeny", "moe", "miney", "meeny"]
    vocab = Vocab(l)
    assert vocab.has("moe")
    assert vocab.has("eeny")
    assert vocab.has("miney")
    assert vocab.has("meeny")
    assert not vocab.has("many")
    assert sorted(vocab.as_list()) == sorted(l)
Exemplo n.º 2
0
def test_empty_vocab():
    """
    Nothing is present in an empty word list
    """
    vocab = Vocab([])
    assert vocab.as_list() == []
    assert not vocab.has("sheep")
Exemplo n.º 3
0
def test_from_simulated_file():
    from io import StringIO
    l = StringIO(initial_value="""
        #comment
        # another comment line
        sheep

        rats
        #comment
        squirrels
        """)
    vocab = Vocab(l)
    assert sorted(vocab.as_list()) == ["rats", "sheep", "squirrels"]
    assert vocab.has("sheep")
    assert vocab.has("rats")
    assert vocab.has("squirrels")
    assert not vocab.has("#comment")
Exemplo n.º 4
0
def test_single_vocab():
    vocab = Vocab(["moe"])
    assert vocab.as_list() == ["moe"]
    assert vocab.has("moe")
    assert not vocab.has("meeny")