Beispiel #1
0
def test_main():
    """Test trigrams main function."""
    import trigrams
    assert len(trigrams.main('text/text_test.txt', 5).split(' ')) == 5
Beispiel #2
0
def test_main():
    """Test main output function."""
    from trigrams import main
    res = main('LICENSE', 5)
    assert res >= 1
Beispiel #3
0
def test_main():
    """Test that our listed function produced the desired output."""
    from trigrams import main
    assert len(main('sherlock.txt', 100).split()) == 100
    assert type(main('sherlock.txt', 100)) == str
Beispiel #4
0
def test_num_words():
    """."""
    from trigrams import main
    text = main('test.txt', 500)
    assert len(text.split()) == 500
Beispiel #5
0
def test_file_length():
    """Test to check trigram file length."""
    from trigrams import main
    assert len(main(TEST_STRING2, TEST_LENGTH).split()) == TEST_LENGTH
Beispiel #6
0
def test_main_text_length_returns_expected():
    """Test that main function returns meets the requested number of words."""
    from trigrams import main
    assert len((main('sherlock_small.txt', 50).split(" "))) >= 50
Beispiel #7
0
def test_open_text_file():
    """Test that main function can open a file."""
    from trigrams import main
    main('test_book.txt', 1)
Beispiel #8
0
def test_zero_words_from_main():
    """Test that main funciton returns empty string for 0 words."""
    from trigrams import main
    assert main('test_book.txt', 0) == ''
Beispiel #9
0
def test_invalid_text_file():
    """Test that main function raises exception on non-existant file."""
    from trigrams import main
    with pytest.raises(FileNotFoundError):
        main('test_text.txt', 1)