From 6c2d8f7a145de7eaa8447487ae8195ee6cccbfd5 Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Thu, 9 Jul 2020 15:40:13 +0200 Subject: [PATCH 1/2] riotctrl_shell.tests: add regression test for non-str ifconfig_set() --- .../riotctrl_shell/tests/test_netif.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dist/pythonlibs/riotctrl_shell/tests/test_netif.py b/dist/pythonlibs/riotctrl_shell/tests/test_netif.py index c15c1bd7d2..b9e66fd7c8 100644 --- a/dist/pythonlibs/riotctrl_shell/tests/test_netif.py +++ b/dist/pythonlibs/riotctrl_shell/tests/test_netif.py @@ -76,12 +76,18 @@ def test_ifconfig_help(): assert res == "ifconfig foobar help" -def test_ifconfig_set(): - rc = init_ctrl(output="success: address set") +@pytest.mark.parametrize( + "option,value,expected", + [("addr", "42:de:ad:c0:ff:ee", + "ifconfig foobar set addr 42:de:ad:c0:ff:ee"), + ("chan", 17, "ifconfig foobar set chan 17")] +) +def test_ifconfig_set(option, value, expected): + rc = init_ctrl(output="success: option set") si = riotctrl_shell.netif.Ifconfig(rc) - res = si.ifconfig_set("foobar", "addr", "42:de:ad:c0:ff:ee") - assert res == "success: address set" - assert rc.term.last_command == "ifconfig foobar set addr 42:de:ad:c0:ff:ee" + res = si.ifconfig_set("foobar", option, value) + assert res == "success: option set" + assert rc.term.last_command == expected def test_ifconfig_set_error(): From b1a1bf107802dbf4eab7e7b563d177a9049bce24 Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Thu, 9 Jul 2020 15:41:06 +0200 Subject: [PATCH 2/2] riotctrl_shell.netif: allow for non str values with ifconfig_set() --- dist/pythonlibs/riotctrl_shell/netif.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/pythonlibs/riotctrl_shell/netif.py b/dist/pythonlibs/riotctrl_shell/netif.py index deb11f01fd..6f225645fc 100644 --- a/dist/pythonlibs/riotctrl_shell/netif.py +++ b/dist/pythonlibs/riotctrl_shell/netif.py @@ -286,7 +286,7 @@ class Ifconfig(ShellInteraction): if args is not None: if netif is None: raise ValueError("netif required when args are provided") - cmd += " {args}".format(args=" ".join(args)) + cmd += " {args}".format(args=" ".join(str(a) for a in args)) return self.cmd(cmd, timeout=timeout, async_=False) def ifconfig_help(self, netif, timeout=-1, async_=False):