1616from 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