From 437866ebf93c654c39a25425967c31c97935833a Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 6 Jun 2016 11:42:25 -0700 Subject: Reenable pathod.language.writer tests This reverts commit 1e1b4fd88dd16b3b6b8c2cbf9337cba4dffa6c68. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b77091b1..5f065d53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,9 +22,9 @@ matrix: git: depth: 9999999 - python: 3.5 - env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_base.py" + env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py" - python: 3.5 - env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_base.py" NO_ALPN=1 + env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py" NO_ALPN=1 - python: 2.7 env: DOCS=1 script: 'cd docs && make html' -- cgit v1.2.3 From d2281e0ab38e717e92d8d2e8f84600aa48d7aa9e Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Mon, 6 Jun 2016 00:54:05 +0530 Subject: Enable Travis for test/pathod/test_language_websocket --- .travis.yml | 4 ++-- tox.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b78d331..87affb9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,9 +22,9 @@ matrix: git: depth: 9999999 - python: 3.5 - env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_base.py test/pathod/test_language_http.py" + env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_base.py test/pathod/test_language_http.py test/pathod/test_language_websocket.py" - python: 3.5 - env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_base.py test/pathod/test_language_http.py" NO_ALPN=1 + env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_base.py test/pathod/test_language_http.py test/pathod/test_language_websocket.py" NO_ALPN=1 - python: 2.7 env: DOCS=1 script: 'cd docs && SPHINXOPTS="-W" make -e html' diff --git a/tox.ini b/tox.ini index a1e6a816..9fb563a0 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ deps = -rrequirements.txt commands = py.test -n 8 --timeout 60 ./test [testenv:py35] -commands = py.test -n 8 --timeout 60 test/netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py test/pathod/test_language_http.py +commands = py.test -n 8 --timeout 60 test/netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py test/pathod/test_language_http.py test_language_websocket.py [testenv:lint] deps = flake8 -- cgit v1.2.3 From 009a4d2adde7fe8a6c00e18b610a61856bf3914f Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 6 Jun 2016 23:38:21 -0700 Subject: s/coveralls/codecov/ --- .travis.yml | 2 +- setup.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b78d331..b0eb8291 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ script: - "py.test --timeout 60 --cov netlib --cov mitmproxy --cov pathod test/$SCOPE" after_success: - - coveralls + - bash <(curl -s https://codecov.io/bash) - | if [[ $TRAVIS_OS_NAME == "osx" && $TRAVIS_PULL_REQUEST == "false" && ($TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG) ]] then diff --git a/setup.py b/setup.py index dd34465c..e8829d49 100644 --- a/setup.py +++ b/setup.py @@ -97,7 +97,6 @@ setup( "ipaddress>=1.0.15, <1.1", ], 'dev': [ - "coveralls>=1.1, <1.2", "mock>=2.0, <2.1", "flake8>=2.5.4, <3", "pytest>=2.8.7, <2.10", -- cgit v1.2.3 From 1904afe3f089124b7041bfc3e664efb65b4b4c3a Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 6 Jun 2016 23:41:41 -0700 Subject: add codecov too appveyor --- .appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index 2e1a477f..6b3933f9 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -18,6 +18,8 @@ install: - "python -c \"from OpenSSL import SSL; print(SSL.SSLeay_version(SSL.SSLEAY_VERSION))\"" test_script: - "py.test --timeout 60 --cov netlib --cov mitmproxy --cov pathod" +after_test: + - bash <(curl -s https://codecov.io/bash) cache: - C:\Users\appveyor\AppData\Local\pip\cache deploy_script: -- cgit v1.2.3 From d254fe791ad57387496eb51dde92a3ec0b6e5752 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Tue, 7 Jun 2016 11:45:38 +0530 Subject: Py3: Fix a test_language_writer test by using a byte literal --- test/pathod/test_language_writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pathod/test_language_writer.py b/test/pathod/test_language_writer.py index c02f66f3..e857e084 100644 --- a/test/pathod/test_language_writer.py +++ b/test/pathod/test_language_writer.py @@ -87,4 +87,4 @@ def test_write_values_after(): s = BytesIO() r = next(language.parse_pathod("400:ia,'xx'")) language.serve(r, s, {}) - assert s.getvalue().endswith('xx') + assert s.getvalue().endswith(b'xx') -- cgit v1.2.3 From e7ba89a327122b7e1971f27ef7b2350ea18292aa Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 7 Jun 2016 00:32:29 -0700 Subject: Update README.rst --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 4f84effd..4a665360 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ mitmproxy ^^^^^^^^^ -|travis| |coveralls| |latest_release| |python_versions| +|travis| |coverage| |latest_release| |python_versions| This repository contains the **mitmproxy** and **pathod** projects, as well as their shared networking library, **netlib**. @@ -141,8 +141,8 @@ good reason not to. :target: https://travis-ci.org/mitmproxy/mitmproxy :alt: Build Status -.. |coveralls| image:: https://shields.mitmproxy.org/coveralls/mitmproxy/mitmproxy/master.svg - :target: https://coveralls.io/r/mitmproxy/mitmproxy +.. |coverage| image:: https://codecov.io/gh/mitmproxy/mitmproxy/branch/master/graph/badge.svg + :target: https://codecov.io/gh/mitmproxy/mitmproxy :alt: Coverage Status .. |latest_release| image:: https://shields.mitmproxy.org/pypi/v/mitmproxy.svg -- cgit v1.2.3 From 5ea363afad855dcc2bb23fb8c243382718b91471 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 7 Jun 2016 00:45:18 -0700 Subject: use codecov pypi package --- .appveyor.yml | 2 +- .travis.yml | 2 +- setup.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 6b3933f9..b43a2b3d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -19,7 +19,7 @@ install: test_script: - "py.test --timeout 60 --cov netlib --cov mitmproxy --cov pathod" after_test: - - bash <(curl -s https://codecov.io/bash) + - "codecov" cache: - C:\Users\appveyor\AppData\Local\pip\cache deploy_script: diff --git a/.travis.yml b/.travis.yml index bba9a67f..17669e67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ script: - "py.test --timeout 60 --cov netlib --cov mitmproxy --cov pathod test/$SCOPE" after_success: - - bash <(curl -s https://codecov.io/bash) + - codecov - | if [[ $TRAVIS_OS_NAME == "osx" && $TRAVIS_PULL_REQUEST == "false" && ($TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG) ]] then diff --git a/setup.py b/setup.py index e8829d49..ff36f873 100644 --- a/setup.py +++ b/setup.py @@ -97,6 +97,7 @@ setup( "ipaddress>=1.0.15, <1.1", ], 'dev': [ + "codecov", "mock>=2.0, <2.1", "flake8>=2.5.4, <3", "pytest>=2.8.7, <2.10", -- cgit v1.2.3 From c6180a7b261610d2099ac8fdcbc35a6a56595c5a Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 7 Jun 2016 00:48:32 -0700 Subject: don't declare codecov as dev dependency --- .appveyor.yml | 2 +- .travis.yml | 2 +- setup.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index b43a2b3d..d7a87753 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -13,7 +13,7 @@ environment: SNAPSHOT_PASS: secure: LPjrtFrWxYhOVGXzfPRV1GjtZE/wHoKq9m/PI6hSalfysUK5p2DxTG9uHlb4Q9qV install: - - "pip install --user -U virtualenv" + - "pip install --user -U virtualenv codecov" - "dev.bat" - "python -c \"from OpenSSL import SSL; print(SSL.SSLeay_version(SSL.SSLEAY_VERSION))\"" test_script: diff --git a/.travis.yml b/.travis.yml index 17669e67..dad81c37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ install: brew outdated openssl || brew upgrade openssl brew install python fi - - pip install -U virtualenv + - pip install -U virtualenv codecov - ./dev.sh - source venv/bin/activate diff --git a/setup.py b/setup.py index ff36f873..e8829d49 100644 --- a/setup.py +++ b/setup.py @@ -97,7 +97,6 @@ setup( "ipaddress>=1.0.15, <1.1", ], 'dev': [ - "codecov", "mock>=2.0, <2.1", "flake8>=2.5.4, <3", "pytest>=2.8.7, <2.10", -- cgit v1.2.3 From 637a3be937f382ec45829a1084b2b56d1f6a55e9 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 7 Jun 2016 01:00:23 -0700 Subject: disable codecov comments --- codecov.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..db247200 --- /dev/null +++ b/codecov.yml @@ -0,0 +1 @@ +comment: off -- cgit v1.2.3 From c98c83190baa078539b79136c2de348985cc61cc Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 7 Jun 2016 00:23:07 -0700 Subject: tests++ --- netlib/strutils.py | 8 +------- test/netlib/test_strutils.py | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/netlib/strutils.py b/netlib/strutils.py index 03b371f5..5ad41c7e 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -120,13 +120,7 @@ def isMostlyBin(s): def isXML(s): - for i in s: - if i in "\n \t": - continue - elif i == "<": - return True - else: - return False + return s.strip().startswith("<") def clean_hanging_newline(t): diff --git a/test/netlib/test_strutils.py b/test/netlib/test_strutils.py index 734265c4..84a0dded 100644 --- a/test/netlib/test_strutils.py +++ b/test/netlib/test_strutils.py @@ -1,6 +1,18 @@ # coding=utf-8 +import six -from netlib import strutils +from netlib import strutils, tutils + + +def test_native(): + with tutils.raises(TypeError): + strutils.native(42) + if six.PY2: + assert strutils.native(u"foo") == b"foo" + assert strutils.native(b"foo") == b"foo" + else: + assert strutils.native(u"foo") == u"foo" + assert strutils.native(b"foo") == u"foo" def test_clean_bin(): @@ -29,6 +41,9 @@ def test_bytes_to_escaped_str(): assert strutils.bytes_to_escaped_str(b"'") == r"\'" assert strutils.bytes_to_escaped_str(b'"') == r'"' + with tutils.raises(ValueError): + strutils.bytes_to_escaped_str(u"such unicode") + def test_escaped_str_to_bytes(): assert strutils.escaped_str_to_bytes("foo") == b"foo" @@ -39,6 +54,13 @@ def test_escaped_str_to_bytes(): assert strutils.escaped_str_to_bytes(u"&!?=\\\\)") == br"&!?=\)" assert strutils.escaped_str_to_bytes(u"ΓΌ") == b'\xc3\xbc' + if six.PY2: + with tutils.raises(ValueError): + strutils.escaped_str_to_bytes(42) + else: + with tutils.raises(ValueError): + strutils.escaped_str_to_bytes(b"very byte") + def test_isBin(): assert not strutils.isBin("testing\n\r") -- cgit v1.2.3 From 14ac916bceac2aa10e55b8ea69973d5159cb6823 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Tue, 7 Jun 2016 09:17:15 +0200 Subject: use tox in Travis --- .travis.yml | 33 +++++++++++++++------------------ setup.py | 2 +- tox.ini | 28 ++++++++++++++++++++++------ 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index dad81c37..b0a4ea10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,20 +14,21 @@ matrix: fast_finish: true include: - python: 2.7 + env: TOXENV=py27 - python: 2.7 - env: NO_ALPN=1 + env: TOXENV=py27 NO_ALPN=1 + - python: 3.5 + env: TOXENV=py35 + - python: 3.5 + env: TOXENV=py35 NO_ALPN=1 - language: generic + env: TOXENV=py27 os: osx osx_image: xcode7.1 git: depth: 9999999 - - python: 3.5 - env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py test/pathod/test_language_http.py test/pathod/test_language_websocket.py" - - python: 3.5 - env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py test/pathod/test_language_http.py test/pathod/test_language_websocket.py" NO_ALPN=1 - python: 2.7 - env: DOCS=1 - script: 'cd docs && SPHINXOPTS="-W" make -e html' + env: TOXENV=docs allow_failures: - python: pypy @@ -39,23 +40,20 @@ install: brew outdated openssl || brew upgrade openssl brew install python fi - - pip install -U virtualenv codecov - - ./dev.sh - - source venv/bin/activate before_script: - - "openssl version -a" - - "python -c \"from OpenSSL import SSL; print(SSL.SSLeay_version(SSL.SSLEAY_VERSION))\"" - - "flake8 --jobs 4 --count mitmproxy netlib pathod examples test" + - "pip install tox" + - "tox -e lint" -script: - - "py.test --timeout 60 --cov netlib --cov mitmproxy --cov pathod test/$SCOPE" +script: tox after_success: - - codecov - | if [[ $TRAVIS_OS_NAME == "osx" && $TRAVIS_PULL_REQUEST == "false" && ($TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG) ]] then + pip install -U virtualenv + ./dev.sh + source venv/bin/activate pip install -e ./release python ./release/rtool.py bdist python ./release/rtool.py upload-snapshot --bdist --wheel @@ -71,7 +69,6 @@ notifications: cache: directories: - - $HOME/build/mitmproxy/mitmproxy/venv + - $HOME/build/mitmproxy/mitmproxy/.tox - $HOME/.cache/pip - $HOME/.pyenv - - $HOME/Library/Caches/pip diff --git a/setup.py b/setup.py index e8829d49..050043b3 100644 --- a/setup.py +++ b/setup.py @@ -97,8 +97,8 @@ setup( "ipaddress>=1.0.15, <1.1", ], 'dev': [ + "tox>=2.3, <3", "mock>=2.0, <2.1", - "flake8>=2.5.4, <3", "pytest>=2.8.7, <2.10", "pytest-cov>=2.2.1, <2.3", "pytest-timeout>=1.0.0, <1.1", diff --git a/tox.ini b/tox.ini index 9fb563a0..b75f536f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,31 @@ [tox] -envlist = py27, py35, lint +envlist = py27, py35, docs, lint [testenv] -deps = -rrequirements.txt +deps = + -rrequirements.txt + codecov>=2.0.5 +passenv = CI TRAVIS_BUILD_ID TRAVIS TRAVIS_BRANCH TRAVIS_JOB_NUMBER TRAVIS_PULL_REQUEST TRAVIS_JOB_ID TRAVIS_REPO_SLUG TRAVIS_COMMIT [testenv:py27] -commands = py.test -n 8 --timeout 60 ./test +commands = + py.test --cov netlib --cov mitmproxy --cov pathod --color=yes --timeout 60 ./test + codecov -e TOXENV [testenv:py35] -commands = py.test -n 8 --timeout 60 test/netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py test/pathod/test_language_http.py test_language_websocket.py +# remove bash & pipe & grep hack after cryptography ships with openssl 1.1.0 +whitelist_externals = bash +commands = + bash -c 'py.test --cov netlib --cov mitmproxy --cov pathod --color=yes --timeout 60 test/netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py test/pathod/test_language_http.py test/pathod/test_language_websocket.py 2>&1 | grep -v Cryptography_locking_cb' + codecov -e TOXENV + +[testenv:docs] +basepython = python2.7 +whitelist_externals = make +changedir = docs +setenv = SPHINXOPTS="-W" +commands = make -e html [testenv:lint] -deps = flake8 -commands = flake8 --count mitmproxy netlib pathod examples test +deps = flake8>=2.5.4, <3 +commands = flake8 --jobs 8 --count mitmproxy netlib pathod examples test -- cgit v1.2.3