Merge pull request #493 from medecau/codestyle_environment

Codestyle environment
This commit is contained in:
Jakub Roztočil 2016-07-29 23:17:00 +02:00 committed by GitHub
commit ee375b6942
5 changed files with 28 additions and 6 deletions

View File

@ -45,6 +45,11 @@ matrix:
- TOXENV=py35 - TOXENV=py35
- BREW_INSTALL=python3 - BREW_INSTALL=python3
# Python Codestyle
- os: linux
python: 3.5
env: CODESTYLE=true
install: install:
- | - |
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
@ -54,11 +59,20 @@ install:
fi fi
sudo pip install tox sudo pip install tox
fi fi
if [[ $CODESTYLE ]]; then
pip install pycodestyle
fi
script: script:
- | - |
if [[ $TRAVIS_OS_NAME == 'linux' ]]; then if [[ $TRAVIS_OS_NAME == 'linux' ]]; then
make if [[ $CODESTYLE ]]; then
# 241 - multiple spaces after ,
# 501 - line too long
pycodestyle --ignore=E241,E501
else
make
fi
else else
PATH="/usr/local/bin:$PATH" tox -e "$TOXENV" PATH="/usr/local/bin:$PATH" tox -e "$TOXENV"
fi fi

View File

@ -213,7 +213,7 @@ output_processing.add_argument(
""".format( """.format(
default=DEFAULT_STYLE, default=DEFAULT_STYLE,
available='\n'.join( available='\n'.join(
'{0}{1}'.format(8*' ', line.strip()) '{0}{1}'.format(8 * ' ', line.strip())
for line in wrap(', '.join(sorted(AVAILABLE_STYLES)), 60) for line in wrap(', '.join(sorted(AVAILABLE_STYLES)), 60)
).rstrip(), ).rstrip(),
) )

View File

@ -243,7 +243,7 @@ def main(args=sys.argv[1:], env=Environment(), custom_log_error=None):
except requests.TooManyRedirects: except requests.TooManyRedirects:
exit_status = ExitStatus.ERROR_TOO_MANY_REDIRECTS exit_status = ExitStatus.ERROR_TOO_MANY_REDIRECTS
log_error('Too many redirects (--max-redirects=%s).', log_error('Too many redirects (--max-redirects=%s).',
parsed_args.max_redirects) parsed_args.max_redirects)
except Exception as e: except Exception as e:
# TODO: Further distinction between expected and unexpected errors. # TODO: Further distinction between expected and unexpected errors.
msg = str(e) msg = str(e)

View File

@ -108,8 +108,8 @@ class TestItemParsing:
# Parsed file fields # Parsed file fields
assert 'file' in items.files assert 'file' in items.files
assert (items.files['file'][1].read().strip().decode('utf8') assert (items.files['file'][1].read().strip().
== FILE_CONTENT) decode('utf8') == FILE_CONTENT)
def test_multiple_file_fields_with_same_field_name(self): def test_multiple_file_fields_with_same_field_name(self):
items = input.parse_items([ items = input.parse_items([

10
tox.ini
View File

@ -3,7 +3,7 @@
[tox] [tox]
envlist = py26, py27, py35, pypy envlist = py26, py27, py35, pypy, codestyle
[testenv] [testenv]
@ -20,3 +20,11 @@ commands =
--verbose \ --verbose \
--doctest-modules \ --doctest-modules \
{posargs:./httpie ./tests} {posargs:./httpie ./tests}
[testenv:codestyle]
deps = pycodestyle
commands =
pycodestyle \
--ignore=E241,E501
# 241 - multiple spaces after ,
# 501 - line too long