Skip to content

Commit 3860be4

Browse files
jk-ozlabsJunYe1993
authored andcommitted
tests: minor formatting fixes for VDM tests
Clean up wrapping a little, by using a temporary for each vendor type Variant. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
1 parent 8b12d0f commit 3860be4

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

tests/test_mctpd.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,8 +1346,8 @@ async def test_register_vdm_type_support_pcie_only(dbus, mctpd):
13461346
mctp = await mctpd_mctp_base_iface_obj(dbus)
13471347

13481348
# Register PCIe VDM: format=0x00, VID=0xABCD, command_set=0x0001
1349-
await mctp.call_register_vdm_type_support(0x00,
1350-
asyncdbus.Variant('q', 0xABCD), 0x0001)
1349+
v_type = asyncdbus.Variant('q', 0xABCD)
1350+
await mctp.call_register_vdm_type_support(0x00, v_type, 0x0001)
13511351

13521352
# Verify PCIe VDM (selector 0)
13531353
cmd = MCTPControlCommand(True, 0, 0x06, bytes([0x00]))
@@ -1372,8 +1372,8 @@ async def test_register_vdm_type_support_iana_only(dbus, mctpd):
13721372
mctp = await mctpd_mctp_base_iface_obj(dbus)
13731373

13741374
# Register IANA VDM: format=0x01, VID=0x1234ABCD, command_set=0x5678
1375-
await mctp.call_register_vdm_type_support(0x01,
1376-
asyncdbus.Variant('u', 0x1234ABCD), 0x5678)
1375+
v_type = asyncdbus.Variant('u', 0x1234ABCD)
1376+
await mctp.call_register_vdm_type_support(0x01, v_type, 0x5678)
13771377

13781378
# Verify IANA VDM (selector 0)
13791379
cmd = MCTPControlCommand(True, 0, 0x06, bytes([0x00]))
@@ -1399,8 +1399,8 @@ async def test_register_vdm_type_support_dbus_disconnect(mctpd):
13991399
mctp = await mctpd_mctp_base_iface_obj(temp_bus)
14001400

14011401
# Register PCIe VDM: format=0x00, VID=0xABCD, command_set=0x0001
1402-
await mctp.call_register_vdm_type_support(0x00,
1403-
asyncdbus.Variant('q', 0xABCD), 0x0001)
1402+
v_type = asyncdbus.Variant('q', 0xABCD)
1403+
await mctp.call_register_vdm_type_support(0x00, v_type, 0x0001)
14041404

14051405
# Verify PCIe VDM (selector 0)
14061406
cmd = MCTPControlCommand(True, 0, 0x06, bytes([0x00]))
@@ -1427,25 +1427,24 @@ async def test_register_vdm_type_support_errors(dbus, mctpd):
14271427

14281428
mctp = await mctpd_mctp_base_iface_obj(dbus)
14291429
# Verify DBus call fails with invalid format 0x02
1430+
v_type = asyncdbus.Variant('q', 0xABCD)
14301431
with pytest.raises(asyncdbus.errors.DBusError) as ex:
1431-
await mctp.call_register_vdm_type_support(0x02,
1432-
asyncdbus.Variant('q', 0xABCD), 0x0001)
1432+
await mctp.call_register_vdm_type_support(0x02, v_type, 0x0001)
14331433
assert "Unsupported VID format" in str(ex.value)
14341434

14351435
# Verify incorrect VID type raises error
1436+
v_type = asyncdbus.Variant('u', 0xABCDEF12)
14361437
with pytest.raises(asyncdbus.errors.DBusError) as ex:
1437-
await mctp.call_register_vdm_type_support(0x00,
1438-
asyncdbus.Variant('u', 0xABCDEF12), 0x0001)
1438+
await mctp.call_register_vdm_type_support(0x00, v_type, 0x0001)
14391439
assert "Expected format is PCIe but variant contains" in str(ex.value)
1440+
1441+
v_type = asyncdbus.Variant('q', 0xABCD)
14401442
with pytest.raises(asyncdbus.errors.DBusError) as ex:
1441-
await mctp.call_register_vdm_type_support(0x01,
1442-
asyncdbus.Variant('q', 0xABCD), 0x5678)
1443+
await mctp.call_register_vdm_type_support(0x01, v_type, 0x5678)
14431444
assert "Expected format is IANA but variant contains" in str(ex.value)
14441445

14451446
# Verify duplicate VDM raises error
1446-
await mctp.call_register_vdm_type_support(0x00,
1447-
asyncdbus.Variant('q', 0xABCD), 0x0001)
1447+
await mctp.call_register_vdm_type_support(0x00, v_type, 0x0001)
14481448
with pytest.raises(asyncdbus.errors.DBusError) as ex:
1449-
await mctp.call_register_vdm_type_support(0x00,
1450-
asyncdbus.Variant('q', 0xABCD), 0x0001)
1449+
await mctp.call_register_vdm_type_support(0x00, v_type, 0x0001)
14511450
assert str(ex.value) == "VDM type already registered"

0 commit comments

Comments
 (0)