diff --git a/.coveragerc b/.coveragerc index 7ba22a38f..ea883da05 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,2 +1,3 @@ [report] -omit = *contrib* +omit = *contrib*, *tnetstring* +include = *libmproxy* diff --git a/README.mkd b/README.mkd index dcdb1ce2b..c78e1bb6c 100644 --- a/README.mkd +++ b/README.mkd @@ -58,8 +58,8 @@ Requirements The following auxiliary components may be needed if you plan to hack on mitmproxy: -* The test suite uses the [pry](http://github.com/cortesi/pry) unit testing - library. +* The test suite uses the [nose](http://readthedocs.org/docs/nose/en/latest/) unit testing + framework. * Rendering the documentation requires [countershape](http://github.com/cortesi/countershape). __mitmproxy__ is tested and developed on OSX, Linux and OpenBSD. Windows is not diff --git a/README.txt b/README.txt index da4177378..fba22ff04 100644 --- a/README.txt +++ b/README.txt @@ -57,8 +57,8 @@ Requirements The following auxiliary components may be needed if you plan to hack on mitmproxy: -* The test suite uses the pry_ unit testing - library. +* The test suite uses the nose_ unit testing + framework. * Rendering the documentation requires countershape_. **mitmproxy** is tested and developed on OSX, Linux and OpenBSD. Windows is not @@ -80,5 +80,5 @@ following: .. _PIL: http://www.pythonware.com/products/pil/ .. _lxml: http://lxml.de/ .. _urwid: http://excess.org/urwid/ -.. _pry: http://github.com/cortesi/pry +.. _nose: http://readthedocs.org/docs/nose/en/latest/ .. _countershape: http://github.com/cortesi/countershape diff --git a/libmproxy/certutils.py b/libmproxy/certutils.py index 6ce2ea09d..31b1fa08b 100644 --- a/libmproxy/certutils.py +++ b/libmproxy/certutils.py @@ -213,10 +213,7 @@ class SSLCert: return altnames -# begin nocover -def get_remote_cert(host, port): +def get_remote_cert(host, port): # pragma: no cover addr = socket.gethostbyname(host) s = ssl.get_server_certificate((addr, port)) return SSLCert(s) -# end nocover - diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py index c897db858..e64cb4fa3 100644 --- a/libmproxy/console/contentview.py +++ b/libmproxy/console/contentview.py @@ -236,11 +236,10 @@ def view_javascript(hdrs, content, limit): opts.indent_size = 2 try: res = jsbeautifier.beautify(content[:limit], opts) - # begin nocover - except: - # Bugs in jsbeautifier mean that it can trhow arbitrary errors. - return None - # end nocover + except: # pragma: no cover + # Bugs in jsbeautifier mean that it + # can throw arbitrary errors. + return None # pragma: no cover return "JavaScript", _view_text(res, len(content), limit) diff --git a/libmproxy/controller.py b/libmproxy/controller.py index 174a3c6e5..f38d1edb4 100644 --- a/libmproxy/controller.py +++ b/libmproxy/controller.py @@ -17,8 +17,6 @@ import Queue, threading should_exit = False -#begin nocover - class Msg: def __init__(self): self.q = Queue.Queue() @@ -36,13 +34,13 @@ class Msg: self.acked = False try: masterq.put(self, timeout=3) - while not should_exit: + while not should_exit: # pragma: no cover try: g = self.q.get(timeout=0.5) except Queue.Empty: continue return g - except (Queue.Empty, Queue.Full): + except (Queue.Empty, Queue.Full): # pragma: no cover return None @@ -88,7 +86,7 @@ class Master: self.tick(self.masterq) self.shutdown() - def handle(self, msg): + def handle(self, msg): # pragma: no cover c = "handle_" + msg.__class__.__name__.lower() m = getattr(self, c, None) if m: diff --git a/libmproxy/dump.py b/libmproxy/dump.py index 5781764c2..36f546085 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -214,13 +214,12 @@ class DumpMaster(flow.FlowMaster): self._process_flow(f) return f -# begin nocover - def shutdown(self): + def shutdown(self): # pragma: no cover if self.o.wfile: self.fwriter.fo.close() return flow.FlowMaster.shutdown(self) - def run(self): + def run(self): # pragma: no cover if self.o.rfile and not self.o.keepserving: if self.script: self.load_script(None) diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 2c0fa57be..9249de866 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -257,7 +257,6 @@ class FileLike: return result -#begin nocover class RequestReplayThread(threading.Thread): def __init__(self, config, flow, masterq): self.config, self.flow, self.masterq = config, flow, masterq diff --git a/test/test_dump.py b/test/test_dump.py index 621e76e75..f13245ed0 100644 --- a/test/test_dump.py +++ b/test/test_dump.py @@ -82,7 +82,7 @@ class TestDumpMaster: libpry.raises( dump.DumpError, self._dummy_cycle, - 0, None, "", verbosity=1, rfile="test_dump.py" + 0, None, "", verbosity=1, rfile=tutils.test_data.path("test_dump.py") ) def test_options(self): diff --git a/test/test_flow.py b/test/test_flow.py index 994264e4c..885299d84 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -595,7 +595,7 @@ class TestFlowMaster: err = flow.Error(f.request, "msg") fm.handle_error(err) - fm.load_script("scripts/a.py") + fm.load_script(tutils.test_data.path("scripts/a.py")) fm.shutdown() def test_client_playback(self):