Пример #1
0
 def __new__(cls, id, kind=KIND.VARIABLE, external=None):
     self = super().__new__(
         cls,
         id=ID.from_raw(id),
         kind=str(kind) if kind else None,
         external=bool(external) if external is not None else None,
     )
     return self
Пример #2
0
    def test_from_raw(self):
        tests = [
            ('', None),
            (None, None),
            ('spam', (None, None, 'spam')),
            (('spam',), (None, None, 'spam')),
            (('x/y/z/spam.c', 'spam'), ('x/y/z/spam.c', None, 'spam')),
            (self.VALID_ARGS, self.VALID_EXPECTED),
            (self.VALID_KWARGS, self.VALID_EXPECTED),
            ]
        for raw, expected in tests:
            with self.subTest(raw):
                id = ID.from_raw(raw)

                self.assertEqual(id, expected)