コード例 #1
0
    def test_store_single_response(self):
        """测试单个答案会被妥善地存储"""
        question = "What language did you first learn to speak?"
        my_survey = AnonymousSurvey(question)
        my_survey.stored_response("english")

        self.assertIn("english", my_survey.responses)
コード例 #2
0
class Test_TestAnonymousSurvey(unittest.TestCase):
    """Testy dla klasy AnonymousSurvey"""
    
    def setUp(self):
        """
        Utworzenie ankiety i zestawu odpowiedzi do użycia 
        we wszystkich metodach testowych
        """
        question = "Jaki jest Twój ojczysty język?"
        self.my_survey = AnonymousSurvey(question)
        self.responses = ['angielski', 'hiszpański', 'polski']

    def test_store_single_response(self):
        """
        Sprawdzenie czy pojedyncza odpowiedź jest prawidłowo
        przechowywana
        """
        self.my_survey.store_response(self.responses[0])
        self.assertIn(self.responses[0], self.my_survey.responses)

    def test_store_three_response(self):
        """
        Sprawdzenie czy trzy pojednyncze odpowiedzi są prawidłowo
        przechowywane
        """
        for response in self.responses:
            self.my_survey.store_response(response)

        for response in self.responses:
            self.assertIn(response, self.my_survey.responses)
コード例 #3
0
 def setUp(self):
     """
     Utworzenie ankiety i zestawu odpowiedzi do użycia 
     we wszystkich metodach testowych
     """
     question = "Jaki jest Twój ojczysty język?"
     self.my_survey = AnonymousSurvey(question)
     self.responses = ['angielski', 'hiszpański', 'polski']
コード例 #4
0
    def test_store_three_response(self):
        """测试三个答案会被妥善存储"""
        question = "What language did you first learn to speak?"
        my_survey = AnonymousSurvey(question)
        responses = ["english", "spanish", "mandarin"]
        for response in responses:
            my_survey.stored_response(response)

        for response in responses:
            self.assertIn(response, my_survey.responses)
コード例 #5
0
class TestAnonymousSurvey(unittest.TestCase):
    """针对AnonymousSurvey类的测试"""
    def setUp(self):
        """创建一个调查对象和一组答案,供使用的测试方法使用"""
        question = " What language did you first learn to speak? "
        self.my_survey = AnonymousSurvey(question)
        self.responses = ["english", "spanish", "mandarin"]

    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 response in self.responses:
            self.my_survey.store_response(response)
        for response in self.responses:
            self.assertIn(response, self.my_survey.responses)
コード例 #6
0
from Survey import AnonymousSurvey

#定义一个问题,并创建一个表示调查的AnonymousSurvey
question = "What language did you first learn to speak?"
my_survey = AnonymousSurvey(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.stored_response(response)
#显示调查结果
print("\nThank you to everyone who participated in the survey!")
my_survey.show_results()
コード例 #7
0
 def setUp(self):
     """ Create a survey and a set of responses for use in all test methods.
     """
     question = "What lang was your first language?"
     my_survey = AnonymousSurvey(question)
     responses = ['English', 'Spanish', 'Mandarin']
コード例 #8
0
 def setUp(self):
     """创建一个调查对象和一组答案,供使用的测试方法使用"""
     question = " What language did you first learn to speak? "
     self.my_survey = AnonymousSurvey(question)
     self.responses = ["english", "spanish", "mandarin"]