Пример #1
0
    def test_load_bundle(self):
        NSBundle = objc.lookUpClass('NSBundle')

        # _objc is linked with Foundation, hence should be able to load without
        # providing a valid path
        o = lazyimport._loadBundle('Foundation', 'com.apple.Foundation',
                                   '/dev/null')
        self.assertIsInstance(o, NSBundle)
        self.assertEqual(o.bundleIdentifier(), 'com.apple.Foundation')
        self.assertTrue(o.isLoaded())

        # Load using path
        o = lazyimport._loadBundle(
            'AppKit', None, '/System/Library/Frameworks/AppKit.framework')
        o.load()
        self.assertEqual(o.bundleIdentifier(), 'com.apple.AppKit')
        self.assertTrue(o.isLoaded())

        # Should not be loaded yet, hence fallback from identifier to path
        o = lazyimport._loadBundle(
            'PreferencePanes', 'com.apple.frameworks.preferencepanes',
            '/System/Library/Frameworks/PreferencePanes.framework')
        o.load()
        self.assertEqual(o.bundleIdentifier(),
                         'com.apple.frameworks.preferencepanes')
        self.assertTrue(o.isLoaded())
Пример #2
0
    def test_load_bundle(self):
        NSBundle = objc.lookUpClass('NSBundle')

        # _objc is linked with Foundation, hence should be able to load without
        # providing a valid path
        o = lazyimport._loadBundle('Foundation', 'com.apple.Foundation', '/dev/null')
        self.assertIsInstance(o, NSBundle)
        self.assertEqual(o.bundleIdentifier(), 'com.apple.Foundation')
        self.assertTrue(o.isLoaded())

        # Load using path
        o = lazyimport._loadBundle('AppKit', None, '/System/Library/Frameworks/AppKit.framework')
        o.load()
        self.assertEqual(o.bundleIdentifier(), 'com.apple.AppKit')
        self.assertTrue(o.isLoaded())

        # Should not be loaded yet, hence fallback from identifier to path
        o = lazyimport._loadBundle('PreferencePanes', 'com.apple.frameworks.preferencepanes', '/System/Library/Frameworks/PreferencePanes.framework')
        o.load()
        self.assertEqual(o.bundleIdentifier(), 'com.apple.frameworks.preferencepanes')
        self.assertTrue(o.isLoaded())