Пример #1
0
def test_repeated_word_capital(lengthy):
    """
    The first repeated word is found in a lengthy string with a case-sensative string.
    """

    expected = 'the'
    actual = repeated_word(lengthy)
    assert actual == expected
Пример #2
0
def test_repeated_word(lengthy):
    """
    The first repeated word is found in a lengthy string.
    """

    lengthy.replace('The', 'the')

    expected = 'the'
    actual = repeated_word(lengthy)
    assert actual == expected
Пример #3
0
def test_no_repeated_word():
    """
    Strings without a repeated word show a null return.
    """

    lengthy = 'The quick brown fox jumps over a lazy dog'

    expected = None
    actual = repeated_word(lengthy)
    assert actual == expected
Пример #4
0
def test_repeated_word_punctuation(lengthy):
    """
    The right first repeated word is found even with punctuation in the string.
    """

    lengthy.replace('the', 'the,')

    expected = 'the'
    actual = repeated_word(lengthy)
    assert actual == expected
Пример #5
0
def test_repeated_word_two():
    actual = repeated_word(
        'It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way – in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only...'
    )
    expected = 'it'
    assert actual == expected


# def test_repeated_word_three():
#     actual = repeated_word('It was a queer, sultry summer, the summer they electrocuted the Rosenbergs, and I didn’t know what I was doing in New York...')
#     expected = 'summer'
#     assert actual == expected
Пример #6
0
def test_string_validation():
    """test string validation returns TypeError"""
    with pytest.raises(TypeError):
        repeated_word([1, 2, 3])
    with pytest.raises(TypeError):
        repeated_word(9)    
    with pytest.raises(TypeError):
        repeated_word({'string': 'value'})
Пример #7
0
def test_long_random_string():
    string = "Apple apricot alpaca banana Bermuda boat cat catnip catsup, or is it ketchup?, dog doll dogstar doggie Eyeore eyesore eye flight fright fight great greater grate holliday Hollywood Halle Berry igloo ignore ignatious jelly jealous jellybean jeans kettle should have put ketchup here llama mama pajama drama "
    word = repeated_word(string)
    assert word == 'ketchup'
def test_lower():
    lengthy = "James james james  bond Bond james'."
    word = repeated_word(lengthy)
    assert word == 'james'
def test_long_string():
    string = "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way – in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only..."	
    word = repeated_word(string)
    assert word == 'it'
def test_sample3():
    input = "It was a queer, sultry summer, the summer they electrocuted the Rosenbergs, and I didn't know what I was doing in New York..."
    expected = "summer"
    actual = repeated_word(input)
    assert expected == actual
def test_repeated_word_no_repeat():
    my_string = "This is my string"
    actual = repeated_word(my_string)
    expected = 'No Duplicate'
    assert actual == expected
def test_repeated_word_big_string(large_string):
    actual = repeated_word(large_string)
    expected = "a"
Пример #13
0
def test_repeated_word_pass():
    stuff = 'cat and a cat'
    assert repeated_word(stuff) == 'cat'
Пример #14
0
def test_repeated_word_fail():
    stuff = 'there are no repeating words'
    assert repeated_word(stuff) == 'No matching words.'
def test_repeated_word():
    string = 'cat dog bat dog'
    actual = repeated_word(string)
    expected = 'dog'
    assert actual == expected
Пример #16
0
def test_repeated_word():
    actual = repeated_word(
        "It was a queer, sultry summer, the summer they electrocuted the Rosenbergs, and I didn’t know what I was doing in New York..."
    )
    expected = 'summer'
    assert actual == expected
def test_repeated_word(small_string):
    actual = repeated_word(small_string)
    expected = "is"
    assert actual == expected
Пример #18
0
def test_repeated_word_pass_again():
    stuff = 'the cat in the hat'
    assert repeated_word(stuff) == 'the'
def test_repeated_word_raise_error_typeerror():
    with pytest.raises(AttributeError):
        repeated_word(123041230)
Пример #20
0
def test_repeated_word_no_dupes():
    with pytest.raises(KeyError):
        repeated_word('It was a bright cold day in April, and the clocks were \
                       striking thirteen.')
def test_repeated_word_none_input():
    with pytest.raises(AttributeError):
        repeated_word(None)
Пример #22
0
def test_repeated_word_type_error():
    with pytest.raises(TypeError):
        repeated_word(42)
def test_sample1():
    input = "Once upon a time, there was a brave princess who..."

    expected = "a"
    actual = repeated_word(input)
    assert expected == actual
Пример #24
0
def test_repeated_word_long():
    dupe = repeated_word('In the week before their departure \
                   to Arrakis, when all the final scurrying about had reached \
                   a nearly unbearable frenzy, an old crone came to visit the \
                   mother of the boy, Paul.')
    assert dupe == 'the'
def test_string():
    lengthy = "Once upon a time, there was a brave princess who.."
    word = repeated_word(lengthy)
    assert word == 'a'
Пример #26
0
def test_repeated_word_punctuation_fail():
    actual = repeated_word(
        'It was a queer, sultry summer, the summer they electrocuted the Rosenbergs, and I didn’t know what I was doing in New York...'
    )
    expected = 'the'
    assert actual != expected
Пример #27
0
def test_not_repeated():
    string = "Apple banana cat dog elephant fruitfly."
    word = repeated_word(string)
    assert word == None
Пример #28
0
def test_repeated_word_normal():
    actual = repeated_word(
        'Once upon a time, there was a brave princess who...')
    expected = 'a'
    assert actual == expected
Пример #29
0
def test_string():
    string = "It was a queer, sultry summer, the summer they electrocuted the Rosenbergs, and I didn\'t know what I was doing in New York..."
    word = repeated_word(string)
    assert word == 'summer'
Пример #30
0
def test_repeated_word_2():
    actual = repeated_word(
        "Once upon a time, there was a brave princess who...")
    expected = "a"
    assert actual == expected