Skip to content

Commit

Permalink
Merge branch 'pyobjc10-dev' of github.com:ronaldoussoren/pyobjc into …
Browse files Browse the repository at this point in the history
…pyobjc10-dev

Merging work on a 13.5 laptop and 14.0 VM
  • Loading branch information
ronaldoussoren committed Jun 10, 2023
2 parents bf045eb + f34554f commit ecc8eae
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 67 deletions.
5 changes: 3 additions & 2 deletions pyobjc-core/Lib/PyObjCTools/TestSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@ def assertCallableMetadataIsSane(
}

exclude_attrs = set(exclude_attrs)
# exclude_attrs.add("FBSSceneClientSettings")
exclude_attrs.add(("NSColor", "scn_C3DColorIgnoringColorSpace_success_"))
exclude_attrs.add(
("PDFKitPlatformColor", "scn_C3DColorIgnoringColorSpace_success_")
Expand Down Expand Up @@ -1289,7 +1290,7 @@ def assertCallableMetadataIsSane(
# Calculate all (interesting) names in the module. This pokes into
# the implementation details of objc.ObjCLazyModule to avoid loading
# all attributes (which is expensive for larger bindings).
if isinstance(module, objc.ObjCLazyModule):
if isinstance(module, objc.ObjCLazyModule) and False:
module_names = []
module_names.extend(
cls.__name__
Expand All @@ -1311,7 +1312,7 @@ def assertCallableMetadataIsSane(
# The module_names list might contain duplicates
module_names = sorted(set(module_names))
else:
module_names = sorted(dir(module))
module_names = sorted(set(dir(module)))

for _idx, nm in enumerate(module_names):
# print(f"{_idx}/{len(module_names)} {nm}")
Expand Down
7 changes: 3 additions & 4 deletions pyobjc-core/Lib/objc/_lazyimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,12 @@ def calc_all():
except AttributeError:
all_names.update(dir(p))

# Add all class names, ignoring names with a dot because
# those are not valid attribute names (and in general are private)
# Add all class names, ignoring names that aren't valid identifiers
all_names.update(
cls.__name__ for cls in getClassList() if "." not in cls.__name__
cls.__name__ for cls in getClassList() if cls.__name__.isidentifier()
)

return [v for v in all_names if not v.startswith("_")]
return sorted({v for v in all_names if not v.startswith("_")})

def get_constant(name):
if varmap_dct:
Expand Down
1 change: 1 addition & 0 deletions pyobjc-core/PyObjCTest/test_splitsig.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def testSignatureCount(self):
b"cksqlcs",
b"if",
b"pep",
b"ams",
b"safari",
) or sel.selector in (
b"isNSArray::",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ def selAorI(a, b):
"",
{"arguments": {0: {"type_modifier": "n"}}},
),
"InvokeIconActionUPP": (b"sI^^^c^v^?",),
"CopyProcessName": (
b"i^{ProcessSerialNumber=II}^^{__CFString=}",
"",
Expand Down Expand Up @@ -836,7 +835,6 @@ def selAorI(a, b):
"",
{"arguments": {0: {"type_modifier": "n"}}},
),
"InvokeIconGetterUPP": (b"^^cI^v^?",),
"PasteboardCopyItemFlavorData": (
b"i^{OpaquePasteboardRef=}^v^{__CFString=}^^{__CFData=}",
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,15 @@
}
},
"InvokeIconActionUPP": {
"ignore": true,
"args": {
"1": {},
"2": {},
"3": {}
}
},
"InvokeIconGetterUPP": {
'ignore": true,
"args": {
"1": {},
"2": {}
Expand Down
34 changes: 12 additions & 22 deletions pyobjc-framework-Cocoa/PyObjCTest/test_cfcalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,16 @@
import CoreFoundation
from PyObjCTools.TestSupport import TestCase, min_os_level

NSCalendar = objc.lookUpClass("NSCalendar")
NSLocale = objc.lookUpClass("NSLocale")

class TestCFCalendarVariadic(TestCase):
def testTypes(self):
cls = None
try:
cls = objc.lookUpClass("NSCFCalendar")
except objc.error:
cls = objc.lookUpClass("__NSCFCalendar")

if cls is None:
self.assertIsCFType(CoreFoundation.CFCalendarRef)

else:
self.assertIs(CoreFoundation.CFCalendarRef, cls)

class TestCFCalendarVariadic(TestCase):
def testCFCalendarComposeAbsoluteTime(self):
calendar = CoreFoundation.CFCalendarCreateWithIdentifier(
None, CoreFoundation.kCFGregorianCalendar
)
self.assertIsInstance(calendar, CoreFoundation.CFCalendarRef)
self.assertIsInstance(calendar, NSCalendar)

success, at = CoreFoundation.CFCalendarComposeAbsoluteTime(calendar, None, b"")
self.assertEqual(success, True)
Expand All @@ -39,7 +29,7 @@ def testCFCalendarAddComponents(self):
calendar = CoreFoundation.CFCalendarCreateWithIdentifier(
None, CoreFoundation.kCFGregorianCalendar
)
self.assertIsInstance(calendar, CoreFoundation.CFCalendarRef)
self.assertIsInstance(calendar, NSCalendar)

success, at = CoreFoundation.CFCalendarComposeAbsoluteTime(
calendar, None, b"yMdHms", 1965, 1, 6, 14, 10, 0
Expand Down Expand Up @@ -113,21 +103,21 @@ def testTypeID(self):

def testCreation(self):
cal = CoreFoundation.CFCalendarCopyCurrent()
self.assertIsInstance(cal, CoreFoundation.CFCalendarRef)
self.assertIsInstance(cal, NSCalendar)
cal = CoreFoundation.CFCalendarCreateWithIdentifier(
None, CoreFoundation.kCFBuddhistCalendar
)
self.assertIsInstance(cal, CoreFoundation.CFCalendarRef)
self.assertIsInstance(cal, NSCalendar)

def testInspection(self):
cal = CoreFoundation.CFCalendarCreateWithIdentifier(
None, CoreFoundation.kCFGregorianCalendar
)
self.assertIsInstance(cal, CoreFoundation.CFCalendarRef)
self.assertIsInstance(cal, NSCalendar)
name = CoreFoundation.CFCalendarGetIdentifier(cal)
self.assertEqual(name, CoreFoundation.kCFGregorianCalendar)
locale = CoreFoundation.CFCalendarCopyLocale(cal)
self.assertIsInstance(locale, CoreFoundation.CFLocaleRef)
self.assertIsInstance(locale, NSLocale)
timezone = CoreFoundation.CFCalendarCopyTimeZone(cal)
self.assertIsInstance(timezone, CoreFoundation.CFTimeZoneRef)
weekday = CoreFoundation.CFCalendarGetFirstWeekday(cal)
Expand Down Expand Up @@ -189,15 +179,15 @@ def testMutation(self):
)

loc = CoreFoundation.CFLocaleCreate(None, "mr_IN")
self.assertIsInstance(loc, CoreFoundation.CFLocaleRef)
self.assertIsInstance(loc, NSLocale)
id1 = CoreFoundation.CFLocaleGetIdentifier(loc)

orig_loc = CoreFoundation.CFCalendarCopyLocale(cal)
self.assertIsInstance(orig_loc, CoreFoundation.CFLocaleRef)
self.assertIsInstance(orig_loc, NSLocale)
orig_id = CoreFoundation.CFLocaleGetIdentifier(orig_loc)
CoreFoundation.CFCalendarSetLocale(cal, loc)
new_loc = CoreFoundation.CFCalendarCopyLocale(cal)
self.assertIsInstance(new_loc, CoreFoundation.CFLocaleRef)
self.assertIsInstance(new_loc, NSLocale)
new_id = CoreFoundation.CFLocaleGetIdentifier(new_loc)

self.assertEqual(new_id, id1)
Expand Down
3 changes: 2 additions & 1 deletion pyobjc-framework-Cocoa/PyObjCTest/test_cfdateformatter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CoreFoundation
import Foundation
from PyObjCTools.TestSupport import TestCase, min_os_level
import objc


class TestDateFormatter(TestCase):
Expand Down Expand Up @@ -130,7 +131,7 @@ def testTypes(self):

def testInspection(self):
locale = CoreFoundation.CFLocaleCopyCurrent()
self.assertIsInstance(locale, CoreFoundation.CFLocaleRef)
self.assertIsInstance(locale, objc.lookUpClass("NSLocale"))

date = CoreFoundation.CFDateCreate(
None, CoreFoundation.CFAbsoluteTimeGetCurrent()
Expand Down
34 changes: 13 additions & 21 deletions pyobjc-framework-Cocoa/PyObjCTest/test_cflocale.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,27 @@
import objc
from PyObjCTools.TestSupport import TestCase, min_os_level

NSLocale = objc.lookUpClass("NSLocale")
NSArray = objc.lookUpClass("NSArray")

class TestLocale(TestCase):
def testTypes(self):
try:
cls = objc.lookUpClass("__NSCFLocale")
self.assertIs(CoreFoundation.CFLocaleRef, cls)
except objc.error:
try:
cls = objc.lookUpClass("NSCFLocale")
self.assertIs(CoreFoundation.CFLocaleRef, cls)
except objc.error:
self.assertIsCFType(CoreFoundation.CFLocaleRef)

class TestLocale(TestCase):
def testGetTypeID(self):
self.assertIsInstance(CoreFoundation.CFLocaleGetTypeID(), int)

def testInspection(self):
locale = CoreFoundation.CFLocaleGetSystem()
self.assertIsInstance(locale, CoreFoundation.CFLocaleRef)
self.assertIsInstance(locale, NSLocale)
locale = CoreFoundation.CFLocaleCopyCurrent()
self.assertIsInstance(locale, CoreFoundation.CFLocaleRef)
self.assertIsInstance(locale, NSLocale)
idents = CoreFoundation.CFLocaleCopyAvailableLocaleIdentifiers()
self.assertIsInstance(idents, CoreFoundation.CFArrayRef)
self.assertIsInstance(idents, NSArray)
codes = CoreFoundation.CFLocaleCopyISOLanguageCodes()
self.assertIsInstance(codes, CoreFoundation.CFArrayRef)
self.assertIsInstance(codes, NSArray)
codes = CoreFoundation.CFLocaleCopyISOCountryCodes()
self.assertIsInstance(codes, CoreFoundation.CFArrayRef)
self.assertIsInstance(codes, NSArray)
codes = CoreFoundation.CFLocaleCopyISOCurrencyCodes()
self.assertIsInstance(codes, CoreFoundation.CFArrayRef)
self.assertIsInstance(codes, NSArray)
val = CoreFoundation.CFLocaleCreateCanonicalLanguageIdentifierFromString(
None, "de_DE"
)
Expand All @@ -54,9 +46,9 @@ def testInspection(self):
self.assertEqual(val, "nl_NL")

locale = CoreFoundation.CFLocaleCreate(None, "nl_NL")
self.assertIsInstance(locale, CoreFoundation.CFLocaleRef)
self.assertIsInstance(locale, NSLocale)
locale = CoreFoundation.CFLocaleCreateCopy(None, locale)
self.assertIsInstance(locale, CoreFoundation.CFLocaleRef)
self.assertIsInstance(locale, NSLocale)
ident = CoreFoundation.CFLocaleGetIdentifier(locale)
self.assertEqual(ident, "nl_NL")
v = CoreFoundation.CFLocaleGetValue(
Expand Down Expand Up @@ -97,9 +89,9 @@ def testConstants(self):
@min_os_level("10.5")
def testFunctions10_5(self):
codes = CoreFoundation.CFLocaleCopyCommonISOCurrencyCodes()
self.assertIsInstance(codes, CoreFoundation.CFArrayRef)
self.assertIsInstance(codes, NSArray)
codes = CoreFoundation.CFLocaleCopyPreferredLanguages()
self.assertIsInstance(codes, CoreFoundation.CFArrayRef)
self.assertIsInstance(codes, NSArray)

@min_os_level("10.5")
def testConstants10_5(self):
Expand Down
9 changes: 6 additions & 3 deletions pyobjc-framework-Cocoa/PyObjCTest/test_cftimezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from PyObjCTools.TestSupport import TestCase, min_os_level
import objc

NSData = objc.lookUpClass("NSData")
NSDictionary = objc.lookUpClass("NSDictionary")


class TestTimeZone(TestCase):
def testTypes(self):
Expand Down Expand Up @@ -42,7 +45,7 @@ def testNames(self):

def testAbbreviationDict(self):
abbrevs = CoreFoundation.CFTimeZoneCopyAbbreviationDictionary()
self.assertIsInstance(abbrevs, CoreFoundation.CFDictionaryRef)
self.assertIsInstance(abbrevs, NSDictionary)
for key, value in abbrevs.items():
self.assertIsInstance(key, str)
self.assertIsInstance(value, str)
Expand All @@ -60,7 +63,7 @@ def testAbbrievationDictSetting(self):
self.assertIs(v, None)
try:
map2 = CoreFoundation.CFTimeZoneCopyAbbreviationDictionary()
self.assertIsInstance(map2, CoreFoundation.CFDictionaryRef)
self.assertIsInstance(map2, NSDictionary)
self.assertEqual(map2["AAA"], "Europe/Amsterdam")
finally:
CoreFoundation.CFTimeZoneSetAbbreviationDictionary(abbrevs)
Expand All @@ -84,7 +87,7 @@ def testZoneObject(self):
self.assertEqual(name, "Europe/Amsterdam")

data = CoreFoundation.CFTimeZoneGetData(zone)
self.assertIsInstance(data, CoreFoundation.CFDataRef)
self.assertIsInstance(data, NSData)
abbrev = CoreFoundation.CFTimeZoneCopyAbbreviation(zone, time.time())
self.assertIsInstance(abbrev, str)
dt = CoreFoundation.CFGregorianDate(
Expand Down
11 changes: 8 additions & 3 deletions pyobjc-framework-Cocoa/PyObjCTest/test_nsopengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,14 @@ def testMethods(self):
AppKit.NSOpenGLPixelFormat.CGLPixelFormatObj, b"^{_CGLPixelFormatObject}"
)

self.assertResultHasType(
AppKit.NSOpenGLContext.CGLContextObj, b"^{_CGLContextObj}"
)
# This open codes a variant on assertResultHasType because the type encoding
# for CGLObject has changed in macOS 14.
# XXX: Need to validate that CGLObject is still usable!
tp = AppKit.NSOpenGLContext.CGLContextObj.__metadata__()["retval"]["type"]
self.assertStartswith(tp, b"^{_CGLContextObj")
# self.assertResultHasType(
# AppKit.NSOpenGLContext.CGLContextObj, b"^{_CGLContextObj}"
# )

self.assertArgIsIn(AppKit.NSOpenGLContext.setValues_forParameter_, 0)
self.assertArgIsVariableSize(AppKit.NSOpenGLContext.setValues_forParameter_, 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
from PyObjCTools.TestSupport import TestCase, min_sdk_level, min_os_level
from PyObjCTools.TestSupport import TestCase, min_sdk_level

import CoreMotion
import CoreMotion # noqa: F401


class TestCMWaterSubmersionManager(TestCase):
@min_sdk_level("13.0")
def test_protocols(self):
self.assertProtocolExists("CMWaterSubmersionManagerDelegate")

@min_os_level("13.0")
def test_methods(self):
self.assertResultIsBOOL(
CoreMotion.CMWaterSubmersionManager.waterSubmersionAvailable
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def callback(st, keys, info):

have_ip = False

for intf in ("en0", "en1", "en2", "en3"):
for intf in ("en0", "en1", "en2", "en3", "en4"):
with os.popen(f"ifconfig {intf} 2>/dev/null| grep inet", "r") as fp:
ip = fp.read()
if ip.strip():
Expand Down

0 comments on commit ecc8eae

Please sign in to comment.