mock urwid to run console tests on windows, push failing testcases down to 0. :-)

This commit is contained in:
Maximilian Hils 2014-02-05 23:17:26 +01:00
parent f26d91cb81
commit 80683e77bc
4 changed files with 22 additions and 16 deletions

View File

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

8
test/mock_urwid.py Normal file
View File

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

View File

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

View File

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