Exemple #1
0
    def test_min_larger_than_max(self):
        with self.assertRaises(ValueError) as cm:
            NumberValue(name='foo', min=100, max=99)
        self.assertIn('minimum must be smaller than or equal to maximum',
                      str(cm.exception))

        val = NumberValue(name='foo')
        val.min = 50
        with self.assertRaises(ValueError) as cm:
            val.max = 49
        self.assertIn('minimum must be smaller than or equal to maximum',
                      str(cm.exception))
Exemple #2
0
    def test_min(self):
        val = NumberValue(name='foo', min=10)
        with self.assertRaises(ValueError) as cm:
            val.set(9)
        self.assertIn('Too small', str(cm.exception))
        self.assertIn('minimum is 10', str(cm.exception))

        val = NumberValue(name='foo', default=100)
        val.min = 150
        self.assertEqual(val.min, 150)
        self.assertEqual(val.get(), 150)
        self.assertEqual(val.get_default(), 150)
        with self.assertRaises(ValueError) as cm:
            val.set(149)
        self.assertIn('Too small', str(cm.exception))
        self.assertIn('minimum is 150', str(cm.exception))