diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 092990b10..4be20be12 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -197,7 +197,7 @@ class StatusBar(common.WWrap): ] if self.master.server.bound: - boundaddr = "[%s:%s]"%(self.master.server.address or "*", self.master.server.port) + boundaddr = "[%s:%s]"%(self.master.server.address() or "*", self.master.server.address.port) else: boundaddr = "" t.extend(self.get_status()) diff --git a/test/mock_urwid.py b/test/mock_urwid.py new file mode 100644 index 000000000..f132e0bdd --- /dev/null +++ b/test/mock_urwid.py @@ -0,0 +1,8 @@ +import os, sys, mock +if os.name == "nt": + m = mock.Mock() + m.__version__ = "1.1.1" + m.Widget = mock.Mock + m.WidgetWrap = mock.Mock + sys.modules['urwid'] = m + sys.modules['urwid.util'] = mock.Mock() \ No newline at end of file diff --git a/test/test_console.py b/test/test_console.py index 20534177a..0c5b45914 100644 --- a/test/test_console.py +++ b/test/test_console.py @@ -1,10 +1,9 @@ -import os -from nose.plugins.skip import SkipTest -if os.name == "nt": - raise SkipTest("Skipped on Windows.") - +import os, sys, mock, gc +from os.path import normpath +import mock_urwid from libmproxy import console from libmproxy.console import common + import tutils class TestConsoleState: @@ -89,6 +88,7 @@ class TestConsoleState: assert len(c.flowsettings) == 1 c.delete_flow(f) del f + gc.collect() assert len(c.flowsettings) == 0 @@ -107,19 +107,17 @@ def test_format_keyvals(): class TestPathCompleter: def test_lookup_construction(self): c = console._PathCompleter() - assert c.complete("/tm") == "/tmp/" - c.reset() cd = tutils.test_data.path("completion") ca = os.path.join(cd, "a") - assert c.complete(ca).endswith("/completion/aaa") - assert c.complete(ca).endswith("/completion/aab") + assert c.complete(ca).endswith(normpath("/completion/aaa")) + assert c.complete(ca).endswith(normpath("/completion/aab")) c.reset() ca = os.path.join(cd, "aaa") - assert c.complete(ca).endswith("/completion/aaa") - assert c.complete(ca).endswith("/completion/aaa") + assert c.complete(ca).endswith(normpath("/completion/aaa")) + assert c.complete(ca).endswith(normpath("/completion/aaa")) c.reset() - assert c.complete(cd).endswith("/completion/aaa") + assert c.complete(cd).endswith(normpath("/completion/aaa")) def test_completion(self): c = console._PathCompleter(True) diff --git a/test/tutils.py b/test/tutils.py index 10cd0eb93..ad2960d96 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -2,9 +2,9 @@ import os, shutil, tempfile from contextlib import contextmanager from libmproxy import flow, utils, controller, proxy from libmproxy.protocol import http -if os.name != "nt": - from libmproxy.console.flowview import FlowView - from libmproxy.console import ConsoleState +import mock_urwid +from libmproxy.console.flowview import FlowView +from libmproxy.console import ConsoleState from libmproxy.protocol.primitives import Error from netlib import certutils from nose.plugins.skip import SkipTest