def test_store_single_response(self):
        """ Test that a single response is stored properly """
        question = "q1"
        my_survey = survey.AnonymousSurvey(question)
        my_survey.store_response('English')

        self.assertIn('English', my_survey.responses)
Esempio n. 2
0
 def test_store_sigle_response(self):
     """测试单个答案会被妥善保存"""
     question = "Who is your name?"
     # 定义实例对象
     my_survey = survey.AnonymousSurvey(question)
     # 存入一个答案
     my_survey.store_response("Zhang Bin")
     # 比较答案
     self.assertIn("Zhang Bin", my_survey.responses)
Esempio n. 3
0
    def test_store_three_responses(self):
        """测试三个答案"""
        question = "Who is your name?"
        #定义一个实例对象
        my_survey = survey.AnonymousSurvey(question)
        #填入三个答案
        responses = ['Zhang Bin', 'Li Jian Ting', 'Duo Duo']
        for response in responses:
            my_survey.store_response(response)

        for response in responses:
            self.assertIn(response, my_survey.responses)
Esempio n. 4
0
import survey


#定义一个问题,并创建一个表示调查的AnonymousSurvey对象
question="What language did you first learn to speak ?"
my_survey=survey.AnonymousSurvey(question)

#显示问题并存储答案
my_survey.show_question()
print("Enter 'q' at any time to quit.\n")
while True:
    respone=input('Language: ')
    if respone == 'q':
        break
    my_survey.store_response(respone)

print("\nThank you to everyone who participated in the survey!")
my_survey.show_results()
Esempio n. 5
0
 def setUp(self):
     """
        Create a survey and a set of responses for use in all test methods.
     """
     self.question = "q1"
     self.my_survey = survey.AnonymousSurvey(self.question)
Esempio n. 6
0
 def setUp(self):
     """创建一次实例和答案,供测试使用"""
     question = "Who is your name?"
     self.my_survey = survey.AnonymousSurvey(question)
     self.responses = ["Zhang Bin", "Li Jian Ting", "Duo Duo"]