tests/test_api.py: apply Black and Pyright
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 29 Sep 2023 20:34:21 +0000 (16:34 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 29 Sep 2023 20:34:21 +0000 (16:34 -0400)
Change-Id: I5f15a309a0ff0c79717f46461fb3b4aaca7af5b0
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
tests/test_api.py

index cc419854deb08e9272d8ed3810625dd029f62856..780b86f99c5617b98109cb7c8b3b22cad2c9c32f 100644 (file)
@@ -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 <june> 22 (77 <aug> 88) * 2 <kilo> 33', init_labels=labels.copy())
-    labels['june'] = 1
-    labels['kilo'] = 6
+    labels = {"yo": 0x88, "meow": 123}  # type: normand.SymbolsT
+    res = normand.parse(
+        "11 <june> 22 (77 <aug> 88) * 2 <kilo> 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
This page took 0.024501 seconds and 4 git commands to generate.