From f23afb3759358c892804aa8bda170349d5f114a3 Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Tue, 9 Jan 2018 18:29:38 +0100 Subject: [PATCH] Fix mock usage in mock_windows.uts for PY3 --- test/mock_windows.uts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/mock_windows.uts b/test/mock_windows.uts index 851f2d47e..b7690de9a 100644 --- a/test/mock_windows.uts +++ b/test/mock_windows.uts @@ -223,9 +223,11 @@ conf.prog._reload() = 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): show_interfaces() lines = mock_stdout.getvalue().split("\n")[1:] @@ -235,7 +237,7 @@ def test_show_interfaces(mock_stdout): try: int(l[:2]) except: - sys.stderr.write(l) + sys.stdout.write(l) return False return True