File: test_mach_o.py

package info (click to toggle)
python-macholib 1.8~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 484 kB
  • ctags: 758
  • sloc: python: 4,109; makefile: 127
file content (32 lines) | stat: -rw-r--r-- 910 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
from macholib import mach_o

import sys
if sys.version_info[:2] <= (2,6):
    import unittest2 as unittest
else:
    import unittest


class TestMachO (unittest.TestCase):
    # This module is just a set of struct definitions,
    # not sure how to test those without replicating
    # the code.
    #
    # The definitions will get exercised by the
    # other tests, therefore testing is ignored
    # for now.

    def test_consistency(self):
        self.assertEqual(
            mach_o.MH_FLAGS_DESCRIPTIONS.keys(),
            mach_o.MH_FLAGS_NAMES.keys()
        )
        for k in dir (mach_o):
            if not k.startswith('MH_'): continue
            v = getattr(mach_o, k)
            if isinstance(v, int) and any(v == 1 << x for x in range(31)):
                self.assertTrue(v in mach_o.MH_FLAGS_NAMES, "No NAME and DESCRIPTION for %s"%(k,))


if __name__ == "__main__":
    unittest.main()