Best Python code snippet using hypothesis
parser_operators.py
Source:parser_operators.py
...21 self.assertIsInstance(atoms[0], operators.add.ParseBinaryAddIntegerInteger)22 def test_integer_float(self):23 atoms, deps = parse(tokenise("1 + 1.0"), {})24 self.assertIsInstance(atoms[0], operators.add.ParseBinaryAddIntegerFloat)25 def test_float_float(self):26 atoms, deps = parse(tokenise("1.0 + 1.0"), {})27 self.assertIsInstance(atoms[0], operators.add.ParseBinaryAddFloatFloat)28 def test_float_integer(self):29 atoms, deps = parse(tokenise("1.0 + 1"), {})30 self.assertIsInstance(atoms[0], operators.add.ParseBinaryAddFloatInteger)31class ParserOperatorTestSubtract(unittest.TestCase):32 def test_integer_integer(self):33 atoms, deps = parse(tokenise("1 - 1"), {})34 self.assertIsInstance(atoms[0], operators.subtract.ParseBinarySubtractIntegerInteger)35 def test_integer_float(self):36 atoms, deps = parse(tokenise("1 - 1.0"), {})37 self.assertIsInstance(atoms[0], operators.subtract.ParseBinarySubtractIntegerFloat)38 def test_float_float(self):39 atoms, deps = parse(tokenise("1.0 - 1.0"), {})40 self.assertIsInstance(atoms[0], operators.subtract.ParseBinarySubtractFloatFloat)41 def test_float_integer(self):42 atoms, deps = parse(tokenise("1.0 - 1"), {})43 self.assertIsInstance(atoms[0], operators.subtract.ParseBinarySubtractFloatInteger)44class ParserOperatorTestDivide(unittest.TestCase):45 def test_integer_integer(self):46 atoms, deps = parse(tokenise("1 / 1"), {})47 self.assertIsInstance(atoms[0], operators.divide.ParseBinaryDivideIntegerInteger)48 def test_integer_float(self):49 atoms, deps = parse(tokenise("1 / 1.0"), {})50 self.assertIsInstance(atoms[0], operators.divide.ParseBinaryDivideIntegerFloat)51 def test_float_float(self):52 atoms, deps = parse(tokenise("1.0 / 1.0"), {})53 self.assertIsInstance(atoms[0], operators.divide.ParseBinaryDivideFloatFloat)54 def test_float_integer(self):55 atoms, deps = parse(tokenise("1.0 / 1"), {})56 self.assertIsInstance(atoms[0], operators.divide.ParseBinaryDivideFloatInteger)57class ParserOperatorTestModulo(unittest.TestCase):58 def test_integer_integer(self):59 atoms, deps = parse(tokenise("1 % 1"), {})60 self.assertIsInstance(atoms[0], operators.modulo.ParseBinaryModuloIntegerInteger)61 def test_integer_float(self):62 atoms, deps = parse(tokenise("1 % 1.0"), {})63 self.assertIsInstance(atoms[0], operators.modulo.ParseBinaryModuloIntegerFloat)64 def test_float_float(self):65 atoms, deps = parse(tokenise("1.0 % 1.0"), {})66 self.assertIsInstance(atoms[0], operators.modulo.ParseBinaryModuloFloatFloat)67 def test_float_integer(self):68 atoms, deps = parse(tokenise("1.0 % 1"), {})69 self.assertIsInstance(atoms[0], operators.modulo.ParseBinaryModuloFloatInteger)70class ParserOperatorTestMultiply(unittest.TestCase):71 def test_integer_integer(self):72 atoms, deps = parse(tokenise("1 * 1"), {})73 self.assertIsInstance(atoms[0], operators.multiply.ParseBinaryMultiplyIntegerInteger)74 def test_integer_float(self):75 atoms, deps = parse(tokenise("1 * 1.0"), {})76 self.assertIsInstance(atoms[0], operators.multiply.ParseBinaryMultiplyIntegerFloat)77 def test_float_float(self):78 atoms, deps = parse(tokenise("1.0 * 1.0"), {})79 self.assertIsInstance(atoms[0], operators.multiply.ParseBinaryMultiplyFloatFloat)80 def test_float_integer(self):81 atoms, deps = parse(tokenise("1.0 * 1"), {})82 self.assertIsInstance(atoms[0], operators.multiply.ParseBinaryMultiplyFloatInteger)83class ParserOperatorTestExponent(unittest.TestCase):84 def test_integer_integer(self):85 atoms, deps = parse(tokenise("1 ** 1"), {})86 self.assertIsInstance(atoms[0], operators.exponent.ParseBinaryExponentIntegerInteger)87 def test_integer_negative(self):88 atoms, deps = parse(tokenise("1 ** -1"), {})89 self.assertIsInstance(atoms[0], operators.exponent.ParseBinaryExponentIntegerNegative)90 def test_integer_float(self):91 atoms, deps = parse(tokenise("1 ** 1.0"), {})92 self.assertIsInstance(atoms[0], operators.exponent.ParseBinaryExponentIntegerFloat)93 def test_float_float(self):94 atoms, deps = parse(tokenise("1.0 ** 1.0"), {})95 self.assertIsInstance(atoms[0], operators.exponent.ParseBinaryExponentFloatFloat)96 def test_float_integer(self):97 atoms, deps = parse(tokenise("1.0 ** 1"), {})98 self.assertIsInstance(atoms[0], operators.exponent.ParseBinaryExponentFloatInteger)99class ParserOperatorTestComplement(unittest.TestCase):100 def test_integer(self):101 atoms, deps = parse(tokenise("~1"), {})102 self.assertIsInstance(atoms[0], operators.complement.ParseUnaryComplementInteger)103class ParserOperatorTestAnd(unittest.TestCase):104 def test_integer_integer(self):105 atoms, deps = parse(tokenise("1 & 1"), {})106 self.assertIsInstance(atoms[0], operators.bitwise.ParseBinaryAndIntegerInteger)107class ParserOperatorTestXor(unittest.TestCase):108 def test_integer_integer(self):109 atoms, deps = parse(tokenise("1 ^ 1"), {})110 self.assertIsInstance(atoms[0], operators.bitwise.ParseBinaryXorIntegerInteger)111class ParserOperatorTestOr(unittest.TestCase):112 def test_integer_integer(self):113 atoms, deps = parse(tokenise("1 | 1"), {})114 self.assertIsInstance(atoms[0], operators.bitwise.ParseBinaryOrIntegerInteger)115class ParserOperatorTestLeft(unittest.TestCase):116 def test_integer_integer(self):117 atoms, deps = parse(tokenise("1 << 1"), {})118 self.assertIsInstance(atoms[0], operators.bitwise.ParseBinaryLeftIntegerInteger)119class ParserOperatorRightLeft(unittest.TestCase):120 def test_integer_integer(self):121 atoms, deps = parse(tokenise("1 >> 1"), {})122 self.assertIsInstance(atoms[0], operators.bitwise.ParseBinaryRightIntegerInteger)123class ParserOperatorTestGreater(unittest.TestCase):124 def test_integer_integer(self):125 atoms, deps = parse(tokenise("1 > 1"), {})126 self.assertIsInstance(atoms[0], operators.greater.ParseBinaryGreaterIntegerInteger)127 def test_integer_float(self):128 atoms, deps = parse(tokenise("1 > 1.0"), {})129 self.assertIsInstance(atoms[0], operators.greater.ParseBinaryGreaterIntegerFloat)130 def test_float_float(self):131 atoms, deps = parse(tokenise("1.0 > 1.0"), {})132 self.assertIsInstance(atoms[0], operators.greater.ParseBinaryGreaterFloatFloat)133 def test_float_integer(self):134 atoms, deps = parse(tokenise("1.0 > 1"), {})135 self.assertIsInstance(atoms[0], operators.greater.ParseBinaryGreaterFloatInteger)136class ParserOperatorTestLesser(unittest.TestCase):137 def test_integer_integer(self):138 atoms, deps = parse(tokenise("1 < 1"), {})139 self.assertIsInstance(atoms[0], operators.lesser.ParseBinaryLesserIntegerInteger)140 def test_integer_float(self):141 atoms, deps = parse(tokenise("1 < 1.0"), {})142 self.assertIsInstance(atoms[0], operators.lesser.ParseBinaryLesserIntegerFloat)143 def test_float_float(self):144 atoms, deps = parse(tokenise("1.0 < 1.0"), {})145 self.assertIsInstance(atoms[0], operators.lesser.ParseBinaryLesserFloatFloat)146 def test_float_integer(self):147 atoms, deps = parse(tokenise("1.0 < 1"), {})148 self.assertIsInstance(atoms[0], operators.lesser.ParseBinaryLesserFloatInteger)149class ParserOperatorTestContains(unittest.TestCase):150 def test_string_string(self):151 atoms, deps = parse(tokenise('"a" in "asd"'), {})152 self.assertIsInstance(atoms[0], operators.contains.ParseBinaryContainsStringString)153 def test_ipv4_cidrv4(self):154 atoms, deps = parse(tokenise("10.84.1.1 in 10.84.0.0/16"), {})155 self.assertIsInstance(atoms[0], operators.contains.ParseBinaryContainsIPCIDR)156 def test_ipv6_cidrv6(self):157 atoms, deps = parse(tokenise("fd84:9d71:8b8:1::1 in fd84:9d71:8b8::/48"), {})158 self.assertIsInstance(atoms[0], operators.contains.ParseBinaryContainsIPCIDR)159class ParserOperatorTestMatch(unittest.TestCase):160 def test_string_regex(self):161 atoms, deps = parse(tokenise('"asd" =~ /^a/'), {})162 self.assertIsInstance(atoms[0], operators.match.ParseBinaryMatchStringRegex)163class ParserOperatorTestNot(unittest.TestCase):164 def test_string(self):165 atoms, deps = parse(tokenise('!"asd"'), {})166 self.assertIsInstance(atoms[0], operators.bools.ParseUnaryNot)167 def test_regex(self):168 atoms, deps = parse(tokenise("!/a/"), {})169 self.assertIsInstance(atoms[0], operators.bools.ParseUnaryNot)170 def test_integer(self):171 atoms, deps = parse(tokenise("!1"), {})172 self.assertIsInstance(atoms[0], operators.bools.ParseUnaryNot)173 def test_float(self):174 atoms, deps = parse(tokenise("!1.0"), {})175 self.assertIsInstance(atoms[0], operators.bools.ParseUnaryNot)176 def test_bool(self):177 atoms, deps = parse(tokenise("!true"), {})178 self.assertIsInstance(atoms[0], operators.bools.ParseUnaryNot)179class ParserOperatorTestPositive(unittest.TestCase):180 def test_integer(self):181 atoms, deps = parse(tokenise("+1"), {})182 self.assertIsInstance(atoms[0], operators.positive.ParseUnaryPositiveInteger)183 def test_float(self):184 atoms, deps = parse(tokenise("+1.0"), {})185 self.assertIsInstance(atoms[0], operators.positive.ParseUnaryPositiveFloat)186class ParserOperatorTestNegative(unittest.TestCase):187 def test_integer(self):188 atoms, deps = parse(tokenise("-1"), {})189 self.assertIsInstance(atoms[0], operators.negative.ParseUnaryNegativeInteger)190 def test_integer_double(self):191 # flatten a double negative integer to an integer192 atoms, deps = parse(tokenise("--1"), {})193 self.assertIsInstance(atoms[0], ParseInteger)194 def test_float(self):195 atoms, deps = parse(tokenise("-1.0"), {})196 self.assertIsInstance(atoms[0], operators.negative.ParseUnaryNegativeFloat)197 def test_float_double(self):198 # flatten a double negative float to a float199 atoms, deps = parse(tokenise("--1.0"), {})200 self.assertIsInstance(atoms[0], ParseFloat)201class ParserOperatorTestBoth(unittest.TestCase):202 def test_bool_bool(self):203 atoms, deps = parse(tokenise("true && true"), {})204 self.assertIsInstance(atoms[0], operators.bools.ParseBinaryBoth)205 def test_integer_integer(self):206 atoms, deps = parse(tokenise("1 && 1"), {})207 self.assertIsInstance(atoms[0], operators.bools.ParseBinaryBoth)208 def test_float_float(self):209 atoms, deps = parse(tokenise("1.0 && 1.0"), {})210 self.assertIsInstance(atoms[0], operators.bools.ParseBinaryBoth)211 def test_string_string(self):212 atoms, deps = parse(tokenise('"asd" && "asd"'), {})213 self.assertIsInstance(atoms[0], operators.bools.ParseBinaryBoth)214 def test_regex_regex(self):215 atoms, deps = parse(tokenise("/a/ && /a/"), {})216 self.assertIsInstance(atoms[0], operators.bools.ParseBinaryBoth)217class ParserOperatorTestVariable(unittest.TestCase):218 def test_integer(self):219 atoms, deps = parse(tokenise("a"), {"a": ParseInteger()})220 self.assertIsInstance(atoms[0], operators.variable.ParseVariableInteger)221 def test_float(self):222 atoms, deps = parse(tokenise("a"), {"a": ParseFloat()})...
ctypes_cfunctype_promptt0.8_pp2.0_fp2.0_18.py
Source:ctypes_cfunctype_promptt0.8_pp2.0_fp2.0_18.py
1import ctypes2# Test ctypes.CFUNCTYPE()3# python_obj = ctypes.CFUNCTYPE(result, arg1, arg...)4# result is one of [void, int, float, double, POINTER(c_int), POINTER(c_float)]5# arg is one of [int, float, double, POINTER(c_int), POINTER(c_float)]6# int function(int)7test_int_int = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int)8# float function(float)9test_float_float = ctypes.CFUNCTYPE(ctypes.c_float, ctypes.c_float)10# double function(double)11test_double_double = ctypes.CFUNCTYPE(ctypes.c_double, ctypes.c_double)12# int function(float)13test_int_float = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_float)...
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!!