diff options
Diffstat (limited to 'python/macholib/macholib_tests/test_dylib.py')
-rw-r--r-- | python/macholib/macholib_tests/test_dylib.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/python/macholib/macholib_tests/test_dylib.py b/python/macholib/macholib_tests/test_dylib.py new file mode 100644 index 000000000..dcbc45358 --- /dev/null +++ b/python/macholib/macholib_tests/test_dylib.py @@ -0,0 +1,38 @@ +from macholib import dylib + +import sys +if sys.version_info[:2] <= (2,6): + import unittest2 as unittest +else: + import unittest + +def d(location=None, name=None, shortname=None, version=None, suffix=None): + return dict( + location=location, + name=name, + shortname=shortname, + version=version, + suffix=suffix + ) + +class TestDylib (unittest.TestCase): + def testInvalid(self): + self.assertTrue(dylib.dylib_info('completely/invalid') is None) + self.assertTrue(dylib.dylib_info('completely/invalid_debug') is None) + + def testUnversioned(self): + self.assertEqual(dylib.dylib_info('P/Foo.dylib'), + d('P', 'Foo.dylib', 'Foo')) + self.assertEqual(dylib.dylib_info('P/Foo_debug.dylib'), + d('P', 'Foo_debug.dylib', 'Foo', suffix='debug')) + + def testVersioned(self): + self.assertEqual(dylib.dylib_info('P/Foo.A.dylib'), + d('P', 'Foo.A.dylib', 'Foo', 'A')) + self.assertEqual(dylib.dylib_info('P/Foo_debug.A.dylib'), + d('P', 'Foo_debug.A.dylib', 'Foo_debug', 'A')) + self.assertEqual(dylib.dylib_info('P/Foo.A_debug.dylib'), + d('P', 'Foo.A_debug.dylib', 'Foo', 'A', 'debug')) + +if __name__ == "__main__": + unittest.main() |