1import objc 2import PyObjCTest.fnd as Foundation 3from PyObjCTools.TestSupport import * 4 5class TestBundleVariables (TestCase): 6 def setUp(self): 7 self.bundle = Foundation.NSBundle.bundleForClass_(Foundation.NSBundle) 8 9 def testStrings(self): 10 d = {} 11 objc.loadBundleVariables(self.bundle, d, [ 12 ('NSAppleScriptErrorMessage', b'@'), 13 ('NSBundleDidLoadNotification', b'@'), 14 ]) 15 16 self.assertIn(u'NSBundleDidLoadNotification', d) 17 self.assertIn(u'NSAppleScriptErrorMessage', d) 18 19 self.assertIsInstance(d[u'NSAppleScriptErrorMessage'], objc.pyobjc_unicode) 20 self.assertIsInstance(d[u'NSBundleDidLoadNotification'], objc.pyobjc_unicode) 21 22 def testSimple(self): 23 d = {} 24 objc.loadBundleVariables(self.bundle, d, [ 25 ('NSDebugEnabled', objc._C_NSBOOL), 26 ('NSFoundationVersionNumber', objc._C_DBL), 27 ]) 28 29 self.assertIn('NSDebugEnabled', d) 30 self.assertIn('NSFoundationVersionNumber', d) 31 32 self.assertIsInstance(d['NSFoundationVersionNumber'], float) 33 self.assertIsInstance(d['NSDebugEnabled'], int) 34 35 36if __name__ == "__main__": 37 main() 38 39 40