Best Python code snippet using Kiwi_python
validator.py
Source:validator.py
...73 if self.default:74 return "", self.default75 return "", None76 if self.valid_value:77 parsed_value = self.valid_value(value)78 if parsed_value is None:79 error_msg = "{} {} is not valid".format(name, value)80 elif self.arg_type is not None and self.arg_type is not type(parsed_value):81 logging.warning("arg_type is {} but valid_value returned {}. They should match"82 .format(self.arg_type, type(parsed_value)))83 return error_msg, parsed_value84 assert value is not None and self.valid_value is None and error_msg == "" and self.arg_type is not None85 if self.arg_type is list: # Parsing to a list requires special processing86 error_msg, parsed_value = _parse_param_to_list(name, value)87 if error_msg:88 return error_msg, parsed_value89 else:90 try:91 parsed_value = self.arg_type(value)...
test_conversion.py
Source:test_conversion.py
1# -*- Mode: Python -*-2import unittest3from common import gtk, gobject4class Tests(unittest.TestCase):5 def testUnicharArg(self):6 """ Test unichar values when used as arguments. """7 entry = gtk.Entry()8 for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]:9 entry.set_invisible_char(valid_value)10 self.assertEqual(entry.get_invisible_char(),11 unicode(valid_value),12 valid_value)13 for invalid_value in ('12', None, 1, ''):14 try:15 entry.set_invisible_char(invalid_value)16 except:17 pass18 else:19 raise AssertionError(20 'exception not raised on invalid value w/ '21 'set_invisible_char: %s' % invalid_value)22 def testUnicharProperty(self):23 """ Test unichar values when used as properties. """24 entry = gtk.Entry()25 for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]:26 entry.set_property('invisible_char', valid_value)27 self.assertEqual(entry.get_property('invisible_char'),28 valid_value, valid_value)29 for invalid_value in ('12', None, 1, ''):30 try:31 entry.set_property('invisible_char', invalid_value)32 except TypeError:33 pass34 else:35 raise AssertionError(36 'exception not raised on invalid value w/ '37 'set_invisible_char: %s' % invalid_value)38 def testUnicharConstructor(self):39 for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]:40 entry = gobject.new(gtk.Entry, invisible_char=valid_value)41 self.assertEqual(entry.get_property('invisible_char'),42 valid_value, valid_value)43 def testUIntArg(self):44 child = gtk.DrawingArea()45 table = gtk.Table(2, 2, False)46 table.attach(child, 1, 2, 0, 1, ypadding=2)47 self.assertEqual(table.child_get_property(child, 'y-padding'), 2)48 child = gtk.DrawingArea()49 table.attach(child, 1, 2, 0, 1, ypadding=2L)50 self.assertEqual(table.child_get_property(child, 'y-padding'), 2)51if __name__ == '__main__':...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!