Пример #1
0
class test_BoundedIntVar(unittest.TestCase):
    """ verify functionality of the BoundedIntVar variable class
    """
    def setUp(self):
        self.bivar = BoundedIntVar('name','description', min=3, max=10)
        self.defaultminvar = BoundedIntVar('name', 'description', max=10)
        self.defaultmaxvar = BoundedIntVar('name', 'description', min=3)
        self.max = sys.maxint
        self.min = -self.max-1
    
    def testValidation(self):
        """ A BoundedIntVar should take values between min and max (inclusive)
            If max is not provided, default to sys.maxint
            if min is not provided, default to -sys.maxint-1
        """
        self.assertEqual(4, self.bivar.validate(4))
        self.assertEqual(5, self.bivar.validate(5.9))
        self.assertEqual(6, self.bivar.validate('6'))
        
        self.assertRaises(ValidationException, self.bivar.validate, 'four')
        self.assertRaises(ValidationException, self.bivar.validate, 1)
        self.assertRaises(ValidationException, self.bivar.validate, 11)
        
        self.assertEqual(self.max, self.defaultmaxvar.validate(self.max))
        self.assertEqual(self.min, self.defaultminvar.validate(self.min))
Пример #2
0
class test_BoundedIntVar(unittest.TestCase):
    """ verify functionality of the BoundedIntVar variable class
    """
    def setUp(self):
        self.bivar = BoundedIntVar('name', 'description', min=3, max=10)
        self.defaultminvar = BoundedIntVar('name', 'description', max=10)
        self.defaultmaxvar = BoundedIntVar('name', 'description', min=3)
        self.max = sys.maxint
        self.min = -self.max - 1

    def testValidation(self):
        """ A BoundedIntVar should take values between min and max (inclusive)
            If max is not provided, default to sys.maxint
            if min is not provided, default to -sys.maxint-1
        """
        self.assertEqual(4, self.bivar.validate(4))
        self.assertEqual(5, self.bivar.validate(5.9))
        self.assertEqual(6, self.bivar.validate('6'))

        self.assertRaises(ValidationException, self.bivar.validate, 'four')
        self.assertRaises(ValidationException, self.bivar.validate, 1)
        self.assertRaises(ValidationException, self.bivar.validate, 11)

        self.assertEqual(self.max, self.defaultmaxvar.validate(self.max))
        self.assertEqual(self.min, self.defaultminvar.validate(self.min))
Пример #3
0
                            page='Main',
                            default='',
                            help="""
Your buildout will have a single user, "%(zope_user)s", with manager 
privileges, defined at the root. This option lets you select the initial
password for this user. If left blank, the password will be randomly
generated.
""")

VAR_HTTP = BoundedIntVar(
    'http_port',
    title='HTTP Port',
    description='Port that Zope will use for serving HTTP',
    default='8080',
    modes=(EXPERT, EASY),
    page='Main',
    help="""
This options lets you select the port # that Zope will use for serving
HTTP.
""",
    min=1024,
    max=65535,
)

VAR_DEBUG_MODE = OnOffVar('debug_mode',
                          title='Debug Mode',
                          description='Should debug mode be "on" or "off"?',
                          default='off',
                          modes=(EXPERT, EASY),
                          page='Main',
                          help="""
Debug mode (sometimes called "Debug/Development Mode") is the correct
Пример #4
0
 def setUp(self):
     self.bivar = BoundedIntVar('name','description', min=3, max=10)
     self.defaultminvar = BoundedIntVar('name', 'description', max=10)
     self.defaultmaxvar = BoundedIntVar('name', 'description', min=3)
     self.max = sys.maxint
     self.min = -self.max-1
Пример #5
0
 def setUp(self):
     self.bivar = BoundedIntVar('name', 'description', min=3, max=10)
     self.defaultminvar = BoundedIntVar('name', 'description', max=10)
     self.defaultmaxvar = BoundedIntVar('name', 'description', min=3)
     self.max = sys.maxint
     self.min = -self.max - 1