mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
experimental: run tests using py.tests
This commit is contained in:
parent
88375ad64a
commit
bba5ec7144
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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/
|
||||
|
@ -30,7 +30,7 @@ Note that this means we don't support transparent mode for earlier versions of O
|
||||
|
||||
5. And now enable it:
|
||||
|
||||
>>>sudo pfctl -e
|
||||
>>> sudo pfctl -e
|
||||
|
||||
6. Configure sudoers to allow mitmproxy to access pfctl. Edit the file
|
||||
**/etc/sudoers** on your system as root. Add the following line to the end
|
||||
|
@ -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
|
||||
|
5
setup.py
5
setup.py
@ -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",
|
||||
|
@ -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.")
|
||||
|
||||
|
@ -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.")
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user