Hello community,
here is the log from the commit of package python-pytest-tornado for
openSUSE:Factory checked in at 2019-06-03 18:56:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-tornado (Old)
and /work/SRC/openSUSE:Factory/.python-pytest-tornado.new.5148 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-tornado"
Mon Jun 3 18:56:55 2019 rev:3 rq:707087 version:0.8.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-pytest-tornado/python-pytest-tornado.changes
2018-07-17 09:42:55.005175902 +0200
+++
/work/SRC/openSUSE:Factory/.python-pytest-tornado.new.5148/python-pytest-tornado.changes
2019-06-03 18:56:58.996392959 +0200
@@ -1,0 +2,8 @@
+Mon Jun 3 09:00:53 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 0.8.0:
+ * Added support for HTTPS testing (#50)
+ * Group commandline options for pytest (#53)
+ * Added support for Tornado 6
+
+-------------------------------------------------------------------
Old:
----
LICENSE
pytest-tornado-0.5.0.tar.gz
New:
----
pytest-tornado-0.8.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pytest-tornado.spec ++++++
--- /var/tmp/diff_new_pack.ML8xcb/_old 2019-06-03 18:56:59.492392775 +0200
+++ /var/tmp/diff_new_pack.ML8xcb/_new 2019-06-03 18:56:59.492392775 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-pytest-tornado
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,29 +12,29 @@
# 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-%{**}}
Name: python-pytest-tornado
-Version: 0.5.0
+Version: 0.8.0
Release: 0
Summary: A py.test plugin for tornado applications
License: Apache-2.0
Group: Development/Languages/Python
-Url: https://github.com/eugeniy/pytest-tornado
+URL: https://github.com/eugeniy/pytest-tornado
Source:
https://files.pythonhosted.org/packages/source/p/pytest-tornado/pytest-tornado-%{version}.tar.gz
-Source10:
https://raw.githubusercontent.com/eugeniy/pytest-tornado/v%{version}/LICENSE
-BuildRequires: %{python_module base}
+BuildRequires: %{python_module certifi}
+BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
+BuildRequires: %{python_module tornado >= 4.1}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-certifi
Requires: python-pytest
-Requires: python-tornado
+Requires: python-tornado >= 4.1
BuildArch: noarch
-
%python_subpackages
%description
@@ -43,7 +43,6 @@
%prep
%setup -q -n pytest-tornado-%{version}
-cp %{SOURCE10} .
%build
%python_build
++++++ pytest-tornado-0.5.0.tar.gz -> pytest-tornado-0.8.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-tornado-0.5.0/LICENSE
new/pytest-tornado-0.8.0/LICENSE
--- old/pytest-tornado-0.5.0/LICENSE 1970-01-01 01:00:00.000000000 +0100
+++ new/pytest-tornado-0.8.0/LICENSE 2019-05-14 14:29:17.000000000 +0200
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-tornado-0.5.0/MANIFEST.in
new/pytest-tornado-0.8.0/MANIFEST.in
--- old/pytest-tornado-0.5.0/MANIFEST.in 1970-01-01 01:00:00.000000000
+0100
+++ new/pytest-tornado-0.8.0/MANIFEST.in 2019-05-14 14:29:17.000000000
+0200
@@ -0,0 +1,3 @@
+include LICENSE
+
+prune test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-tornado-0.5.0/PKG-INFO
new/pytest-tornado-0.8.0/PKG-INFO
--- old/pytest-tornado-0.5.0/PKG-INFO 2018-04-21 21:18:25.000000000 +0200
+++ new/pytest-tornado-0.8.0/PKG-INFO 2019-05-14 14:29:51.000000000 +0200
@@ -1,10 +1,12 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: pytest-tornado
-Version: 0.5.0
+Version: 0.8.0
Summary: A py.test plugin providing fixtures and markers to simplify testing
of asynchronous tornado applications.
Home-page: https://github.com/eugeniy/pytest-tornado
Author: Eugeniy Kalinin
Author-email: [email protected]
+Maintainer: Vidar Tonaas Fauske
+Maintainer-email: [email protected]
License: Apache License, Version 2.0
Description: pytest-tornado
==============
@@ -70,8 +72,10 @@
get a port used by the test server
base_url
- get an absolute base url for the test server,
- for example, ``http://localhost:59828``
+ Get an absolute base url for the test server,
+ for example ``http://localhost:59828``.
+ Can also be used in a test with HTTPS fixture and will then return
+ a corresponding url, for example ``http://localhost:48372``.
http_server
start a tornado HTTP server, you must create an ``app`` fixture,
@@ -81,6 +85,24 @@
get an asynchronous HTTP client
+ There is also the possibility to test applications with HTTPS.
+ For running a server with HTTPS you need a certificate.
+
+ https_port
+ Get a port used by the test server.
+
+ https_server
+ Start a tornado HTTPS server. You must create an ``app`` fixture,
+ which returns the `tornado.web.Application`_ to be tested, and
+ an ``ssl_options`` fixture which returns the SSL options for the
+ `tornado.httpserver.HTTPServer`_.
+
+ https_client
+ Get an asynchronous HTTP client.
+ In case your test uses an self-signed certificate you can set
+ ``verify=False`` on the fetch method.
+
+
Show fixtures provided by the plugin::
py.test --fixtures
@@ -100,6 +122,16 @@
assert response.code == 200
+ This marker supports writing tests with async/await syntax as well:
+
+ .. code-block:: python
+
+ @pytest.mark.gen_test
+ async def test_tornado(http_client):
+ response = await
http_client.fetch('http://www.tornadoweb.org/')
+ assert response.code == 200
+
+
Marked tests will time out after 5 seconds. The timeout can be
modified by
setting an ``ASYNC_TEST_TIMEOUT`` environment variable,
``--async-test-timeout`` command line argument or a marker argument.
@@ -110,7 +142,7 @@
def test_tornado(http_client):
yield http_client.fetch('http://www.tornadoweb.org/')
- The mark can also receive a run_sync flag, which if turned off will,
instead of running the test synchronously, will add it as a coroutine and run
the IOLoop (until the timeout). For instance, this allows to test things on
both a client and a server at the same time.
+ The mark can also receive a run_sync flag, which if turned off will,
instead of running the test synchronously, will add it as a coroutine and run
the IOLoop (until the timeout). For instance, this allows to test things on
both a client and a server at the same time.
.. code-block:: python
@@ -126,6 +158,7 @@
.. _py.test: http://pytest.org/
+ .. _`tornado.httpserver.HTTPServer`:
https://www.tornadoweb.org/en/latest/httpserver.html#http-server
.. _`tornado.ioloop.IOLoop`:
http://tornado.readthedocs.org/en/latest/ioloop.html#ioloop-objects
.. _`tornado.web.Application`:
http://tornado.readthedocs.org/en/latest/web.html#application-configuration
.. _`tornado.gen`: http://tornado.readthedocs.org/en/latest/gen.html
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-tornado-0.5.0/README.rst
new/pytest-tornado-0.8.0/README.rst
--- old/pytest-tornado-0.5.0/README.rst 2018-04-21 21:17:55.000000000 +0200
+++ new/pytest-tornado-0.8.0/README.rst 2019-05-14 14:29:17.000000000 +0200
@@ -62,8 +62,10 @@
get a port used by the test server
base_url
- get an absolute base url for the test server,
- for example, ``http://localhost:59828``
+ Get an absolute base url for the test server,
+ for example ``http://localhost:59828``.
+ Can also be used in a test with HTTPS fixture and will then return
+ a corresponding url, for example ``http://localhost:48372``.
http_server
start a tornado HTTP server, you must create an ``app`` fixture,
@@ -73,6 +75,24 @@
get an asynchronous HTTP client
+There is also the possibility to test applications with HTTPS.
+For running a server with HTTPS you need a certificate.
+
+https_port
+ Get a port used by the test server.
+
+https_server
+ Start a tornado HTTPS server. You must create an ``app`` fixture,
+ which returns the `tornado.web.Application`_ to be tested, and
+ an ``ssl_options`` fixture which returns the SSL options for the
+ `tornado.httpserver.HTTPServer`_.
+
+https_client
+ Get an asynchronous HTTP client.
+ In case your test uses an self-signed certificate you can set
+ ``verify=False`` on the fetch method.
+
+
Show fixtures provided by the plugin::
py.test --fixtures
@@ -92,6 +112,16 @@
assert response.code == 200
+This marker supports writing tests with async/await syntax as well:
+
+.. code-block:: python
+
+ @pytest.mark.gen_test
+ async def test_tornado(http_client):
+ response = await http_client.fetch('http://www.tornadoweb.org/')
+ assert response.code == 200
+
+
Marked tests will time out after 5 seconds. The timeout can be modified by
setting an ``ASYNC_TEST_TIMEOUT`` environment variable,
``--async-test-timeout`` command line argument or a marker argument.
@@ -102,7 +132,7 @@
def test_tornado(http_client):
yield http_client.fetch('http://www.tornadoweb.org/')
-The mark can also receive a run_sync flag, which if turned off will, instead
of running the test synchronously, will add it as a coroutine and run the
IOLoop (until the timeout). For instance, this allows to test things on both a
client and a server at the same time.
+The mark can also receive a run_sync flag, which if turned off will, instead
of running the test synchronously, will add it as a coroutine and run the
IOLoop (until the timeout). For instance, this allows to test things on both a
client and a server at the same time.
.. code-block:: python
@@ -118,6 +148,7 @@
.. _py.test: http://pytest.org/
+.. _`tornado.httpserver.HTTPServer`:
https://www.tornadoweb.org/en/latest/httpserver.html#http-server
.. _`tornado.ioloop.IOLoop`:
http://tornado.readthedocs.org/en/latest/ioloop.html#ioloop-objects
.. _`tornado.web.Application`:
http://tornado.readthedocs.org/en/latest/web.html#application-configuration
.. _`tornado.gen`: http://tornado.readthedocs.org/en/latest/gen.html
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-tornado-0.5.0/pytest_tornado/plugin.py
new/pytest-tornado-0.8.0/pytest_tornado/plugin.py
--- old/pytest-tornado-0.5.0/pytest_tornado/plugin.py 2018-04-21
21:17:55.000000000 +0200
+++ new/pytest-tornado-0.8.0/pytest_tornado/plugin.py 2019-05-14
14:29:17.000000000 +0200
@@ -15,26 +15,6 @@
else:
iscoroutinefunction = lambda f: False
-try:
- with_timeout = tornado.gen.with_timeout
-except AttributeError:
- from tornado.ioloop import IOLoop
- from tornado.concurrent import Future, chain_future
-
- # simplified version of 'with_timeout' from tornado 4.0
- # to work with tornado 3
- def with_timeout(timeout, future, io_loop=None):
- result = Future()
- chain_future(future, result)
- if io_loop is None:
- io_loop = IOLoop.current()
- timeout_handle = io_loop.add_timeout(
- timeout,
- lambda: result.set_exception(TimeoutError("Timeout")))
- future.add_done_callback(
- lambda future: io_loop.remove_timeout(timeout_handle))
- return result
-
def _get_async_test_timeout():
try:
@@ -44,11 +24,14 @@
def pytest_addoption(parser):
- parser.addoption('--async-test-timeout', type=float,
- default=_get_async_test_timeout(),
- help='timeout in seconds before failing the test')
- parser.addoption('--app-fixture', default='app',
- help='fixture name returning a tornado application')
+ tornado_group = parser.getgroup('tornado options')
+ tornado_group.addoption('--async-test-timeout', type=float,
+ default=_get_async_test_timeout(),
+ help='timeout in seconds before failing the test')
+ tornado_group.addoption('--app-fixture', default='app',
+ help='fixture name returning a tornado
application')
+ tornado_group.addoption('--ssl-options-fixture', default='ssl_options',
+ help='fixture name returning a certificate
configuration')
def pytest_configure(config):
@@ -59,18 +42,23 @@
def _argnames(func):
- spec = inspect.getargspec(func)
- if spec.defaults:
- return spec.args[:-len(spec.defaults)]
- if isinstance(func, types.FunctionType):
- return spec.args
- # Func is a bound method, skip "self"
- return spec.args[1:]
+ if hasattr(inspect, "signature"):
+ sig = inspect.signature(func)
+ return [name for name, param in sig.parameters.items()
+ if param.default is param.empty]
+ else:
+ spec = inspect.getargspec(func)
+ if spec.defaults:
+ return spec.args[:-len(spec.defaults)]
+ if isinstance(func, types.FunctionType):
+ return spec.args
+ # Func is a bound method, skip "self"
+ return spec.args[1:]
def _timeout(item):
default_timeout = item.config.getoption('async_test_timeout')
- gen_test = item.get_marker('gen_test')
+ gen_test = item.get_closest_marker('gen_test')
if gen_test:
return gen_test.kwargs.get('timeout', default_timeout)
return default_timeout
@@ -92,7 +80,7 @@
@pytest.mark.tryfirst
def pytest_pyfunc_call(pyfuncitem):
- gen_test_mark = pyfuncitem.keywords.get('gen_test')
+ gen_test_mark = pyfuncitem.get_closest_marker('gen_test')
if gen_test_mark:
io_loop = pyfuncitem.funcargs.get('io_loop')
run_sync = gen_test_mark.kwargs.get('run_sync', True)
@@ -111,7 +99,7 @@
# Run this test function as a coroutine, until the timeout. When
completed, stop the IOLoop
# and reraise any exceptions
- future_with_timeout = with_timeout(
+ future_with_timeout = tornado.gen.with_timeout(
datetime.timedelta(seconds=_timeout(pyfuncitem)),
future)
io_loop.add_future(future_with_timeout, lambda f: io_loop.stop())
@@ -152,10 +140,21 @@
@pytest.fixture
-def base_url(http_port):
+def https_port(_unused_port):
+ """Get a port used by the test server.
+ """
+ return _unused_port[1]
+
+
[email protected]
+def base_url(request):
"""Create an absolute base url (scheme://host:port)
"""
- return 'http://localhost:%s' % http_port
+ fixturenames = request.fixturenames
+ if 'https_port' in fixturenames or 'https_client' in fixturenames or
'https_server' in fixturenames:
+ return 'https://localhost:%s' % request.getfixturevalue('https_port')
+
+ return 'http://localhost:%s' % request.getfixturevalue('http_port')
@pytest.fixture
@@ -168,7 +167,7 @@
Raises:
FixtureLookupError: tornado application fixture not found
"""
- http_app = request.getfuncargvalue(request.config.option.app_fixture)
+ http_app = request.getfixturevalue(request.config.option.app_fixture)
server = tornado.httpserver.HTTPServer(http_app)
server.add_socket(_unused_port[0])
@@ -190,6 +189,46 @@
client = tornado.httpclient.AsyncHTTPClient()
def _close():
+ client.close()
+
+ request.addfinalizer(_close)
+ return client
+
+
[email protected]
+def https_server(request, io_loop, _unused_port):
+ """Start a tornado HTTPS server.
+
+ You must create an `app` fixture, which returns
+ the `tornado.web.Application` to be tested.
+
+ Raises:
+ FixtureLookupError: tornado application fixture not found
+ """
+ https_app = request.getfixturevalue(request.config.option.app_fixture)
+ ssl_options =
request.getfixturevalue(request.config.option.ssl_options_fixture)
+ server = tornado.httpserver.HTTPServer(https_app, ssl_options=ssl_options)
+ server.add_socket(_unused_port[0])
+
+ def _stop():
+ server.stop()
+
+ if hasattr(server, 'close_all_connections'):
+ io_loop.run_sync(server.close_all_connections,
+ timeout=request.config.option.async_test_timeout)
+
+ request.addfinalizer(_stop)
+ return server
+
+
[email protected]
+def https_client(request, https_server):
+ """Get an asynchronous HTTPS client.
+ """
+ # How does on get ca_certs from the user
+ client = tornado.httpclient.AsyncHTTPClient()
+
+ def _close():
client.close()
request.addfinalizer(_close)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest-tornado-0.5.0/pytest_tornado.egg-info/PKG-INFO
new/pytest-tornado-0.8.0/pytest_tornado.egg-info/PKG-INFO
--- old/pytest-tornado-0.5.0/pytest_tornado.egg-info/PKG-INFO 2018-04-21
21:18:25.000000000 +0200
+++ new/pytest-tornado-0.8.0/pytest_tornado.egg-info/PKG-INFO 2019-05-14
14:29:51.000000000 +0200
@@ -1,10 +1,12 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: pytest-tornado
-Version: 0.5.0
+Version: 0.8.0
Summary: A py.test plugin providing fixtures and markers to simplify testing
of asynchronous tornado applications.
Home-page: https://github.com/eugeniy/pytest-tornado
Author: Eugeniy Kalinin
Author-email: [email protected]
+Maintainer: Vidar Tonaas Fauske
+Maintainer-email: [email protected]
License: Apache License, Version 2.0
Description: pytest-tornado
==============
@@ -70,8 +72,10 @@
get a port used by the test server
base_url
- get an absolute base url for the test server,
- for example, ``http://localhost:59828``
+ Get an absolute base url for the test server,
+ for example ``http://localhost:59828``.
+ Can also be used in a test with HTTPS fixture and will then return
+ a corresponding url, for example ``http://localhost:48372``.
http_server
start a tornado HTTP server, you must create an ``app`` fixture,
@@ -81,6 +85,24 @@
get an asynchronous HTTP client
+ There is also the possibility to test applications with HTTPS.
+ For running a server with HTTPS you need a certificate.
+
+ https_port
+ Get a port used by the test server.
+
+ https_server
+ Start a tornado HTTPS server. You must create an ``app`` fixture,
+ which returns the `tornado.web.Application`_ to be tested, and
+ an ``ssl_options`` fixture which returns the SSL options for the
+ `tornado.httpserver.HTTPServer`_.
+
+ https_client
+ Get an asynchronous HTTP client.
+ In case your test uses an self-signed certificate you can set
+ ``verify=False`` on the fetch method.
+
+
Show fixtures provided by the plugin::
py.test --fixtures
@@ -100,6 +122,16 @@
assert response.code == 200
+ This marker supports writing tests with async/await syntax as well:
+
+ .. code-block:: python
+
+ @pytest.mark.gen_test
+ async def test_tornado(http_client):
+ response = await
http_client.fetch('http://www.tornadoweb.org/')
+ assert response.code == 200
+
+
Marked tests will time out after 5 seconds. The timeout can be
modified by
setting an ``ASYNC_TEST_TIMEOUT`` environment variable,
``--async-test-timeout`` command line argument or a marker argument.
@@ -110,7 +142,7 @@
def test_tornado(http_client):
yield http_client.fetch('http://www.tornadoweb.org/')
- The mark can also receive a run_sync flag, which if turned off will,
instead of running the test synchronously, will add it as a coroutine and run
the IOLoop (until the timeout). For instance, this allows to test things on
both a client and a server at the same time.
+ The mark can also receive a run_sync flag, which if turned off will,
instead of running the test synchronously, will add it as a coroutine and run
the IOLoop (until the timeout). For instance, this allows to test things on
both a client and a server at the same time.
.. code-block:: python
@@ -126,6 +158,7 @@
.. _py.test: http://pytest.org/
+ .. _`tornado.httpserver.HTTPServer`:
https://www.tornadoweb.org/en/latest/httpserver.html#http-server
.. _`tornado.ioloop.IOLoop`:
http://tornado.readthedocs.org/en/latest/ioloop.html#ioloop-objects
.. _`tornado.web.Application`:
http://tornado.readthedocs.org/en/latest/web.html#application-configuration
.. _`tornado.gen`: http://tornado.readthedocs.org/en/latest/gen.html
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest-tornado-0.5.0/pytest_tornado.egg-info/SOURCES.txt
new/pytest-tornado-0.8.0/pytest_tornado.egg-info/SOURCES.txt
--- old/pytest-tornado-0.5.0/pytest_tornado.egg-info/SOURCES.txt
2018-04-21 21:18:25.000000000 +0200
+++ new/pytest-tornado-0.8.0/pytest_tornado.egg-info/SOURCES.txt
2019-05-14 14:29:51.000000000 +0200
@@ -1,3 +1,5 @@
+LICENSE
+MANIFEST.in
README.rst
setup.cfg
setup.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest-tornado-0.5.0/pytest_tornado.egg-info/requires.txt
new/pytest-tornado-0.8.0/pytest_tornado.egg-info/requires.txt
--- old/pytest-tornado-0.5.0/pytest_tornado.egg-info/requires.txt
2018-04-21 21:18:25.000000000 +0200
+++ new/pytest-tornado-0.8.0/pytest_tornado.egg-info/requires.txt
2019-05-14 14:29:51.000000000 +0200
@@ -1,2 +1,2 @@
-pytest
-tornado>=4
+pytest>=3.6
+tornado>=4.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-tornado-0.5.0/setup.py
new/pytest-tornado-0.8.0/setup.py
--- old/pytest-tornado-0.5.0/setup.py 2018-04-21 21:17:55.000000000 +0200
+++ new/pytest-tornado-0.8.0/setup.py 2019-05-14 14:29:17.000000000 +0200
@@ -11,13 +11,15 @@
setup(
name='pytest-tornado',
- version='0.5.0',
+ version='0.8.0',
description=('A py.test plugin providing fixtures and markers '
'to simplify testing of asynchronous tornado applications.'),
long_description=long_description,
url='https://github.com/eugeniy/pytest-tornado',
author='Eugeniy Kalinin',
author_email='[email protected]',
+ maintainer='Vidar Tonaas Fauske',
+ maintainer_email='[email protected]',
license='Apache License, Version 2.0',
classifiers=[
'Development Status :: 5 - Production/Stable',
@@ -33,8 +35,8 @@
],
keywords=('pytest py.test tornado async asynchronous '
'testing unit tests plugin'),
- packages=find_packages(),
- install_requires=['pytest', 'tornado>=4'],
+ packages=find_packages(exclude=["tests.*", "tests"]),
+ install_requires=['pytest>=3.6', 'tornado>=4.1'],
entry_points={
'pytest11': ['tornado = pytest_tornado.plugin'],
},