experimental: run tests using py.tests

This commit is contained in:
Maximilian Hils 2015-09-21 18:31:30 +02:00
parent 88375ad64a
commit bba5ec7144
11 changed files with 19 additions and 15 deletions

View File

@ -41,7 +41,7 @@ before_script:
- "openssl version -a"
script:
- "nosetests --with-cov --cov-report term-missing"
- "py.test -n 4 --cov libmproxy"
after_success:
- coveralls

View File

@ -69,7 +69,7 @@ mitmproxy test suite:
.. code-block:: text
. ../venv.mitmproxy/bin/activate # ..\venv.mitmproxy\Scripts\activate.bat on Windows
nosetests ./test
py.test -n 4 --cov libmproxy
Note that the main executables for the project - ``mitmdump``, ``mitmproxy`` and
``mitmweb`` - are all created within the virtualenv. After activating the
@ -92,7 +92,7 @@ requirements installed, and you can simply run the test suite:
.. code-block:: text
nosetests --with-cov --cov-report term-missing
py.test -n 4 --cov libmproxy
Please ensure that all patches are accompanied by matching changes in the test
suite. The project maintains 100% test coverage.

View File

@ -7,10 +7,10 @@ All the mitmproxy projects strive to maintain 100% code coverage. In general,
patches and pull requests will be declined unless they're accompanied by a
suitable extension to the test suite.
Our tests are written for the nose_ test framework.
Our tests are written for the `py.test`_ or nose_ test frameworks.
At the point where you send your pull request, a command like this:
>>> nosetests --with-cov --cov-report term-missing ./test
>>> py.test -n 4 --cov libmproxy
Should give output something like this:
@ -44,3 +44,4 @@ excluded from coverage analysis either in the **.coveragerc** file, or using
these measures as sparingly as possible.
.. _nose: https://nose.readthedocs.org/en/latest/
.. _py.test: https://pytest.org/

View File

@ -106,6 +106,7 @@ class Master(object):
while True:
msg = q.get(timeout=timeout)
self.handle(*msg)
q.task_done()
changed = True
except Queue.Empty:
pass

View File

@ -40,8 +40,9 @@ scripts = {
# Developer dependencies
dev_deps = {
"mock>=1.0.1",
"nose>=1.3.0",
"nose-cov>=1.6",
"pytest>=2.8.0",
"pytest-xdist>=1.13.1",
"pytest-cov>=2.1.0",
"coveralls>=0.4.1",
"pathod>=%s, <%s" % (version.MINORVERSION, version.NEXT_MINORVERSION),
"sphinx>=1.3.1",

View File

@ -1,5 +1,5 @@
import os
from nose.plugins.skip import SkipTest
from unittest.case import SkipTest
if os.name == "nt":
raise SkipTest("Skipped on Windows.")

View File

@ -1,5 +1,5 @@
import os
from nose.plugins.skip import SkipTest
from unittest.case import SkipTest
if os.name == "nt":
raise SkipTest("Skipped on Windows.")

View File

@ -1,5 +1,5 @@
import os
from nose.plugins.skip import SkipTest
from unittest.case import SkipTest
if os.name == "nt":
raise SkipTest("Skipped on Windows.")
import libmproxy.console.palettes as palettes

View File

@ -124,6 +124,8 @@ class TcpMixin:
i2 = self.pathod("306")
self._ignore_off()
self.master.masterq.join()
assert n.status_code == 304
assert i.status_code == 305
assert i2.status_code == 306
@ -168,6 +170,8 @@ class TcpMixin:
i2 = self.pathod("306")
self._tcpproxy_off()
self.master.masterq.join()
assert n.status_code == 304
assert i.status_code == 305
assert i2.status_code == 306

View File

@ -6,16 +6,13 @@ import sys
from cStringIO import StringIO
from contextlib import contextmanager
from nose.plugins.skip import SkipTest
from mock import Mock
from unittest.case import SkipTest
import netlib.tutils
from libmproxy import utils, controller
from libmproxy.models import (
ClientConnection, ServerConnection, Error, HTTPRequest, HTTPResponse, HTTPFlow
)
from libmproxy.console.flowview import FlowView
from libmproxy.console import ConsoleState
def _SkipWindows(*args):