diff options
Diffstat (limited to 'testapp/exam/tests.py')
-rw-r--r-- | testapp/exam/tests.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/testapp/exam/tests.py b/testapp/exam/tests.py index 29c22ac..2a5f1e7 100644 --- a/testapp/exam/tests.py +++ b/testapp/exam/tests.py @@ -142,18 +142,22 @@ class QuestionPaperTestCases(unittest.TestCase): def test_get_random_questions(self): """ Test get_random_questions() method of Question Paper""" - random_questions_set_1 = set(self.question_set_1. - get_random_questions()) - random_questions_set_2 = set(self.question_set_2. - get_random_questions()) + random_questions_set_1 = self.question_set_1.get_random_questions() + random_questions_set_2 = self.question_set_2.get_random_questions() # To check whether random questions are from random_question_set - boolean = set(self.question_set_1.questions.all()).\ - intersection(random_questions_set_1)\ - == random_questions_set_1 + questions_set_1 = set(self.question_set_1.questions.all()) + random_set_1 = set(random_questions_set_1) + random_set_2 = set(random_questions_set_2) + boolean = questions_set_1.intersection(random_set_1) == random_set_1 self.assertTrue(boolean) - self.assertEqual(len(random_questions_set_1), 2) - self.assertFalse(random_questions_set_1 == random_questions_set_2) + self.assertEqual(len(random_set_1), 2) + # To check that the questions are random. + # If incase not random then check that the order is diferent + try: + self.assertFalse(random_set_1 == random_set_2) + except AssertionError: + self.assertTrue(random_questions_set_1 != random_questions_set_2) def test_get_questions_for_answerpaper(self): """ Test get_questions_for_answerpaper() method of Question Paper""" |