# count_vowels.py
#задача #автоматизация #python #pytest
def count_vowels(input_string):# test_count_vowels.py
vowels = "AEIOUaeiou"
return sum(1 for char in input_string if char in vowels)
import pytest
from count_vowels import count_vowels
def test_regular_string():
assert count_vowels("hello") == 2
assert count_vowels("python") == 1
def test_empty_string():
assert count_vowels("") == 0
def test_string_with_no_vowels():
assert count_vowels("xyz") == 0
assert count_vowels("bcdfghjklmnpqrstvwxyz") == 0
def test_string_with_all_vowels():
assert count_vowels("AEIOUaeiou") == 10
def test_mixed_string():
assert count_vowels("Hello World") == 3
assert count_vowels("Programming is fun!") == 6
данном примере функция count_vowels()
принимает на вход строку, состоящую из латинских букв и возвращает количество гласных букв в данной строке. Подсчет гласных осуществляется посредством проверки вхождения каждого символа в строку, в которой есть только все гласные буквы. Тесты проверяют правильность работы функции для различных входных данных.#задача #автоматизация #python #pytest