mirror of https://github.com/secdev/scapy.git
Fix mock usage in mock_windows.uts for PY3
This commit is contained in:
parent
29f54ee2f2
commit
f23afb3759
|
@ -223,9 +223,11 @@ conf.prog._reload()
|
||||||
= show_interfaces
|
= show_interfaces
|
||||||
|
|
||||||
from scapy.arch import show_interfaces
|
from scapy.arch import show_interfaces
|
||||||
from io import BytesIO
|
from io import StringIO, BytesIO
|
||||||
|
|
||||||
@mock.patch('sys.stdout', new_callable=BytesIO)
|
storage = BytesIO if six.PY2 else StringIO
|
||||||
|
|
||||||
|
@mock.patch('sys.stdout', new_callable=storage)
|
||||||
def test_show_interfaces(mock_stdout):
|
def test_show_interfaces(mock_stdout):
|
||||||
show_interfaces()
|
show_interfaces()
|
||||||
lines = mock_stdout.getvalue().split("\n")[1:]
|
lines = mock_stdout.getvalue().split("\n")[1:]
|
||||||
|
@ -235,7 +237,7 @@ def test_show_interfaces(mock_stdout):
|
||||||
try:
|
try:
|
||||||
int(l[:2])
|
int(l[:2])
|
||||||
except:
|
except:
|
||||||
sys.stderr.write(l)
|
sys.stdout.write(l)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue