From: Philippe Proulx Date: Fri, 29 Sep 2023 20:34:21 +0000 (-0400) Subject: tests/test_api.py: apply Black and Pyright X-Git-Tag: v0.7.0~1 X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=eb2f968a720dd8cba4db94c87a2f678ca6d75cdb;p=normand.git tests/test_api.py: apply Black and Pyright Change-Id: I5f15a309a0ff0c79717f46461fb3b4aaca7af5b0 Signed-off-by: Philippe Proulx --- diff --git a/tests/test_api.py b/tests/test_api.py index cc41985..780b86f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -25,33 +25,33 @@ import normand def test_init_labels(): - labels = {'yo': 0x88, 'meow': 123} - res = normand.parse('11 22 {yo:8} 33', init_labels=labels.copy()) + labels = {"yo": 0x88, "meow": 123} # type: normand.SymbolsT + res = normand.parse("11 22 {yo:8} 33", init_labels=labels.copy()) assert res.data == bytearray([0x11, 0x22, 0x88, 0x33]) assert res.labels == labels.copy() def test_init_vars(): - variables = {'zoom': 0x88, 'bateau': -123.45} - res = normand.parse('11 22 {zoom:8} 33', init_variables=variables.copy()) + variables = {"zoom": 0x88, "bateau": -123.45} # type: normand.SymbolsT + res = normand.parse("11 22 {zoom:8} 33", init_variables=variables.copy()) assert res.data == bytearray([0x11, 0x22, 0x88, 0x33]) assert res.variables == variables.copy() def test_init_offset(): - res = normand.parse('11 22 {ICITTE:8} 33', init_offset=0x23) + res = normand.parse("11 22 {ICITTE:8} 33", init_offset=0x23) assert res.data == bytearray([0x11, 0x22, 0x25, 0x33]) assert res.offset == 0x27 -def _test_init_bo(bo): - h_byte = 0xf8 +def _test_init_bo(bo: normand.ByteOrder): + h_byte = 0xF8 l_byte = 0x37 if bo == normand.ByteOrder.LE: h_byte, l_byte = l_byte, h_byte - res = normand.parse('11 22 {-1993:16} 33', init_byte_order=bo) + res = normand.parse("11 22 {-1993:16} 33", init_byte_order=bo) assert res.data == bytearray([0x11, 0x22, h_byte, l_byte, 0x33]) assert res.byte_order == bo @@ -65,43 +65,48 @@ def test_init_bo_le(): def test_final_labels(): - labels = {'yo': 0x88, 'meow': 123} - res = normand.parse('11 22 (77 88) * 2 33', init_labels=labels.copy()) - labels['june'] = 1 - labels['kilo'] = 6 + labels = {"yo": 0x88, "meow": 123} # type: normand.SymbolsT + res = normand.parse( + "11 22 (77 88) * 2 33", init_labels=labels.copy() + ) + labels["june"] = 1 + labels["kilo"] = 6 assert res.labels == labels.copy() def test_final_vars(): - variables = {'yo': 0x88, 'meow': -123.45} - res = normand.parse('11 {yo = 18.2} 22 (77 {zoom = ICITTE} 88) * 2 33', init_variables=variables.copy()) - variables['yo'] = 18.2 - variables['zoom'] = 5 + variables = {"yo": 0x88, "meow": -123.45} + res = normand.parse( + "11 {yo = 18.2} 22 (77 {zoom = ICITTE} 88) * 2 33", + init_variables=variables.copy(), + ) + variables["yo"] = 18.2 + variables["zoom"] = 5 assert res.variables == variables.copy() def test_final_offset(): - res = normand.parse('11 22 33 <32> 44 55') + res = normand.parse("11 22 33 <32> 44 55") assert res.offset == 34 def test_final_byte_order_none(): - res = normand.parse('11 22 33 {-19:8} 44 55') + res = normand.parse("11 22 33 {-19:8} 44 55") assert res.byte_order is None def test_final_byte_order_be(): - res = normand.parse('11 22 {le} 33 {-19:8} 44 ( {be} 88 ) * 3 55') + res = normand.parse("11 22 {le} 33 {-19:8} 44 ( {be} 88 ) * 3 55") assert res.byte_order == normand.ByteOrder.BE def test_final_byte_order_le(): - res = normand.parse('11 22 {be} 33 {-19:8} 44 ( {le} 88 ) * 3 55') + res = normand.parse("11 22 {be} 33 {-19:8} 44 ( {le} 88 ) * 3 55") assert res.byte_order == normand.ByteOrder.LE def test_no_data(): - res = normand.parse('# nothing to see here!\n') + res = normand.parse("# nothing to see here!\n") assert len(res.data) == 0 assert len(res.labels) == 0 assert len(res.variables) == 0