Beispiel #1
0
    def test_rules_property(self):
        """Test that answer normalization behaves as expected."""
        interaction = base.BaseInteraction()
        interaction.answer_type = None
        interaction.normalize_answer('15')

        interaction.answer_type = 'NonnegativeInt'
        interaction.normalize_answer('15')

        with self.assertRaisesRegexp(Exception, 'not a valid object class'):
            interaction.answer_type = 'FakeObjType'
            interaction.normalize_answer('15')
Beispiel #2
0
    def test_rules_property(self):
        """Test that interaction.rules behaves as expected."""
        interaction = base.BaseInteraction()
        interaction.answer_type = 'Null'
        interaction.normalize_answer('15')
        self.assertEqual(interaction.rules, [])

        interaction.answer_type = 'NonnegativeInt'
        self.assertEqual(len(interaction.rules), 1)
        interaction.normalize_answer('15')

        with self.assertRaisesRegexp(Exception, 'not a valid object class'):
            interaction.answer_type = 'FakeObjType'
            interaction.normalize_answer('15')