コード例 #1
0
ファイル: test_vars.py プロジェクト: Rub3nC/buildout_tutorial
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
ファイル: test_vars.py プロジェクト: kkdhanesh/NBADEMO
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
ファイル: test_vars.py プロジェクト: Rub3nC/buildout_tutorial
 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
ファイル: test_vars.py プロジェクト: kkdhanesh/NBADEMO
 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