def test_parse_signature_basic() -> None: assert _parse_signature(1, b': c f') == { 'doc': '', 'index': 1, 'name': 'method1', 'parameters': [{ 'doc': '', 'fmt': 'c', 'name': 'arg0', 'typename': 'bytes' }, { 'doc': '', 'fmt': 'f', 'name': 'arg1', 'typename': 'float' }], 'return': { 'doc': '', 'fmt': '', 'typename': '' } }
def test_add_doc_missing_parameter() -> None: method = _parse_signature(1, b': c f') _add_doc(method, b'name: Test. @p1: Char') assert method['name'] == 'name' assert method['parameters'][0]['name'] == 'p1' assert method['parameters'][1]['name'] == 'arg1'
def test_add_doc_missing_name() -> None: method = _parse_signature(1, b': c f') _add_doc(method, b'@p1: Char. @p2: Float.') assert method['name'] == 'method1' assert method['doc'] == '' assert method['parameters'][0]['name'] == 'arg0'
def test_parse_signature_complex() -> None: assert _parse_signature(2, b'(ff): [c] (cf)') == { 'doc': '', 'index': 2, 'name': 'method2', 'parameters': [{ 'doc': '', 'fmt': ['c'], 'name': 'arg0', 'typename': '[bytes]' }, { 'doc': '', 'fmt': ('c', 'f'), 'name': 'arg1', 'typename': '(bytes, float)' }], 'return': { 'doc': '', 'fmt': ('f', 'f'), 'typename': '(float, float)' } }
def test_add_doc_basic() -> None: method = _parse_signature(1, b'i: c f') _add_doc(method, b'name: Test. @p1: Char. @p2: Float. @return: Int.') assert method['name'] == 'name' assert method['doc'] == 'Test.' assert method['parameters'][0]['name'] == 'p1' assert method['parameters'][0]['doc'] == 'Char.' assert method['parameters'][1]['name'] == 'p2' assert method['parameters'][1]['doc'] == 'Float.' assert method['return']['doc'] == 'Int.'