class TestAnonymSurvey(unittest.TestCase): """" Тесты для класса AnonymousSurvey """ def setUp(self): """" Создание опроса и набора ответов для всех тестовых методов """ frage = 'What language did you first learn to speak?' self.my_survey = AnonymousServey(frage) self.responses = ['eng', 'de', 'sp'] def test_store_single_response(self): """" Проверяет, что один ответ сохранен правильно """ self.my_survey.store_response(self.responses[0]) self.assertIn(self.responses[0], self.my_survey.responses) def test_store_three_responses(self): """" Проверяет, что три ответа были сохранены правильно """ for a in self.responses: self.my_survey.store_response(a) for ant in self.responses: self.assertIn(ant, self.my_survey.responses)
class TestAnonymousSurvey(unittest.TestCase): """Test for the class AnonymousSurvey""" def setUp(self): """Create a survey and a set of responses for use in all test methods""" question = "What language did you first learn to speak?" self.my_survey = AnonymousServey(question) self.responses = ['English', 'Swedish', 'Japanese'] def test_store_single_response(self): """Test that a single response is stored properly""" self.my_survey.store_response(self.responses[0]) self.assertIn(self.responses[0], self.my_survey.responses) def test_store_three_responses(self): """Test that three inidvidual responses are stored properly""" for response in self.responses: self.my_survey.store_response(response) for response in self.responses: self.assertIn(response, self.my_survey.responses)
def setUp(self): """" Создание опроса и набора ответов для всех тестовых методов """ frage = 'What language did you first learn to speak?' self.my_survey = AnonymousServey(frage) self.responses = ['eng', 'de', 'sp']
def test_store_single_response(self): question = "What language did you first learn to speak " my_survey = AnonymousServey(question) my_survey.store_response("English") self.assertIn("English", my_survey.responses)
from survey import AnonymousServey question = "What language did you first learn to speak" my_survey = AnonymousServey(question) my_survey.show_question() print("Enter 'q' at any time to quit.\n") while True: response = input("Language: ") if response == "q": break my_survey.store_response(response) print("\nThank you !") my_survey.show_results()
def setUp(self): """Create a survey and a set of responses for use in all test methods""" question = "What language did you first learn to speak?" self.my_survey = AnonymousServey(question) self.responses = ['English', 'Swedish', 'Japanese']