-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThirdRoundTests.py
More file actions
36 lines (31 loc) · 1.72 KB
/
Copy pathThirdRoundTests.py
File metadata and controls
36 lines (31 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from ThirdRound import ThirdRound
from Player import Player
from Button import Button
from TextBoxForQuestions import TextBoxForQuestions
import pygame
import unittest
class ThirdRoundTest(unittest.TestCase):
def setUp(self):
pygame.init()
self.third_round = ThirdRound(Player())
def test_create_interface(self):
self.third_round.random_question = self.third_round._choose_random_question(self.third_round.loaded_data)
self.third_round.correct_answers = self.third_round.random_question["answer(s)"]
original_generated_questions = self.third_round.generated_questions
self.third_round._create_interface()
expected_attributes_for_singleplayer = {
'objects':[self.third_round.question_text,self.third_round.skip_button,self.third_round.type_area],
'found_answer' : None,
'generated_questions':original_generated_questions+1
}
self.assertIsInstance(self.third_round.question_text,Button)
self.assertIsInstance(self.third_round.type_area,TextBoxForQuestions)
self.assertIsInstance(self.third_round.skip_button,Button)
instance_attributes = vars(self.third_round)
for attr_name, expected_value in expected_attributes_for_singleplayer.items():
self.assertTrue(attr_name in instance_attributes)
self.assertEqual(instance_attributes[attr_name], expected_value)
self.assertTrue(pygame.mixer.get_init(),True)
self.assertIsInstance(self.third_round.sound,pygame.mixer.Sound)
if __name__=='__main__':
unittest.main()