commit python-pytest-httpserver for openSUSE:Factory
![](https://seccdn.libravatar.org/avatar/e2145bc5cf53dda95c308a3c75e8fef3.jpg?s=120&d=mm&r=g)
Hello community, here is the log from the commit of package python-pytest-httpserver for openSUSE:Factory checked in at 2019-07-26 17:35:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-httpserver (Old) and /work/SRC/openSUSE:Factory/.python-pytest-httpserver.new.4126 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-pytest-httpserver" Fri Jul 26 17:35:15 2019 rev:2 rq:718902 version:0.3.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-httpserver/python-pytest-httpserver.changes 2019-07-26 12:42:42.869846836 +0200 +++ /work/SRC/openSUSE:Factory/.python-pytest-httpserver.new.4126/python-pytest-httpserver.changes 2019-07-26 17:35:16.556066527 +0200 @@ -1,0 +2,7 @@ +Fri Jul 26 13:51:39 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com> + +- Update to 0.3.1: + * various bugfixes + * various documentation updates + +------------------------------------------------------------------- Old: ---- pytest-httpserver-0.3.0.tar.gz New: ---- pytest-httpserver-0.3.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-httpserver.spec ++++++ --- /var/tmp/diff_new_pack.86M5JP/_old 2019-07-26 17:35:17.084066344 +0200 +++ /var/tmp/diff_new_pack.86M5JP/_new 2019-07-26 17:35:17.088066343 +0200 @@ -12,30 +12,31 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-pytest-httpserver -Version: 0.3.0 +Version: 0.3.1 Release: 0 -License: MIT Summary: A httpserver for pytest -Url: https://www.github.com/csernazs/pytest-httpserver +License: MIT Group: Development/Languages/Python -Source: https://github.com/csernazs/pytest-httpserver/archive/0.3.0.tar.gz#/pytest-httpserver-%{version}.tar.gz -BuildRequires: fdupes -BuildRequires: python-rpm-macros +Url: https://www.github.com/csernazs/pytest-httpserver +Source: https://github.com/csernazs/pytest-httpserver/archive/%{version}.tar.gz#/pytest-httpserver-%{version}.tar.gz BuildRequires: %{python_module setuptools} BuildRequires: fdupes +BuildRequires: fdupes +BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros # SECTION test requirements BuildRequires: %{python_module Werkzeug} BuildRequires: %{python_module coverage} -BuildRequires: %{python_module pytest} BuildRequires: %{python_module pytest-cov} BuildRequires: %{python_module pytest-runner} +BuildRequires: %{python_module pytest} BuildRequires: %{python_module requests} # /SECTION Requires: python-Werkzeug @@ -61,7 +62,7 @@ %pytest -k 'not test_wait_unexpected_request and not test_wait_timeout' %files %{python_files} -%doc README.rst +%doc README.md %license LICENSE %{python_sitelib}/* ++++++ pytest-httpserver-0.3.0.tar.gz -> pytest-httpserver-0.3.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/.vscode/settings.json new/pytest-httpserver-0.3.1/.vscode/settings.json --- old/pytest-httpserver-0.3.0/.vscode/settings.json 2019-03-09 11:47:20.000000000 +0100 +++ new/pytest-httpserver-0.3.1/.vscode/settings.json 2019-07-25 08:34:32.000000000 +0200 @@ -1,9 +1,9 @@ { "python.pythonPath": "${workspaceFolder}/.venv/bin/python3", "python.linting.pylintPath": "${workspaceFolder}/.venv/bin/pylint", - "python.unitTest.pyTestArgs": [ + "python.testing.pytestArgs": [ "tests" ], - "python.unitTest.pyTestEnabled": true, - "python.unitTest.pyTestPath": "${workspaceFolder}/.venv/bin/pytest" + "python.testing.pytestEnabled": true, + "python.testing.pytestPath": "${workspaceFolder}/.venv/bin/pytest" } \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/MANIFEST.in new/pytest-httpserver-0.3.1/MANIFEST.in --- old/pytest-httpserver-0.3.0/MANIFEST.in 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-httpserver-0.3.1/MANIFEST.in 2019-07-25 08:34:32.000000000 +0200 @@ -0,0 +1,2 @@ +include README.md +include LICENSE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/Makefile new/pytest-httpserver-0.3.1/Makefile --- old/pytest-httpserver-0.3.0/Makefile 2019-03-09 11:47:20.000000000 +0100 +++ new/pytest-httpserver-0.3.1/Makefile 2019-07-25 08:34:32.000000000 +0200 @@ -1,8 +1,10 @@ +PYTHON ?= python3 + .PHONY: doc .venv/bin/pip: - python3 -m venv .venv + ${PYTHON} -m venv .venv .venv/bin/pip3 install --upgrade pip wheel venv: .venv/bin/pip diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/README.md new/pytest-httpserver-0.3.1/README.md --- old/pytest-httpserver-0.3.0/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-httpserver-0.3.1/README.md 2019-07-25 08:34:32.000000000 +0200 @@ -0,0 +1,83 @@ +[![Build Status](https://travis-ci.org/csernazs/pytest-httpserver.svg?branch=master)](https://travis-ci.org/csernazs/pytest-httpserver) +[![Documentation Status](https://readthedocs.org/projects/pytest-httpserver/badge/?version=latest)](https://pytest-httpserver.readthedocs.io/en/latest/?badge=latest) + [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) + +## pytest_httpserver + +HTTP server for pytest + + +### Nutshell + +This library is designed to help to test http clients without contacting the real http server. +In other words, it is a fake http server which is accessible via localhost can be started with +the pre-defined expected http requests and their responses. + +### Example + +```python +def test_my_client(httpserver): # httpserver is a pytest fixture which starts the server + # set up the server to serve /foobar with the json + httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"}) + # check that the request is served + assert requests.get(httpserver.url_for("/foobar")).json() == {'foo': 'bar'} +``` + +You can also use the library without pytest. There's a with statement to ensure that the server is stopped. + + +```python +with HTTPServer() as httpserver: + # set up the server to serve /foobar with the json + httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"}) + # check that the request is served + print(requests.get(httpserver.url_for("/foobar")).json()) +``` + +### Documentation + +Please find the API documentation at https://pytest-httpserver.readthedocs.io/en/latest/. + +### Features + +You can set up a dozen of expectations for the requests, and also what response should be sent by the server to the client. + + +#### Requests + +There are three different types: + +- **permanent**: this will be always served when there's match for this request, you can make as many HTTP requests as you want +- **oneshot**: this will be served only once when there's a match for this request, you can only make 1 HTTP request +- **ordered**: same as oneshot but the order must be strictly matched to the order of setting up + +You can also fine-tune the expected request. The following can be specified: + +- URI (this is a must) +- HTTP method +- headers +- query string +- data (HTTP payload of the request) + + +#### Responses + +Once you have the expectations for the request set up, you should also define the response you want to send back. +The following is supported currently: + +- respond arbitrary data (string or bytearray) +- respond a json (a python dict converted in-place to json) +- respond a Response object of werkzeug +- use your own function + +Similar to requests, you can fine-tune what response you want to send: + +- HTTP status +- headers +- data + + +### Missing features +* HTTP/2 +* Keepalive +* ~~TLS~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/README.rst new/pytest-httpserver-0.3.1/README.rst --- old/pytest-httpserver-0.3.0/README.rst 2019-03-09 11:47:20.000000000 +0100 +++ new/pytest-httpserver-0.3.1/README.rst 1970-01-01 01:00:00.000000000 +0100 @@ -1,92 +0,0 @@ -|build| |doc| - - -pytest_httpserver -================= -HTTP server for pytest - - -Nutshell --------- - -This library is designed to help to test http clients without contacting the real http server. -In other words, it is a fake http server which is accessible via localhost can be started with -the pre-defined expected http requests and their responses. - -Example -------- - -.. code-block:: python - - def test_my_client(httpserver): # httpserver is a pytest fixture which starts the server - # set up the server to serve /foobar with the json - httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"}) - # check that the request is served - assert requests.get(httpserver.url_for("/foobar")).json() == {'foo': 'bar'} - - -You can also use the library without pytest. There's a with statement to ensure that the server is stopped. - - -.. code-block:: python - - with HTTPServer() as httpserver: - # set up the server to serve /foobar with the json - httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"}) - # check that the request is served - print(requests.get(httpserver.url_for("/foobar")).json()) - - -Features --------- -You can set up a dozen of expectations for the requests, and also what response should be sent by the server to the client. - - -Requests -~~~~~~~~ -There are three different types: - -- **permanent**: this will be always served when there's match for this request, you can make as many HTTP requests as you want -- **oneshot**: this will be served only once when there's a match for this request, you can only make 1 HTTP request -- **ordered**: same as oneshot but the order must be strictly matched to the order of setting up - -You can also fine-tune the expected request. The following can be specified: - -- URI (this is a must) -- HTTP method -- headers -- query string -- data (HTTP payload of the request) - - -Responses -~~~~~~~~~ - -Once you have the expectations for the request set up, you should also define the response you want to send back. -The following is supported currently: - -- respond arbitrary data (string or bytearray) -- respond a json (a python dict converted in-place to json) -- respond a Response object of werkzeug -- use your own function - -Similar to requests, you can fine-tune what response you want to send: - -- HTTP status -- headers -- data - - -Missing features ----------------- -* HTTP/2 -* Keepalive -* TLS - - -.. |build| image:: https://travis-ci.org/csernazs/pytest-httpserver.svg?branch=master - :target: https://travis-ci.org/csernazs/pytest-httpserver - -.. |doc| image:: https://readthedocs.org/projects/pytest-httpserver/badge/?version=latest - :target: https://pytest-httpserver.readthedocs.io/en/latest/?badge=latest - :alt: Documentation Status diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/doc/conf.py new/pytest-httpserver-0.3.1/doc/conf.py --- old/pytest-httpserver-0.3.0/doc/conf.py 2019-03-09 11:47:20.000000000 +0100 +++ new/pytest-httpserver-0.3.1/doc/conf.py 2019-07-25 08:34:32.000000000 +0200 @@ -58,9 +58,9 @@ # built documents. # # The short X.Y version. -version = '0.3.0' +version = '0.3.1' # The full version, including alpha/beta/rc tags. -release = '0.3.0' +release = '0.3.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/doc/guide.rst new/pytest-httpserver-0.3.1/doc/guide.rst --- old/pytest-httpserver-0.3.0/doc/guide.rst 2019-03-09 11:47:20.000000000 +0100 +++ new/pytest-httpserver-0.3.1/doc/guide.rst 2019-07-25 08:34:32.000000000 +0200 @@ -9,17 +9,27 @@ thread, so you will need to make sure that the :py:meth:`pytest_httpserver.HTTPServer.stop` method is called before your code exits. -A free TCP port needs to be specified when instantiating the server, where no other daemon is listening. +When using the pytest plugin, the server is started at the first usage of the server and it will +remain running for the whole test suite. For each test function, a clear http server will be used +to avoid crosstalk. -If you are using the pytest plugin it is done automatically by the plugin. Possibility to change -the TCP port is TBD. +A free TCP port needs to be specified when instantiating the server. Setting 0 as the port number +will select a free (ephemeral) TCP port which is guaranteed to be free. +This is the default behavior. -When using pytest plugin, specifying the bind address and bind port can also be possible via environment -variables. Setting PYTEST_HTTPSERVER_HOST and PYTEST_HTTPSERVER_PORT will change the bind host and bind -port, respectively. +Specifying the bind host and port can be done in several ways: + +* Setting PYTEST_HTTPSERVER_HOST and PYTEST_HTTPSERVER_PORT will change the bind host and bind + port, respectively. + +* If pytest plugin is not used, the DEFAULT_LISTEN_HOST and DEFAULT_LISTEN_PORT class attributes can be set + on the HTTPServer class. + +* bind host and port can be specified for the constructor of the + :py:class:`pytest_httpserver.server.HTTPServer` class. + +* Overriding the ``httpserver_listen_address`` fixture in pytest. -If pytest plugin is not used, the DEFAULT_LISTEN_HOST and DEFAULT_LISTEN_PORT class attributes can be set -on the HTTPServer class. Configuring ----------- @@ -54,7 +64,7 @@ ------------------------------------- It is possible to wait until all oneshot and ordered handlers are exhausted or any error happened. This is provided by a context manager which waits until one of these events occured. This can be further customized -by :py:class:`pytest_httpserver.server.WaitSettings` object to raise or not raise assertion. +by :py:class:`pytest_httpserver.server.WaitingSettings` object to raise or not raise assertion. Debugging errors while testing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/example_pytest.py new/pytest-httpserver-0.3.1/example_pytest.py --- old/pytest-httpserver-0.3.0/example_pytest.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-httpserver-0.3.1/example_pytest.py 2019-07-25 08:34:32.000000000 +0200 @@ -0,0 +1,29 @@ +# Run this code as 'pytest example_pytest.py' + +import pytest +import requests +from pytest_httpserver import HTTPServer + +# specify where the server should bind to +# you can return 0 as the port, in this case it will bind to a free (ephemeral) TCP port +@pytest.fixture +def httpserver_listen_address(): + return ("127.0.0.1", 8000) + + +# specify httpserver fixture +def test_oneshot_and_permanent_happy_path1(httpserver: HTTPServer): + # define some request handlers + # more details in the documentation + httpserver.expect_request("/permanent").respond_with_data("OK permanent") + httpserver.expect_oneshot_request("/oneshot1").respond_with_data("OK oneshot1") + httpserver.expect_oneshot_request("/oneshot2").respond_with_data("OK oneshot2") + + # query those handlers with a real HTTP client (requests in this example but could by anything) + # the 'url_for' method formats the final URL, so there's need to wire-in any ports + assert requests.get(httpserver.url_for("/permanent")).text == "OK permanent" + assert requests.get(httpserver.url_for("/oneshot1")).text == "OK oneshot1" + assert requests.get(httpserver.url_for("/oneshot2")).text == "OK oneshot2" + assert requests.get(httpserver.url_for("/permanent")).text == "OK permanent" + + assert len(httpserver.oneshot_handlers) == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/pytest_httpserver/pytest_plugin.py new/pytest-httpserver-0.3.1/pytest_httpserver/pytest_plugin.py --- old/pytest-httpserver-0.3.0/pytest_httpserver/pytest_plugin.py 2019-03-09 11:47:20.000000000 +0100 +++ new/pytest-httpserver-0.3.1/pytest_httpserver/pytest_plugin.py 2019-07-25 08:34:32.000000000 +0200 @@ -30,13 +30,18 @@ @pytest.fixture -def httpserver(): +def httpserver_listen_address(): + return get_httpserver_listen_address() + + +@pytest.fixture +def httpserver(httpserver_listen_address): if Plugin.SERVER: Plugin.SERVER.clear() yield Plugin.SERVER return - host, port = get_httpserver_listen_address() + host, port = httpserver_listen_address if not host: host = HTTPServer.DEFAULT_LISTEN_HOST if not port: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/release_checklist.md new/pytest-httpserver-0.3.1/release_checklist.md --- old/pytest-httpserver-0.3.0/release_checklist.md 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-httpserver-0.3.1/release_checklist.md 2019-07-25 08:34:32.000000000 +0200 @@ -0,0 +1,14 @@ + +Sounds like a python script for me, but here's the manual checklist: + +- [ ] check the latest commits on master +- [ ] every major change reflected in the release notes +- [ ] check the latest doc build at rtd.org +- [ ] check that master is green at travis +- [ ] version bump (sphinx/conf.py, setup.py) +- [ ] tag the HEAD +- [ ] generate documentation, check version at release notes +- [ ] build the dist: setup.py sdist bdist_wheel +- [ ] install package in a local venv +- [ ] push to github (version bump, tags) +- [ ] upload dist/* to pypi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/releasenotes/notes/httpserver-listen-address-fixture-87f18b2cdbf47532.yaml new/pytest-httpserver-0.3.1/releasenotes/notes/httpserver-listen-address-fixture-87f18b2cdbf47532.yaml --- old/pytest-httpserver-0.3.0/releasenotes/notes/httpserver-listen-address-fixture-87f18b2cdbf47532.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-httpserver-0.3.1/releasenotes/notes/httpserver-listen-address-fixture-87f18b2cdbf47532.yaml 2019-07-25 08:34:32.000000000 +0200 @@ -0,0 +1,6 @@ +--- + +features: + - | + Add httpserver_listen_address fixture which is used to set up the bind address and port + of the server. Setting bind address and port is possible by overriding this fixture. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/setup.py new/pytest-httpserver-0.3.1/setup.py --- old/pytest-httpserver-0.3.0/setup.py 2019-03-09 11:47:20.000000000 +0100 +++ new/pytest-httpserver-0.3.1/setup.py 2019-07-25 08:34:32.000000000 +0200 @@ -3,11 +3,11 @@ from setuptools import setup, find_packages -DESCRIPTION = open("README.rst").read() +DESCRIPTION = open("README.md").read() setup( name="pytest_httpserver", - version="0.3.0", + version="0.3.1", url="https://www.github.com/csernazs/pytest-httpserver", packages=find_packages(), author="Zsolt Cserna", @@ -15,6 +15,7 @@ description="pytest-httpserver is a httpserver for pytest", entry_points={"pytest11": ["pytest_httpserver = pytest_httpserver.pytest_plugin"]}, long_description=DESCRIPTION, + long_description_content_type="text/markdown", python_requires=">=3.4", install_requires=[ "typing;python_version<'3.5'", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-httpserver-0.3.0/tests/test_wait.py new/pytest-httpserver-0.3.1/tests/test_wait.py --- old/pytest-httpserver-0.3.0/tests/test_wait.py 2019-03-09 11:47:20.000000000 +0100 +++ new/pytest-httpserver-0.3.1/tests/test_wait.py 2019-07-25 08:34:32.000000000 +0200 @@ -30,7 +30,7 @@ requests.get(httpserver.url_for("/foobaz")) assert not waiting.result no_handler_text = 'No handler found for request' - assert no_handler_text in str(error) + assert no_handler_text in str(error.value) make_unexpected_request_and_wait() @@ -49,7 +49,7 @@ assert not waiting.result waiting_time_error = 0.1 assert waiting.elapsed_time == approx(waiting_timeout, abs=waiting_time_error) - assert 'Wait timeout occurred, but some handlers left' in str(error) + assert 'Wait timeout occurred, but some handlers left' in str(error.value) def test_wait_raise_assertion_false(httpserver: HTTPServer):
participants (1)
-
root