Best Python code snippet using localstack_python
test_callable_docstr.py
Source:test_callable_docstr.py
...5import objc6NSArray = objc.lookUpClass('NSArray')7class TestDescribeType (TestCase):8 def test_basic_types(self):9 self.assertEqual(mod.describe_type(objc._C_VOID), "void")10 self.assertEqual(mod.describe_type(objc._C_INT), "int")11 self.assertEqual(mod.describe_type(objc._C_UINT), "unsigned int")12 self.assertEqual(mod.describe_type(objc._C_CHR), "char")13 self.assertEqual(mod.describe_type(objc._C_UCHR), "unsigned char")14 self.assertEqual(mod.describe_type(objc._C_SHT), "short")15 self.assertEqual(mod.describe_type(objc._C_USHT), "unsigned short")16 self.assertEqual(mod.describe_type(objc._C_LNG), "long")17 self.assertEqual(mod.describe_type(objc._C_ULNG), "unsigned long")18 self.assertEqual(mod.describe_type(objc._C_LNG_LNG), "long long")19 self.assertEqual(mod.describe_type(objc._C_ULNG_LNG), "unsigned long long")20 self.assertEqual(mod.describe_type(objc._C_FLT), "float")21 self.assertEqual(mod.describe_type(objc._C_DBL), "double")22 self.assertEqual(mod.describe_type(objc._C_ID), "id")23 self.assertEqual(mod.describe_type(objc._C_CLASS), "Class")24 self.assertEqual(mod.describe_type(objc._C_SEL), "SEL")25 self.assertEqual(mod.describe_type(objc._C_CHARPTR), "char*")26 self.assertEqual(mod.describe_type(objc._C_BOOL), "bool")27 # PyObjC specials:28 self.assertEqual(mod.describe_type(objc._C_CHAR_AS_INT), "int8_t")29 self.assertEqual(mod.describe_type(objc._C_CHAR_AS_TEXT), "char")30 self.assertEqual(mod.describe_type(objc._C_UNICHAR), "UniChar")31 self.assertEqual(mod.describe_type(objc._C_NSBOOL), "BOOL")32 def test_inout(self):33 self.assertEqual(mod.describe_type(objc._C_IN + objc._C_PTR + objc._C_INT), "in int*")34 self.assertEqual(mod.describe_type(objc._C_OUT + objc._C_PTR + objc._C_INT), "out int*")35 self.assertEqual(mod.describe_type(objc._C_INOUT + objc._C_PTR + objc._C_INT), "inout int*")36 # Nonsense, but should give a sane result anway:37 self.assertEqual(mod.describe_type(objc._C_OUT + objc._C_IN + objc._C_PTR + objc._C_INT), "out in int*")38 def test_pointers(self):39 self.assertEqual(mod.describe_type(objc._C_CHARPTR), "char*")40 self.assertEqual(mod.describe_type(objc._C_PTR + objc._C_CHR), "char*")41 self.assertEqual(mod.describe_type(objc._C_PTR + objc._C_PTR + objc._C_FLT), "float**")42 self.assertEqual(mod.describe_type(objc._C_PTR + objc._C_STRUCT_B + b'hello=' + objc._C_INT + objc._C_STRUCT_E), "struct hello*")43 handle = objc.createOpaquePointerType("NamedPointer", b"^{NamedTestPointer1=}")44 self.assertEqual(mod.describe_type(b"^{NamedTestPointer1=}"), "NamedPointer")45 def test_unknown(self):46 self.assertEqual(mod.describe_type(b'?'), '<?>')47 self.assertEqual(mod.describe_type(b'X'), '<?>')48 def test_callable(self):49 self.assertEqual(mod.describe_type(objc._C_ID + b'?'), "<BLOCK>")50 self.assertEqual(mod.describe_type(objc._C_PTR + b'?'), "<FUNCTION>")51 def test_array(self):52 self.assertEqual(mod.describe_type(objc._C_ARY_B + b"42" + objc._C_INT), "int[42]")53 self.assertEqual(mod.describe_type(objc._C_ARY_B + b"42" + objc._C_PTR + objc._C_INT), "int*[42]")54 def test_struct(self):55 self.assertEqual(mod.describe_type(objc._C_STRUCT_B + b"=" + objc._C_ID + objc._C_STRUCT_E), "struct <?>")56 self.assertEqual(mod.describe_type(objc._C_STRUCT_B + objc._C_STRUCT_E), "struct <?>")57 self.assertEqual(mod.describe_type(objc._C_STRUCT_B + b"name=" + objc._C_ID + objc._C_INT + objc._C_STRUCT_E), "struct name")58 self.assertEqual(mod.describe_type(objc._C_STRUCT_B + b"name=\"field\"" + objc._C_ID + b'"field2"' + objc._C_INT + objc._C_STRUCT_E), "struct name")59 strType = objc.createStructType("NamedTestStruct", b'{NamedTestStruct1="a"i"b"i}', None)60 self.assertEqual(mod.describe_type(b'{NamedTestStruct1=ii}'), "NamedTestStruct")61 def test_union(self):62 self.assertEqual(mod.describe_type(objc._C_UNION_B + b"=" + objc._C_ID + objc._C_UNION_E), "union <?>")63 self.assertEqual(mod.describe_type(objc._C_UNION_B + objc._C_UNION_E), "union <?>")64 self.assertEqual(mod.describe_type(objc._C_UNION_B + b"name=" + objc._C_ID + objc._C_INT + objc._C_UNION_E), "union name")65 self.assertEqual(mod.describe_type(objc._C_UNION_B + b"name=\"field\"" + objc._C_ID + b'"field2"' + objc._C_INT + objc._C_UNION_E), "union name")66class TestDescribeCallable (TestCase):67 def setUp(self):68 dct = {}69 func = objc.loadBundleFunctions(None, dct, [70 ('NSTemporaryDirectory', objc._C_ID),71 ('NSSearchPathForDirectoriesInDomains', objc._C_ID + objc._C_NSUInteger + objc._C_NSUInteger + objc._C_NSBOOL),72 ])73 self.NSTemporaryDirectory = dct['NSTemporaryDirectory']74 self.NSSearchPathForDirectoriesInDomains = dct['NSSearchPathForDirectoriesInDomains']75 def test_not_for_regular_types(self):76 self.assertRaises(AttributeError, mod.describe_callable, 42)77 self.assertRaises(AttributeError, mod.describe_callable, int)78 self.assertRaises(AttributeError, mod.describe_callable, dir)79 self.assertRaises(AttributeError, mod.describe_callable, lambda x: x*2)...
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!!