@@ -253,22 +253,16 @@ class USEROBJECTFLAGS(ctypes.Structure):
253
253
# process not running under the same user id as the current console
254
254
# user. To avoid that, raise an exception if the window manager
255
255
# connection is not available.
256
- from ctypes import cdll , c_int , pointer , Structure
257
- from ctypes . util import find_library
258
-
259
- app_services = cdll . LoadLibrary ( find_library ( "ApplicationServices" ) )
260
-
261
- if app_services . CGMainDisplayID () == 0 :
262
- reason = "gui tests cannot run without OS X window manager"
256
+ import subprocess
257
+ try :
258
+ rc = subprocess . run ([ "launchctl" , "managername" ],
259
+ capture_output = True , check = True )
260
+ managername = rc . stdout . decode ( "utf-8" ). strip ()
261
+ except subprocess . CalledProcessError :
262
+ reason = "unable to detect macOS launchd job manager"
263
263
else :
264
- class ProcessSerialNumber (Structure ):
265
- _fields_ = [("highLongOfPSN" , c_int ),
266
- ("lowLongOfPSN" , c_int )]
267
- psn = ProcessSerialNumber ()
268
- psn_p = pointer (psn )
269
- if ( (app_services .GetCurrentProcess (psn_p ) < 0 ) or
270
- (app_services .SetFrontProcess (psn_p ) < 0 ) ):
271
- reason = "cannot run without OS X gui process"
264
+ if managername != "Aqua" :
265
+ reason = f"{ managername = } -- can only run in a macOS GUI session"
272
266
273
267
# check on every platform whether tkinter can actually do anything
274
268
if not reason :
0 commit comments