def test_count_vowels(self):
     self.assertEqual(count_vowels("Python"), 2)
     self.assertEqual(count_vowels("Theistareykjarbunga"), 8)
     self.assertEqual(count_vowels("grrrrgh!"), 0)
     self.assertEqual(
         count_vowels(
             "Github is the second best thing that happend to programmers, after the keyboard!"
         ), 22)
     self.assertEqual(count_vowels("A nice day to code!"), 8)
Пример #2
0
def count_consonants(string):
    letters = 0
    for char in string:
        if char.isalpha():
            letters += 1

    return letters - count_vowels(string)
    def test_returns_number_of_vowoles_in_text(self):
        #ARRANGE
        text = 'boat'

        #ACT
        result = count_vowels(text)

        #ASSERT
        self.assertEqual(result, 2)
    def test_returns_zero_if_empty_text_passed(self):
        #ARRANGE
        text = ''

        #ACT
        result = count_vowels(text)

        #ASSERT
        self.assertEqual(result, 0)
Пример #5
0
def count_consonants(str):

    del_char = [chr(x) for x in range(32, 65)]
    del_char += [chr(x) for x in range(91, 97)]
    # ASCII table http://www.bibase.com/images/ascii.gif
    del_char += [chr(x) for x in range(123, 126)]

    for char in del_char:
        str = str.replace(char, "")

    return len(str) - count_vowels(str)
def test_count_vowels_e():
    assert count_vowels('e') == 1
 def test_count_vowels(self):
     self.assertEqual(count_vowels("Python"), 2)
     self.assertEqual(count_vowels("Theistareykjarbunga"), 8)
     self.assertEqual(count_vowels("grrrrgh!"), 0)
     self.assertEqual(count_vowels("Github is the second best thing that happend to programmers, after the keyboard!"), 22)
     self.assertEqual(count_vowels("A nice day to code!"), 8)
def test_list():
    with pytest.raises(AttributeError):
        count_vowels(['abcdefg'])
 def test_four(self):
     self.assertEqual(22, count_vowels("Github is the second best thing that happend to programmers, after the keyboard!"))
def test_count_vowels_empty():
    assert count_vowels('') == 0
def test_count_vowels_non_vowels():
    assert count_vowels('sthvxyz., & ') == 0
 def test_two(self):
     self.assertEqual(8, count_vowels("Theistareykjarbunga"))
 def test_one(self):
     self.assertEqual(2, count_vowels("Python"))
 def test_five(self):
     self.assertEqual(8, count_vowels("A nice day to code!"))
def test_count_vowels_lowercase_vowels():
    assert count_vowels('aeiou') == 5
def test_count_vowels_uppercase_IOU():
    assert count_vowels('IOU') == 3
Пример #17
0
import count_vowels

file = open("message.txt", "w", encoding="utf-8")
file.write("lorem ipsem dolor sit ames")
file.close()

file = open("message.txt", "r", encoding="utf-8")
content = file.read()

count = count_vowels.count_vowels(content)


print("number of vowels in message.txt = " + str(count))
def test_count_vowels_Anglia_Ruskin():
    assert count_vowels('Anglia Ruskin University') == 9
Пример #19
0
 def test_count_vowels(self):
     self.assertEqual(count_vowels("Pineapple"), 4)
     self.assertEqual(count_vowels("Badge"), 2)
     self.assertEqual(count_vowels("Cryptocurrency"), 3)
     print("\nPassed count_vowels with no errors!")
def test_count_vowels(
        s, count):  # part 3: the variables are parameters for the function
    # part 4: we use the variables (parameters) in our test
    assert count_vowels(s) == count
 def test_three(self):
     self.assertEqual(0, count_vowels("grrrrgh!"))