File: test_annotations.py

package info (click to toggle)
androguard 4.1.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 81,080 kB
  • sloc: python: 25,059; xml: 3,483; javascript: 3,097; java: 1,311; sh: 130; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 845 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
import os
import unittest

from androguard.core.dex import DEX

test_dir = os.path.dirname(os.path.abspath(__file__))


class AnnotationTest(unittest.TestCase):
    def testAnnotation(self):
        with open(
            os.path.join(test_dir, 'data/APK/Annotation_classes.dex'), "rb"
        ) as f:
            d = DEX(f.read())

        clazz = d.get_class(
            'Landroid/support/v4/widget/SlidingPaneLayout$SlidingPanelLayoutImplJB;'
        )
        annotations = clazz._get_annotation_type_ids()
        self.assertIn(
            'Landroid/support/annotation/RequiresApi;',
            [
                clazz.CM.get_type(annotation.type_idx)
                for annotation in annotations
            ],
        )

        self.assertIn(
            'Landroid/support/annotation/RequiresApi;', clazz.get_annotations()
        )