mirror of
https://github.com/httpie/cli.git
synced 2025-06-20 17:47:48 +02:00
Added CONTRIBUTING.rst.
This commit is contained in:
parent
3d079942f4
commit
887f70f595
85
CONTRIBUTING.rst
Normal file
85
CONTRIBUTING.rst
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
Contributing to HTTPie
|
||||||
|
######################
|
||||||
|
|
||||||
|
Bug reports and code and documentation patches are greatly appretiated. You can
|
||||||
|
also help by using the development version of HTTPie and reporting any bugs you
|
||||||
|
might encounter.
|
||||||
|
|
||||||
|
Bug Reports
|
||||||
|
===========
|
||||||
|
|
||||||
|
Along with a description of the problem, please provide the output of the
|
||||||
|
failing command with the ``--debug`` flag, e.g.:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ http --debug [minimal set of arguments that trigger the error]
|
||||||
|
|
||||||
|
|
||||||
|
Contributing Code and Documentation
|
||||||
|
===================================
|
||||||
|
|
||||||
|
Before working on a new feature or a bug, please browse `existing issues`_
|
||||||
|
to see whether it has been previously discussed. If the change in question
|
||||||
|
is a bigger one, it's always good to discuss before your starting working on
|
||||||
|
it.
|
||||||
|
|
||||||
|
|
||||||
|
Development Environment
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
git clone https://github.com/<YOU>/httpie
|
||||||
|
|
||||||
|
cd httpie
|
||||||
|
|
||||||
|
git checkout -b my_topical_branch
|
||||||
|
|
||||||
|
# (Recommended: create a new virtualenv)
|
||||||
|
|
||||||
|
# Install dev. requirements:
|
||||||
|
pip install -r requirements-dev.txt
|
||||||
|
|
||||||
|
# Install HTTPie in editable mode
|
||||||
|
# (the `http' command will point to your working copy):
|
||||||
|
pip install --upgrade --force-reinstall --editable .
|
||||||
|
|
||||||
|
|
||||||
|
Making Changes
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Please make sure your changes conform to `Style Guide for Python Code`_ (PEP8).
|
||||||
|
|
||||||
|
|
||||||
|
Tests
|
||||||
|
-----
|
||||||
|
|
||||||
|
Before opening a pull requests, please make sure the `test suite`_ passes
|
||||||
|
in all of the `supported Python environments`_. You should also **add tests
|
||||||
|
for any new features and bug fixes**.
|
||||||
|
|
||||||
|
HTTPie uses `pytest`_ and `Tox`_.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# Run all tests on the current Python:
|
||||||
|
python setup.py test
|
||||||
|
|
||||||
|
# Run all tests on all installed supported Pythons:
|
||||||
|
tox
|
||||||
|
|
||||||
|
# Run specific tests:
|
||||||
|
pytest tests/test_uploads.py
|
||||||
|
|
||||||
|
|
||||||
|
Don't forget to add yourself to `AUTHORS.rst`_.
|
||||||
|
|
||||||
|
|
||||||
|
.. _Tox: http://tox.testrun.org
|
||||||
|
.. _supported Python environments: https://github.com/jkbr/httpie/blob/master/tox.ini
|
||||||
|
.. _existing issues: https://github.com/jkbr/httpie/issues?state=open
|
||||||
|
.. _AUTHORS.rst: https://github.com/jkbr/httpie/blob/master/AUTHORS.rst
|
||||||
|
.. _pytest: http://pytest.org/
|
||||||
|
.. _Style Guide for Python Code: http://python.org/dev/peps/pep-0008/
|
||||||
|
.. _test suite: https://github.com/jkbr/httpie/tree/master/tests
|
57
README.rst
57
README.rst
@ -801,9 +801,9 @@ verbatim contents of that XML file with ``Content-Type: application/xml``:
|
|||||||
$ http PUT httpbin.org/put @/data/file.xml
|
$ http PUT httpbin.org/put @/data/file.xml
|
||||||
|
|
||||||
|
|
||||||
=================
|
===============
|
||||||
Terminal Output
|
Terminal Output
|
||||||
=================
|
===============
|
||||||
|
|
||||||
HTTPie does several things by default in order to make its terminal output
|
HTTPie does several things by default in order to make its terminal output
|
||||||
easy to read.
|
easy to read.
|
||||||
@ -1201,51 +1201,14 @@ HTTPie reaches its final version ``1.0``. All changes are recorded in the
|
|||||||
Contribute
|
Contribute
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Bug reports and code and documentation patches are greatly appretiated. You can
|
Please see `CONTRIBUTING`_.
|
||||||
also help by using the development version of HTTPie and reporting any bugs you
|
|
||||||
might encounter.
|
|
||||||
|
|
||||||
Before working on a new feature or a bug, please browse the `existing issues`_
|
|
||||||
to see whether it has been previously discussed. If the change in question
|
|
||||||
is a bigger one, it's always good to discuss before your starting working on
|
|
||||||
it.
|
|
||||||
|
|
||||||
Then fork and clone `the repository`_.
|
|
||||||
|
|
||||||
It's very useful to point the ``http`` command to your local branch during
|
|
||||||
development. To do so, install HTTPie with ``pip`` in editable mode:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ pip install --upgrade --force-reinstall --editable .
|
|
||||||
|
|
||||||
|
|
||||||
Please run the existing suite of tests before a pull request is submitted:
|
====
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
python setup.py test
|
|
||||||
|
|
||||||
|
|
||||||
`Tox`_ can also be used to conveniently run tests in all of the
|
|
||||||
`supported Python environments`_:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
# Install tox
|
|
||||||
pip install tox
|
|
||||||
|
|
||||||
# Run tests
|
|
||||||
tox
|
|
||||||
|
|
||||||
|
|
||||||
Don't forget to add yourself to `AUTHORS.rst`_.
|
|
||||||
|
|
||||||
=======
|
|
||||||
Logo
|
Logo
|
||||||
=======
|
====
|
||||||
|
|
||||||
See `claudiatd/httpie-artwork`_
|
Please see `claudiatd/httpie-artwork`_
|
||||||
|
|
||||||
=======
|
=======
|
||||||
Authors
|
Authors
|
||||||
@ -1270,6 +1233,7 @@ Changelog
|
|||||||
* `0.9.0-dev`_
|
* `0.9.0-dev`_
|
||||||
* Added ``--cert`` and ``--certkey`` parameters to specify a client side
|
* Added ``--cert`` and ``--certkey`` parameters to specify a client side
|
||||||
certificate and private key for SSL
|
certificate and private key for SSL
|
||||||
|
* Started using pytest.
|
||||||
* `0.8.0`_ (2014-01-25)
|
* `0.8.0`_ (2014-01-25)
|
||||||
* Added ``field=@file.txt`` and ``field:=@file.json`` for embedding
|
* Added ``field=@file.txt`` and ``field:=@file.json`` for embedding
|
||||||
the contents of text and JSON files into request data.
|
the contents of text and JSON files into request data.
|
||||||
@ -1376,14 +1340,10 @@ Changelog
|
|||||||
.. _Requests: http://python-requests.org
|
.. _Requests: http://python-requests.org
|
||||||
.. _Pygments: http://pygments.org/
|
.. _Pygments: http://pygments.org/
|
||||||
.. _pip: http://www.pip-installer.org/en/latest/index.html
|
.. _pip: http://www.pip-installer.org/en/latest/index.html
|
||||||
.. _Tox: http://tox.testrun.org
|
|
||||||
.. _Github API: http://developer.github.com/v3/issues/comments/#create-a-comment
|
.. _Github API: http://developer.github.com/v3/issues/comments/#create-a-comment
|
||||||
.. _supported Python environments: https://github.com/jkbr/httpie/blob/master/tox.ini
|
|
||||||
.. _the repository: https://github.com/jkbr/httpie
|
|
||||||
.. _these fine people: https://github.com/jkbr/httpie/contributors
|
.. _these fine people: https://github.com/jkbr/httpie/contributors
|
||||||
.. _Jakub Roztocil: http://subtleapps.com
|
.. _Jakub Roztocil: http://subtleapps.com
|
||||||
.. _@jkbrzt: https://twitter.com/jkbrzt
|
.. _@jkbrzt: https://twitter.com/jkbrzt
|
||||||
.. _existing issues: https://github.com/jkbr/httpie/issues?state=open
|
|
||||||
.. _claudiatd/httpie-artwork: https://github.com/claudiatd/httpie-artwork
|
.. _claudiatd/httpie-artwork: https://github.com/claudiatd/httpie-artwork
|
||||||
.. _0.1.6: https://github.com/jkbr/httpie/compare/0.1.4...0.1.6
|
.. _0.1.6: https://github.com/jkbr/httpie/compare/0.1.4...0.1.6
|
||||||
.. _0.2.0: https://github.com/jkbr/httpie/compare/0.1.6...0.2.0
|
.. _0.2.0: https://github.com/jkbr/httpie/compare/0.1.6...0.2.0
|
||||||
@ -1401,5 +1361,6 @@ Changelog
|
|||||||
.. _0.7.1: https://github.com/jkbr/httpie/compare/0.6.0...0.7.1
|
.. _0.7.1: https://github.com/jkbr/httpie/compare/0.6.0...0.7.1
|
||||||
.. _0.8.0: https://github.com/jkbr/httpie/compare/0.7.1...0.8.0
|
.. _0.8.0: https://github.com/jkbr/httpie/compare/0.7.1...0.8.0
|
||||||
.. _0.9.0-dev: https://github.com/jkbr/httpie/compare/0.8.0...master
|
.. _0.9.0-dev: https://github.com/jkbr/httpie/compare/0.8.0...master
|
||||||
.. _AUTHORS.rst: https://github.com/jkbr/httpie/blob/master/AUTHORS.rst
|
|
||||||
.. _LICENSE: https://github.com/jkbr/httpie/blob/master/LICENSE
|
.. _LICENSE: https://github.com/jkbr/httpie/blob/master/LICENSE
|
||||||
|
.. _Tox: http://tox.testrun.org
|
||||||
|
.. _CONTRIBUTING: https://github.com/jkbr/httpie/blob/master/CONTRIBUTING.rst
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
tox
|
tox
|
||||||
pytest
|
pytest
|
||||||
git+git://github.com/kennethreitz/httpbin.git@7c96875e87a448f08fb1981e85eb79e77d592d98
|
|
||||||
docutils
|
docutils
|
||||||
|
8
tests/README.rst
Normal file
8
tests/README.rst
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
HTTPie Test Suite
|
||||||
|
=================
|
||||||
|
|
||||||
|
|
||||||
|
Please see `CONTRIBUTING`_.
|
||||||
|
|
||||||
|
|
||||||
|
.. _CONTRIBUTING: https://github.com/jkbr/httpie/blob/master/CONTRIBUTING.rst
|
@ -5,23 +5,20 @@ from unittest import TestCase
|
|||||||
# noinspection PyCompatibility
|
# noinspection PyCompatibility
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
from httpie import input
|
||||||
|
from httpie.input import KeyValue, KeyValueArgType
|
||||||
|
from httpie import ExitStatus
|
||||||
|
from httpie.cli import parser
|
||||||
from tests import TestEnvironment, http, httpbin, HTTP_OK
|
from tests import TestEnvironment, http, httpbin, HTTP_OK
|
||||||
from tests.fixtures import (
|
from tests.fixtures import (
|
||||||
FILE_PATH_ARG, JSON_FILE_PATH_ARG,
|
FILE_PATH_ARG, JSON_FILE_PATH_ARG,
|
||||||
JSON_FILE_CONTENT, FILE_CONTENT, FILE_PATH
|
JSON_FILE_CONTENT, FILE_CONTENT, FILE_PATH
|
||||||
)
|
)
|
||||||
|
|
||||||
from httpie import input
|
|
||||||
from httpie.input import KeyValue, KeyValueArgType
|
|
||||||
from httpie import ExitStatus
|
|
||||||
from httpie.cli import parser
|
|
||||||
|
|
||||||
|
|
||||||
class ItemParsingTest(TestCase):
|
class ItemParsingTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.key_value_type = KeyValueArgType(
|
self.key_value_type = KeyValueArgType(*input.SEP_GROUP_ALL_ITEMS)
|
||||||
*input.SEP_GROUP_ALL_ITEMS
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_invalid_items(self):
|
def test_invalid_items(self):
|
||||||
items = ['no-separator']
|
items = ['no-separator']
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import fnmatch
|
||||||
import subprocess
|
import subprocess
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
@ -11,26 +12,34 @@ def has_docutils():
|
|||||||
try:
|
try:
|
||||||
#noinspection PyUnresolvedReferences
|
#noinspection PyUnresolvedReferences
|
||||||
import docutils
|
import docutils
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_readme_errors():
|
def validate_rst(filename):
|
||||||
p = subprocess.Popen([
|
p = subprocess.Popen(
|
||||||
'rst2pseudoxml.py',
|
['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename],
|
||||||
'--report=1',
|
stderr=subprocess.PIPE,
|
||||||
'--exit-status=1',
|
stdout=subprocess.PIPE
|
||||||
os.path.join(TESTS_ROOT, '..', 'README.rst')
|
)
|
||||||
], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
|
||||||
err = p.communicate()[1]
|
err = p.communicate()[1]
|
||||||
if p.returncode:
|
assert p.returncode == 0, err
|
||||||
return err
|
|
||||||
|
|
||||||
|
|
||||||
class READMETest(TestCase):
|
def rst_files():
|
||||||
|
for root, dirnames, filenames in os.walk(os.path.dirname(TESTS_ROOT)):
|
||||||
|
if '.tox' not in root:
|
||||||
|
for filename in fnmatch.filter(filenames, '*.rst'):
|
||||||
|
yield os.path.join(root, filename)
|
||||||
|
|
||||||
@pytest.mark.skipif(not has_docutils(), reason='docutils not installed')
|
|
||||||
def test_README_reStructuredText_valid(self):
|
@pytest.mark.skipif(not has_docutils(), reason='docutils not installed')
|
||||||
errors = get_readme_errors()
|
class RSTTest(TestCase):
|
||||||
assert not errors, errors
|
|
||||||
|
def test_rst_files_syntax(self):
|
||||||
|
paths = list(rst_files())
|
||||||
|
assert paths, 'no .rst files found, which is weird'
|
||||||
|
for path in paths:
|
||||||
|
validate_rst(path)
|
||||||
|
@ -7,12 +7,8 @@ from requests.structures import CaseInsensitiveDict
|
|||||||
|
|
||||||
from httpie.compat import urlopen
|
from httpie.compat import urlopen
|
||||||
from httpie.downloads import (
|
from httpie.downloads import (
|
||||||
parse_content_range,
|
parse_content_range, filename_from_content_disposition, filename_from_url,
|
||||||
filename_from_content_disposition,
|
get_unique_filename, ContentRangeError, Download,
|
||||||
filename_from_url,
|
|
||||||
get_unique_filename,
|
|
||||||
ContentRangeError,
|
|
||||||
Download,
|
|
||||||
)
|
)
|
||||||
from tests import httpbin, http, TestEnvironment
|
from tests import httpbin, http, TestEnvironment
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ class HTTPieTest(TestCase):
|
|||||||
assert r.json['form'] == {'foo': ['bar', 'baz']}
|
assert r.json['form'] == {'foo': ['bar', 'baz']}
|
||||||
|
|
||||||
def test_POST_stdin(self):
|
def test_POST_stdin(self):
|
||||||
|
|
||||||
with open(FILE_PATH) as f:
|
with open(FILE_PATH) as f:
|
||||||
env = TestEnvironment(stdin=f, stdin_isatty=False)
|
env = TestEnvironment(stdin=f, stdin_isatty=False)
|
||||||
r = http('--form', 'POST', httpbin('/post'), env=env)
|
r = http('--form', 'POST', httpbin('/post'), env=env)
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from httpie import ExitStatus
|
from httpie import ExitStatus
|
||||||
from tests import (
|
from tests import TestEnvironment, http, httpbin, HTTP_OK, COLOR, CRLF
|
||||||
TestEnvironment,
|
|
||||||
http, httpbin,
|
|
||||||
HTTP_OK, COLOR, CRLF
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class VerboseFlagTest(TestCase):
|
class VerboseFlagTest(TestCase):
|
||||||
|
@ -40,8 +40,9 @@ class StreamTest(TestCase):
|
|||||||
"""Test that --stream works with non-prettified
|
"""Test that --stream works with non-prettified
|
||||||
redirected terminal output."""
|
redirected terminal output."""
|
||||||
with open(BIN_FILE_PATH, 'rb') as f:
|
with open(BIN_FILE_PATH, 'rb') as f:
|
||||||
env = TestEnvironment(stdout_isatty=False, stdin=f,
|
env = TestEnvironment(stdout_isatty=False,
|
||||||
stdin_isatty=False)
|
stdin_isatty=False,
|
||||||
|
stdin=f)
|
||||||
r = http('--pretty=none', '--stream', '--verbose', 'GET',
|
r = http('--pretty=none', '--stream', '--verbose', 'GET',
|
||||||
httpbin('/get'), env=env)
|
httpbin('/get'), env=env)
|
||||||
# We get 'Bad Request' but it's okay.
|
# We get 'Bad Request' but it's okay.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user