Fix mock usage in mock_windows.uts for PY3

This commit is contained in:
gpotter2 2018-01-09 18:29:38 +01:00
parent 29f54ee2f2
commit f23afb3759
1 changed files with 5 additions and 3 deletions

View File

@ -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