File: test_dylib.py

package info (click to toggle)
python-macholib 1.14%2Bds0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 492 kB
  • sloc: python: 4,125; makefile: 127
file content (48 lines) | stat: -rw-r--r-- 1,335 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import sys

from macholib import dylib

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()