コード例 #1
0
    def test_get_message_skip(self):
        e = Enforce(1, '==', 1)
        skip = [
            Comparator.IN,
            Comparator.NOT_IN,
            Comparator.INSTANCE_OF,
            Comparator.NOT_INSTANCE_OF,
        ]

        expected = '{a} is {comparator.message} {b}.'
        for item in skip:
            result = e._get_message(None, item)
            self.assertEqual(result, expected)

        expected = '{attribute} of {a} is {comparator.message} {attribute} of {b}.'
        for item in skip:
            result = e._get_message('foo', item)
            self.assertEqual(result, expected)
コード例 #2
0
 def test_get_message_not_similar(self):
     e = Enforce(1, '==', 1)
     result = e._get_message('foo', Comparator.NOT_SIMILAR)
     expected = '{attribute} of {a} is {comparator.message} {attribute} of '
     expected += '{b}. Delta {delta} is not greater than epsilon {epsilon}.'
     self.assertEqual(result, expected)
コード例 #3
0
 def test_get_message_attribute(self):
     e = Enforce(1, '==', 1)
     result = e._get_message('foo', Comparator.EQ)
     expected = '{attribute} of {a} is {comparator.message} {attribute} of '
     expected += '{b}. {a_val} {comparator.negation_symbol} {b_val}.'
     self.assertEqual(result, expected)