Skip to content

Commit f4def1b

Browse files
committed
rename to iproute2
1 parent 741a735 commit f4def1b

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

test/test_modules.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -651,47 +651,47 @@ def test_interface(host, family):
651651

652652

653653
def test_iproute2_links(host):
654-
assert host.ip.exists
654+
assert host.iproute2.exists
655655

656-
links = host.ip.links()
656+
links = host.iproute2.links()
657657
assert len(links) > 0 and len(links) < 4
658658

659659
assert links[0].get("ifname") and links[0].get("ifindex")
660660

661661

662662
def test_iproute2_routes(host):
663-
assert host.ip.exists
663+
assert host.iproute2.exists
664664

665-
routes = host.ip.routes()
665+
routes = host.iproute2.routes()
666666
assert len(routes) > 0
667667

668668

669669
def test_iproute2_rules(host):
670-
assert host.ip.exists
670+
assert host.iproute2.exists
671671

672-
rules = host.ip.rules()
672+
rules = host.iproute2.rules()
673673
assert len(rules) > 0 and len(rules) < 4
674674
assert rules[0].get("priority") == 0
675675
assert rules[0].get("src") == "all"
676676
assert rules[0].get("table") == "local"
677677

678678

679679
def test_iproute2_tunnels(host):
680-
assert host.ip.exists
680+
assert host.iproute2.exists
681681

682-
tunnels = host.ip.tunnels()
682+
tunnels = host.iproute2.tunnels()
683683
assert len(tunnels) == 0
684684

685685

686686
def test_iproute2_vrfs(host):
687-
assert host.ip.exists
687+
assert host.iproute2.exists
688688

689-
vrfs = host.ip.vrfs()
689+
vrfs = host.iproute2.vrfs()
690690
assert len(vrfs) == 0
691691

692692

693693
def test_iproute2_netns(host):
694-
assert host.ip.exists
694+
assert host.iproute2.exists
695695

696-
namespaces = host.ip.netns()
696+
namespaces = host.iproute2.netns()
697697
assert len(namespaces) == 0

testinfra/modules/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"group": "group:Group",
2828
"interface": "interface:Interface",
2929
"iptables": "iptables:Iptables",
30-
"ip": "ip:IP",
30+
"iproute2": "iproute2:IProute2",
3131
"mount_point": "mountpoint:MountPoint",
3232
"package": "package:Package",
3333
"pip": "pip:Pip",

testinfra/modules/ip.py renamed to testinfra/modules/iproute2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
from testinfra.modules.base import InstanceModule
1717

1818

19-
class IP(InstanceModule):
19+
class IProute2(InstanceModule):
2020
"""Test network configuration via iproute2 commands
2121
22-
>>> host.ip.rules()
22+
>>> host.iproute2.rules()
2323
2424
host.ip.rules(from,to,tos,fwmark,iif,oif,pref, uidrange, ipproto, sport, dport)
2525
host.ip.routes(table, device, scope, proto, src, metric)
@@ -28,11 +28,11 @@ class IP(InstanceModule):
2828
host.ip.tunnels()
2929
3030
Optionally, the protocol family can be provided to reduce the number of routes returned:
31-
>>> host.ip.routes("inet6", table="main")
31+
>>> host.iproute2.routes("inet6", table="main")
3232
...FIX
3333
3434
Optionally, this can work inside a different network namespace:
35-
>>> host.ip.routes("inet6", "vpn")
35+
>>> host.iproute2.routes("inet6", "vpn")
3636
...FIX
3737
"""
3838

@@ -97,6 +97,6 @@ def netns(self):
9797
"""Return all configured network namespaces"""
9898
cmd = f"{self._ip} --json netns show"
9999
out = self.check_output(cmd)
100-
if out is None: # ip netns returns null instead of [] in json mode
101-
return json.loads("[]")
100+
if not out: # ip netns returns null instead of [] in json mode
101+
return json.loads("[]\n")
102102
return json.loads(out)

0 commit comments

Comments
 (0)