mirror of
https://github.com/python/cpython.git
synced 2024-11-27 03:45:08 +08:00
gh-91265: Make old ctypes.macholib tests runned by python -m test
(gh-32094)
* Move tests from ctypes.macholib.dy* to ctypes.test
This commit is contained in:
parent
4c3b283e83
commit
804ea2da97
@ -163,11 +163,3 @@ def framework_find(fn, executable_path=None, env=None):
|
||||
raise error
|
||||
finally:
|
||||
error = None
|
||||
|
||||
def test_dyld_find():
|
||||
env = {}
|
||||
assert dyld_find('libSystem.dylib') == '/usr/lib/libSystem.dylib'
|
||||
assert dyld_find('System.framework/System') == '/System/Library/Frameworks/System.framework/System'
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_dyld_find()
|
||||
|
@ -40,24 +40,3 @@ def dylib_info(filename):
|
||||
if not is_dylib:
|
||||
return None
|
||||
return is_dylib.groupdict()
|
||||
|
||||
|
||||
def test_dylib_info():
|
||||
def d(location=None, name=None, shortname=None, version=None, suffix=None):
|
||||
return dict(
|
||||
location=location,
|
||||
name=name,
|
||||
shortname=shortname,
|
||||
version=version,
|
||||
suffix=suffix
|
||||
)
|
||||
assert dylib_info('completely/invalid') is None
|
||||
assert dylib_info('completely/invalide_debug') is None
|
||||
assert dylib_info('P/Foo.dylib') == d('P', 'Foo.dylib', 'Foo')
|
||||
assert dylib_info('P/Foo_debug.dylib') == d('P', 'Foo_debug.dylib', 'Foo', suffix='debug')
|
||||
assert dylib_info('P/Foo.A.dylib') == d('P', 'Foo.A.dylib', 'Foo', 'A')
|
||||
assert dylib_info('P/Foo_debug.A.dylib') == d('P', 'Foo_debug.A.dylib', 'Foo_debug', 'A')
|
||||
assert dylib_info('P/Foo.A_debug.dylib') == d('P', 'Foo.A_debug.dylib', 'Foo', 'A', 'debug')
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_dylib_info()
|
||||
|
@ -40,26 +40,3 @@ def framework_info(filename):
|
||||
if not is_framework:
|
||||
return None
|
||||
return is_framework.groupdict()
|
||||
|
||||
def test_framework_info():
|
||||
def d(location=None, name=None, shortname=None, version=None, suffix=None):
|
||||
return dict(
|
||||
location=location,
|
||||
name=name,
|
||||
shortname=shortname,
|
||||
version=version,
|
||||
suffix=suffix
|
||||
)
|
||||
assert framework_info('completely/invalid') is None
|
||||
assert framework_info('completely/invalid/_debug') is None
|
||||
assert framework_info('P/F.framework') is None
|
||||
assert framework_info('P/F.framework/_debug') is None
|
||||
assert framework_info('P/F.framework/F') == d('P', 'F.framework/F', 'F')
|
||||
assert framework_info('P/F.framework/F_debug') == d('P', 'F.framework/F_debug', 'F', suffix='debug')
|
||||
assert framework_info('P/F.framework/Versions') is None
|
||||
assert framework_info('P/F.framework/Versions/A') is None
|
||||
assert framework_info('P/F.framework/Versions/A/F') == d('P', 'F.framework/Versions/A/F', 'F', 'A')
|
||||
assert framework_info('P/F.framework/Versions/A/F_debug') == d('P', 'F.framework/Versions/A/F_debug', 'F', 'A', 'debug')
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_framework_info()
|
||||
|
@ -32,6 +32,8 @@ import unittest
|
||||
# -bob
|
||||
|
||||
from ctypes.macholib.dyld import dyld_find
|
||||
from ctypes.macholib.dylib import dylib_info
|
||||
from ctypes.macholib.framework import framework_info
|
||||
|
||||
def find_lib(name):
|
||||
possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name]
|
||||
@ -42,9 +44,20 @@ def find_lib(name):
|
||||
pass
|
||||
raise ValueError("%s not found" % (name,))
|
||||
|
||||
|
||||
def d(location=None, name=None, shortname=None, version=None, suffix=None):
|
||||
return {'location': location, 'name': name, 'shortname': shortname,
|
||||
'version': version, 'suffix': suffix}
|
||||
|
||||
|
||||
class MachOTest(unittest.TestCase):
|
||||
@unittest.skipUnless(sys.platform == "darwin", 'OSX-specific test')
|
||||
def test_find(self):
|
||||
self.assertEqual(dyld_find('libSystem.dylib'),
|
||||
'/usr/lib/libSystem.dylib')
|
||||
self.assertEqual(dyld_find('System.framework/System'),
|
||||
'/System/Library/Frameworks/System.framework/System')
|
||||
|
||||
# On Mac OS 11, system dylibs are only present in the shared cache,
|
||||
# so symlinks like libpthread.dylib -> libSystem.B.dylib will not
|
||||
# be resolved by dyld_find
|
||||
@ -62,5 +75,36 @@ class MachOTest(unittest.TestCase):
|
||||
('/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit',
|
||||
'/System/Library/Frameworks/IOKit.framework/IOKit'))
|
||||
|
||||
@unittest.skipUnless(sys.platform == "darwin", 'OSX-specific test')
|
||||
def test_info(self):
|
||||
self.assertIsNone(dylib_info('completely/invalid'))
|
||||
self.assertIsNone(dylib_info('completely/invalide_debug'))
|
||||
self.assertEqual(dylib_info('P/Foo.dylib'), d('P', 'Foo.dylib', 'Foo'))
|
||||
self.assertEqual(dylib_info('P/Foo_debug.dylib'),
|
||||
d('P', 'Foo_debug.dylib', 'Foo', suffix='debug'))
|
||||
self.assertEqual(dylib_info('P/Foo.A.dylib'),
|
||||
d('P', 'Foo.A.dylib', 'Foo', 'A'))
|
||||
self.assertEqual(dylib_info('P/Foo_debug.A.dylib'),
|
||||
d('P', 'Foo_debug.A.dylib', 'Foo_debug', 'A'))
|
||||
self.assertEqual(dylib_info('P/Foo.A_debug.dylib'),
|
||||
d('P', 'Foo.A_debug.dylib', 'Foo', 'A', 'debug'))
|
||||
|
||||
@unittest.skipUnless(sys.platform == "darwin", 'OSX-specific test')
|
||||
def test_framework_info(self):
|
||||
self.assertIsNone(framework_info('completely/invalid'))
|
||||
self.assertIsNone(framework_info('completely/invalid/_debug'))
|
||||
self.assertIsNone(framework_info('P/F.framework'))
|
||||
self.assertIsNone(framework_info('P/F.framework/_debug'))
|
||||
self.assertEqual(framework_info('P/F.framework/F'),
|
||||
d('P', 'F.framework/F', 'F'))
|
||||
self.assertEqual(framework_info('P/F.framework/F_debug'),
|
||||
d('P', 'F.framework/F_debug', 'F', suffix='debug'))
|
||||
self.assertIsNone(framework_info('P/F.framework/Versions'))
|
||||
self.assertIsNone(framework_info('P/F.framework/Versions/A'))
|
||||
self.assertEqual(framework_info('P/F.framework/Versions/A/F'),
|
||||
d('P', 'F.framework/Versions/A/F', 'F', 'A'))
|
||||
self.assertEqual(framework_info('P/F.framework/Versions/A/F_debug'),
|
||||
d('P', 'F.framework/Versions/A/F_debug', 'F', 'A', 'debug'))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -0,0 +1,3 @@
|
||||
Test for :mod:`ctypes.macholib.dyld`, :mod:`ctypes.macholib.dylib`, and
|
||||
:mod:`ctypes.macholib.framework` are brought from manual pre-:mod:`unittest`
|
||||
times to :mod:`ctypes.test` location and structure. Patch by Oleg Iarygin.
|
Loading…
Reference in New Issue
Block a user