Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYUP Scheduled weekly dependency update for week 03 #293

Merged
merged 17 commits into from Jan 17, 2022

Conversation

pyup-bot
Copy link
Collaborator

Update numpy from 1.22.0 to 1.22.1.

The bot wasn't able to find a changelog for this release. Got an idea?

Links

Update pytest-asyncio from 0.16.0 to 0.17.1.

Changelog

0.17.1

-----------------

-   Fixes a bug that prevents async Hypothesis tests from working
 without explicit `asyncio` marker when `--asyncio-mode=auto` is set.
 [\258](https://github.com/pytest-dev/pytest-asyncio/issues/258)
-   Fixed a bug that closes the default event loop if the loop doesn\'t
 exist
 [\257](https://github.com/pytest-dev/pytest-asyncio/issues/257)
-   Added type annotations.
 [\198](https://github.com/pytest-dev/pytest-asyncio/issues/198)
-   Show asyncio mode in pytest report headers.
 [\266](https://github.com/pytest-dev/pytest-asyncio/issues/266)
-   Relax `asyncio_mode` type definition; it allows to support pytest
 6.1+.
 [\262](https://github.com/pytest-dev/pytest-asyncio/issues/262)

0.17.0

~~~~~~~~~~~~~~~~~~~
- `pytest-asyncio` no longer alters existing event loop policies. `168 <https://github.com/pytest-dev/pytest-asyncio/issues/168>`_, `#188 <https://github.com/pytest-dev/pytest-asyncio/issues/168>`_
- Drop support for Python 3.6
- Fixed an issue when pytest-asyncio was used in combination with `flaky` or inherited asynchronous Hypothesis tests. `178 <https://github.com/pytest-dev/pytest-asyncio/issues/178>`_ `#231 <https://github.com/pytest-dev/pytest-asyncio/issues/231>`_
- Added `flaky <https://pypi.org/project/flaky/>`_ to test dependencies
- Added ``unused_udp_port`` and ``unused_udp_port_factory`` fixtures (similar to ``unused_tcp_port`` and ``unused_tcp_port_factory`` counterparts. `99 <https://github.com/pytest-dev/pytest-asyncio/issues/99>`_
- Added the plugin modes: *strict*, *auto*, and *legacy*. See `documentation <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details. `125 <https://github.com/pytest-dev/pytest-asyncio/issues/125>`_
- Correctly process ``KeyboardInterrupt`` during async fixture setup phase `219 <https://github.com/pytest-dev/pytest-asyncio/issues/219>`_

0.17.0a6

---
title: 'pytest-asyncio: pytest support for asyncio'
---

[![image](https://img.shields.io/pypi/v/pytest-asyncio.svg)](https://pypi.python.org/pypi/pytest-asyncio)

[![image](https://github.com/pytest-dev/pytest-asyncio/workflows/CI/badge.svg)](https://github.com/pytest-dev/pytest-asyncio/actions?workflow=CI)

[![image](https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/master/graph/badge.svg)](https://codecov.io/gh/pytest-dev/pytest-asyncio)

[![Supported Python versions](https://img.shields.io/pypi/pyversions/pytest-asyncio.svg)](https://github.com/pytest-dev/pytest-asyncio)

[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

pytest-asyncio is an Apache2 licensed library, written in Python, for
testing asyncio code with pytest.

asyncio code is usually written in the form of coroutines, which makes
it slightly more difficult to test using normal testing tools.
pytest-asyncio provides useful fixtures and markers to make testing
easier.

{.sourceCode .python}
pytest.mark.asyncio
async def test_some_asyncio_code():
 res = await library.do_something()
 assert b"expected result" == res


pytest-asyncio has been strongly influenced by
[pytest-tornado](https://github.com/eugeniy/pytest-tornado).

Features
========

-   fixtures for creating and injecting versions of the asyncio event
 loop
-   fixtures for injecting unused tcp/udp ports
-   pytest markers for treating tests as asyncio coroutines
-   easy testing with non-default event loops
-   support for [async def]{.title-ref} fixtures and async generator
 fixtures
-   support *auto* mode to handle all async fixtures and tests
 automatically by asyncio; provide *strict* mode if a test suite
 should work with different async frameworks simultaneously, e.g.
 `asyncio` and `trio`.

Installation
============

To install pytest-asyncio, simply:

{.sourceCode .bash}
$ pip install pytest-asyncio


This is enough for pytest to pick up pytest-asyncio.

Modes
=====

Starting from `pytest-asyncio>=0.17`, three modes are provided: *auto*,
*strict* and *legacy* (default).

The mode can be set by `asyncio_mode` configuration option in
[configuration
file](https://docs.pytest.org/en/latest/reference/customize.html):

{.sourceCode .ini}
pytest.ini
[pytest]
asyncio_mode = auto


The value can be overriden by command-line option for `pytest`
invocation:

{.sourceCode .bash}
$ pytest tests --asyncio-mode=strict


Auto mode
---------

When the mode is auto, all discovered *async* tests are considered
*asyncio-driven* even if they have no `pytest.mark.asyncio` marker.

All async fixtures are considered *asyncio-driven* as well, even if they
are decorated with a regular `pytest.fixture` decorator instead of
dedicated `pytest_asyncio.fixture` counterpart.

*asyncio-driven* means that tests and fixtures are executed by
`pytest-asyncio` plugin.

This mode requires the simplest tests and fixtures configuration and is
recommended for default usage *unless* the same project and its test
suite should execute tests from different async frameworks, e.g.
`asyncio` and `trio`. In this case, auto-handling can break tests
designed for other framework; plase use *strict* mode instead.

Strict mode
-----------

Strict mode enforces `pytest.mark.asyncio` and
`pytest_asyncio.fixture` usage. Without these markers, tests and
fixtures are not considered as *asyncio-driven*, other pytest plugin can
handle them.

Please use this mode if multiple async frameworks should be combined in
the same test suite.

Legacy mode
-----------

This mode follows rules used by `pytest-asyncio<0.17`: tests are not
auto-marked but fixtures are.

This mode is used by default for the sake of backward compatibility,
deprecation warnings are emitted with suggestion to either switching to
`auto` mode or using `strict` mode with `pytest_asyncio.fixture`
decorators.

In future, the default will be changed.

Fixtures
========

`event_loop`
------------

Creates and injects a new instance of the default asyncio event loop. By
default, the loop will be closed at the end of the test (i.e. the
default fixture scope is `function`).

Note that just using the `event_loop` fixture won\'t make your test
function a coroutine. You\'ll need to interact with the event loop
directly, using methods like `event_loop.run_until_complete`. See the
`pytest.mark.asyncio` marker for treating test functions like
coroutines.

Simply using this fixture will not set the generated event loop as the
default asyncio event loop, or change the asyncio event loop policy in
any way. Use `pytest.mark.asyncio` for this purpose.

{.sourceCode .python}
def test_http_client(event_loop):
 url = "http://httpbin.org/get"
 resp = event_loop.run_until_complete(http_client(url))
 assert b"HTTP/1.1 200 OK" in resp


This fixture can be easily overridden in any of the standard pytest
locations (e.g. directly in the test file, or in `conftest.py`) to use a
non-default event loop. This will take effect even if you\'re using the
`pytest.mark.asyncio` marker and not the `event_loop` fixture directly.

{.sourceCode .python}
pytest.fixture
def event_loop():
 loop = MyCustomLoop()
 yield loop
 loop.close()


If the `pytest.mark.asyncio` marker is applied, a pytest hook will
ensure the produced loop is set as the default global loop. Fixtures
depending on the `event_loop` fixture can expect the policy to be
properly modified when they run.

`unused_tcp_port`
-----------------

Finds and yields a single unused TCP port on the localhost interface.
Useful for binding temporary test servers.

`unused_tcp_port_factory`
-------------------------

A callable which returns a different unused TCP port each invocation.
Useful when several unused TCP ports are required in a test.

{.sourceCode .python}
def a_test(unused_tcp_port_factory):
 port1, port2 = unused_tcp_port_factory(), unused_tcp_port_factory()
 ...


`unused_udp_port` and `unused_udp_port_factory`
-----------------------------------------------

Work just like their TCP counterparts but return unused UDP ports.

Async fixtures
--------------

Asynchronous fixtures are defined just like ordinary pytest fixtures,
except they should be decorated with `pytest_asyncio.fixture`.

{.sourceCode .python3}
import pytest_asyncio


pytest_asyncio.fixture
async def async_gen_fixture():
 await asyncio.sleep(0.1)
 yield "a value"


pytest_asyncio.fixture(scope="module")
async def async_fixture():
 return await asyncio.sleep(0.1)


All scopes are supported, but if you use a non-function scope you will
need to redefine the `event_loop` fixture to have the same or broader
scope. Async fixtures need the event loop, and so must have the same or
narrower scope than the `event_loop` fixture.

*auto* and *legacy* mode automatically converts async fixtures declared
with the standard `pytest.fixture` decorator to *asyncio-driven*
versions.

Markers
=======

`pytest.mark.asyncio`
---------------------

Mark your test coroutine with this marker and pytest will execute it as
an asyncio task using the event loop provided by the `event_loop`
fixture. See the introductory section for an example.

The event loop used can be overridden by overriding the `event_loop`
fixture (see above).

In order to make your test code a little more concise, the pytest
`pytestmark`\_ feature can be used to mark entire modules or classes
with this marker. Only test coroutines will be affected (by default,
coroutines prefixed by `test_`), so, for example, fixtures are safe to
define.

{.sourceCode .python}
import asyncio

import pytest

All test coroutines will be treated as marked.
pytestmark = pytest.mark.asyncio


async def test_example(event_loop):
 """No marker!"""
 await asyncio.sleep(0, loop=event_loop)


In *auto* mode, the `pytest.mark.asyncio` marker can be omitted, the
marker is added automatically to *async* test functions.

Note about unittest
===================

Test classes subclassing the standard
[unittest](https://docs.python.org/3/library/unittest.html) library are
not supported, users are recommended to use
[unitest.IsolatedAsyncioTestCase](https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase)
or an async framework such as
[asynctest](https://asynctest.readthedocs.io/en/latest).

Changelog
=========

0.17.0a4

pytest-asyncio: pytest support for asyncio
==========================================

.. image:: https://img.shields.io/pypi/v/pytest-asyncio.svg
 :target: https://pypi.python.org/pypi/pytest-asyncio
.. image:: https://github.com/pytest-dev/pytest-asyncio/workflows/CI/badge.svg
 :target: https://github.com/pytest-dev/pytest-asyncio/actions?workflow=CI
.. image:: https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/master/graph/badge.svg
 :target: https://codecov.io/gh/pytest-dev/pytest-asyncio
.. image:: https://img.shields.io/pypi/pyversions/pytest-asyncio.svg
 :target: https://github.com/pytest-dev/pytest-asyncio
 :alt: Supported Python versions
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
 :target: https://github.com/ambv/black

pytest-asyncio is an Apache2 licensed library, written in Python, for testing
asyncio code with pytest.

asyncio code is usually written in the form of coroutines, which makes it
slightly more difficult to test using normal testing tools. pytest-asyncio
provides useful fixtures and markers to make testing easier.

.. code-block:: python

 pytest.mark.asyncio
 async def test_some_asyncio_code():
     res = await library.do_something()
     assert b"expected result" == res

pytest-asyncio has been strongly influenced by pytest-tornado_.

.. _pytest-tornado: https://github.com/eugeniy/pytest-tornado

Features
--------

- fixtures for creating and injecting versions of the asyncio event loop
- fixtures for injecting unused tcp/udp ports
- pytest markers for treating tests as asyncio coroutines
- easy testing with non-default event loops
- support for `async def` fixtures and async generator fixtures
- support *auto* mode to handle all async fixtures and tests automatically by asyncio;
provide *strict* mode if a test suite should work with different async frameworks
simultaneously, e.g. ``asyncio`` and ``trio``.

Installation
------------

To install pytest-asyncio, simply:

.. code-block:: bash

 $ pip install pytest-asyncio

This is enough for pytest to pick up pytest-asyncio.

Modes
-----

Starting from ``pytest-asyncio>=0.17``, three modes are provided: *auto*, *strict* and
*legacy* (default).

The mode can be set by ``asyncio_mode`` configuration option in `configuration file
<https://docs.pytest.org/en/latest/reference/customize.html>`_:

.. code-block:: ini

 pytest.ini
[pytest]
asyncio_mode = auto

The value can be overriden by command-line option for ``pytest`` invocation:

.. code-block:: bash

$ pytest tests --asyncio-mode=strict

Auto mode
~~~~~~~~~

When the mode is auto, all discovered *async* tests are considered *asyncio-driven* even
if they have no ``pytest.mark.asyncio`` marker.

All async fixtures are considered *asyncio-driven* as well, even if they are decorated
with a regular ``pytest.fixture`` decorator instead of dedicated
``pytest_asyncio.fixture`` counterpart.

*asyncio-driven* means that tests and fixtures are executed by ``pytest-asyncio``
plugin.

This mode requires the simplest tests and fixtures configuration and is
recommended for default usage *unless* the same project and its test suite should
execute tests from different async frameworks, e.g. ``asyncio`` and ``trio``.  In this
case, auto-handling can break tests designed for other framework; plase use *strict*
mode instead.

Strict mode
~~~~~~~~~~~

Strict mode enforces ``pytest.mark.asyncio`` and ``pytest_asyncio.fixture`` usage.
Without these markers, tests and fixtures are not considered as *asyncio-driven*, other
pytest plugin can handle them.

Please use this mode if multiple async frameworks should be combined in the same test
suite.


Legacy mode
~~~~~~~~~~~

This mode follows rules used by ``pytest-asyncio<0.17``: tests are not auto-marked but
fixtures are.

This mode is used by default for the sake of backward compatibility, deprecation
warnings are emitted with suggestion to either switching to ``auto`` mode or using
``strict`` mode with ``pytest_asyncio.fixture`` decorators.

In future, the default will be changed.


Fixtures
--------

``event_loop``
~~~~~~~~~~~~~~
Creates and injects a new instance of the default asyncio event loop. By
default, the loop will be closed at the end of the test (i.e. the default
fixture scope is ``function``).

Note that just using the ``event_loop`` fixture won't make your test function
a coroutine. You'll need to interact with the event loop directly, using methods
like ``event_loop.run_until_complete``. See the ``pytest.mark.asyncio`` marker
for treating test functions like coroutines.

Simply using this fixture will not set the generated event loop as the
default asyncio event loop, or change the asyncio event loop policy in any way.
Use ``pytest.mark.asyncio`` for this purpose.

.. code-block:: python

 def test_http_client(event_loop):
     url = "http://httpbin.org/get"
     resp = event_loop.run_until_complete(http_client(url))
     assert b"HTTP/1.1 200 OK" in resp

This fixture can be easily overridden in any of the standard pytest locations
(e.g. directly in the test file, or in ``conftest.py``) to use a non-default
event loop. This will take effect even if you're using the
``pytest.mark.asyncio`` marker and not the ``event_loop`` fixture directly.

.. code-block:: python

 pytest.fixture
 def event_loop():
     loop = MyCustomLoop()
     yield loop
     loop.close()

If the ``pytest.mark.asyncio`` marker is applied, a pytest hook will
ensure the produced loop is set as the default global loop.
Fixtures depending on the ``event_loop`` fixture can expect the policy to be properly modified when they run.

``unused_tcp_port``
~~~~~~~~~~~~~~~~~~~
Finds and yields a single unused TCP port on the localhost interface. Useful for
binding temporary test servers.

``unused_tcp_port_factory``
~~~~~~~~~~~~~~~~~~~~~~~~~~~
A callable which returns a different unused TCP port each invocation. Useful
when several unused TCP ports are required in a test.

.. code-block:: python

 def a_test(unused_tcp_port_factory):
     port1, port2 = unused_tcp_port_factory(), unused_tcp_port_factory()
     ...

``unused_udp_port`` and ``unused_udp_port_factory``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work just like their TCP counterparts but return unused UDP ports.


Async fixtures
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Asynchronous fixtures are defined just like ordinary pytest fixtures, except they should be decorated with ``pytest_asyncio.fixture``.

.. code-block:: python3

 import pytest_asyncio


 pytest_asyncio.fixture
 async def async_gen_fixture():
     await asyncio.sleep(0.1)
     yield "a value"


 pytest_asyncio.fixture(scope="module")
 async def async_fixture():
     return await asyncio.sleep(0.1)

All scopes are supported, but if you use a non-function scope you will need
to redefine the ``event_loop`` fixture to have the same or broader scope.
Async fixtures need the event loop, and so must have the same or narrower scope
than the ``event_loop`` fixture.

*auto* and *legacy* mode automatically converts async fixtures declared with the
standard ``pytest.fixture`` decorator to *asyncio-driven* versions.


Markers
-------

``pytest.mark.asyncio``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark your test coroutine with this marker and pytest will execute it as an
asyncio task using the event loop provided by the ``event_loop`` fixture. See
the introductory section for an example.

The event loop used can be overridden by overriding the ``event_loop`` fixture
(see above).

In order to make your test code a little more concise, the pytest |pytestmark|_
feature can be used to mark entire modules or classes with this marker.
Only test coroutines will be affected (by default, coroutines prefixed by
``test_``), so, for example, fixtures are safe to define.

.. code-block:: python

 import asyncio

 import pytest

  All test coroutines will be treated as marked.
 pytestmark = pytest.mark.asyncio


 async def test_example(event_loop):
     """No marker!"""
     await asyncio.sleep(0, loop=event_loop)

In *auto* mode, the ``pytest.mark.asyncio`` marker can be omitted, the marker is added
automatically to *async* test functions.


.. |pytestmark| replace:: ``pytestmark``
.. _pytestmark: http://doc.pytest.org/en/latest/example/markers.html#marking-whole-classes-or-modules

Note about unittest
-------------------

Test classes subclassing the standard `unittest <https://docs.python.org/3/library/unittest.html>`__ library are not supported, users
are recommended to use `unitest.IsolatedAsyncioTestCase <https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase>`__
or an async framework such as `asynctest <https://asynctest.readthedocs.io/en/latest>`__.

Changelog
---------

0.17.0a3

pytest-asyncio: pytest support for asyncio
==========================================

.. image:: https://img.shields.io/pypi/v/pytest-asyncio.svg
 :target: https://pypi.python.org/pypi/pytest-asyncio
.. image:: https://github.com/pytest-dev/pytest-asyncio/workflows/CI/badge.svg
 :target: https://github.com/pytest-dev/pytest-asyncio/actions?workflow=CI
.. image:: https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/master/graph/badge.svg
 :target: https://codecov.io/gh/pytest-dev/pytest-asyncio
.. image:: https://img.shields.io/pypi/pyversions/pytest-asyncio.svg
 :target: https://github.com/pytest-dev/pytest-asyncio
 :alt: Supported Python versions
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
 :target: https://github.com/ambv/black

pytest-asyncio is an Apache2 licensed library, written in Python, for testing
asyncio code with pytest.

asyncio code is usually written in the form of coroutines, which makes it
slightly more difficult to test using normal testing tools. pytest-asyncio
provides useful fixtures and markers to make testing easier.

.. code-block:: python

 pytest.mark.asyncio
 async def test_some_asyncio_code():
     res = await library.do_something()
     assert b"expected result" == res

pytest-asyncio has been strongly influenced by pytest-tornado_.

.. _pytest-tornado: https://github.com/eugeniy/pytest-tornado

Features
--------

- fixtures for creating and injecting versions of the asyncio event loop
- fixtures for injecting unused tcp/udp ports
- pytest markers for treating tests as asyncio coroutines
- easy testing with non-default event loops
- support for `async def` fixtures and async generator fixtures
- support *auto* mode to handle all async fixtures and tests automatically by asyncio;
provide *strict* mode if a test suite should work with different async frameworks
simultaneously, e.g. ``asyncio`` and ``trio``.

Installation
------------

To install pytest-asyncio, simply:

.. code-block:: bash

 $ pip install pytest-asyncio

This is enough for pytest to pick up pytest-asyncio.

Modes
-----

Starting from ``pytest-asyncio>=0.17``, three modes are provided: *auto*, *strict* and
*legacy* (default).

The mode can be set by ``asyncio_mode`` configuration option in `configuration file
<https://docs.pytest.org/en/latest/reference/customize.html>`_:

.. code-block:: ini

 pytest.ini
[pytest]
asyncio_mode = auto

The value can be overriden by command-line option for ``pytest`` invocation:

.. code-block:: bash

$ pytest tests --asyncio-mode=strict

Auto mode
~~~~~~~~~

When the mode is auto, all discovered *async* tests are considered *asyncio-driven* even
if they have no ``pytest.mark.asyncio`` marker.

All async fixtures are considered *asyncio-driven* as well, even if they are decorated
with a regular ``pytest.fixture`` decorator instead of dedicated
``pytest_asyncio.fixture`` counterpart.

*asyncio-driven* means that tests and fixtures are executed by ``pytest-asyncio``
plugin.

This mode requires the simplest tests and fixtures configuration and is
recommended for default usage *unless* the same project and its test suite should
execute tests from different async frameworks, e.g. ``asyncio`` and ``trio``.  In this
case, auto-handling can break tests designed for other framework; plase use *strict*
mode instead.

Strict mode
~~~~~~~~~~~

Strict mode enforces ``pytest.mark.asyncio`` and ``pytest_asyncio.fixture`` usage.
Without these markers, tests and fixtures are not considered as *asyncio-driven*, other
pytest plugin can handle them.

Please use this mode if multiple async frameworks should be combined in the same test
suite.


Legacy mode
~~~~~~~~~~~

This mode follows rules used by ``pytest-asyncio<0.17``: tests are not auto-marked but
fixtures are.

This mode is used by default for the sake of backward compatibility, deprecation
warnings are emitted with suggestion to either switching to ``auto`` mode or using
``strict`` mode with ``pytest_asyncio.fixture`` decorators.

In future, the default will be changed.


Fixtures
--------

``event_loop``
~~~~~~~~~~~~~~
Creates and injects a new instance of the default asyncio event loop. By
default, the loop will be closed at the end of the test (i.e. the default
fixture scope is ``function``).

Note that just using the ``event_loop`` fixture won't make your test function
a coroutine. You'll need to interact with the event loop directly, using methods
like ``event_loop.run_until_complete``. See the ``pytest.mark.asyncio`` marker
for treating test functions like coroutines.

Simply using this fixture will not set the generated event loop as the
default asyncio event loop, or change the asyncio event loop policy in any way.
Use ``pytest.mark.asyncio`` for this purpose.

.. code-block:: python

 def test_http_client(event_loop):
     url = "http://httpbin.org/get"
     resp = event_loop.run_until_complete(http_client(url))
     assert b"HTTP/1.1 200 OK" in resp

This fixture can be easily overridden in any of the standard pytest locations
(e.g. directly in the test file, or in ``conftest.py``) to use a non-default
event loop. This will take effect even if you're using the
``pytest.mark.asyncio`` marker and not the ``event_loop`` fixture directly.

.. code-block:: python

 pytest.fixture
 def event_loop():
     loop = MyCustomLoop()
     yield loop
     loop.close()

If the ``pytest.mark.asyncio`` marker is applied, a pytest hook will
ensure the produced loop is set as the default global loop.
Fixtures depending on the ``event_loop`` fixture can expect the policy to be properly modified when they run.

``unused_tcp_port``
~~~~~~~~~~~~~~~~~~~
Finds and yields a single unused TCP port on the localhost interface. Useful for
binding temporary test servers.

``unused_tcp_port_factory``
~~~~~~~~~~~~~~~~~~~~~~~~~~~
A callable which returns a different unused TCP port each invocation. Useful
when several unused TCP ports are required in a test.

.. code-block:: python

 def a_test(unused_tcp_port_factory):
     port1, port2 = unused_tcp_port_factory(), unused_tcp_port_factory()
     ...

``unused_udp_port`` and ``unused_udp_port_factory``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work just like their TCP counterparts but return unused UDP ports.


Async fixtures
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Asynchronous fixtures are defined just like ordinary pytest fixtures, except they should be decorated with ``pytest_asyncio.fixture``.

.. code-block:: python3

 import pytest_asyncio


 pytest_asyncio.fixture
 async def async_gen_fixture():
     await asyncio.sleep(0.1)
     yield "a value"


 pytest_asyncio.fixture(scope="module")
 async def async_fixture():
     return await asyncio.sleep(0.1)

All scopes are supported, but if you use a non-function scope you will need
to redefine the ``event_loop`` fixture to have the same or broader scope.
Async fixtures need the event loop, and so must have the same or narrower scope
than the ``event_loop`` fixture.

*auto* and *legacy* mode automatically converts async fixtures declared with the
standard ``pytest.fixture`` decorator to *asyncio-driven* versions.


Markers
-------

``pytest.mark.asyncio``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark your test coroutine with this marker and pytest will execute it as an
asyncio task using the event loop provided by the ``event_loop`` fixture. See
the introductory section for an example.

The event loop used can be overridden by overriding the ``event_loop`` fixture
(see above).

In order to make your test code a little more concise, the pytest |pytestmark|_
feature can be used to mark entire modules or classes with this marker.
Only test coroutines will be affected (by default, coroutines prefixed by
``test_``), so, for example, fixtures are safe to define.

.. code-block:: python

 import asyncio

 import pytest

  All test coroutines will be treated as marked.
 pytestmark = pytest.mark.asyncio


 async def test_example(event_loop):
     """No marker!"""
     await asyncio.sleep(0, loop=event_loop)

In *auto* mode, the ``pytest.mark.asyncio`` marker can be omitted, the marker is added
automatically to *async* test functions.


.. |pytestmark| replace:: ``pytestmark``
.. _pytestmark: http://doc.pytest.org/en/latest/example/markers.html#marking-whole-classes-or-modules

Note about unittest
-------------------

Test classes subclassing the standard `unittest <https://docs.python.org/3/library/unittest.html>`__ library are not supported, users
are recommended to use `unitest.IsolatedAsyncioTestCase <https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase>`__
or an async framework such as `asynctest <https://asynctest.readthedocs.io/en/latest>`__.

Changelog
---------
Links

Update sphinx from 4.3.2 to 4.4.0.

Changelog

4.4.0

=====================================

Dependencies
------------

* 10007: Use ``importlib_metadata`` for python-3.9 or older
* 10007: Drop ``setuptools``

Features added
--------------

* 9075: autodoc: Add a config variable :confval:`autodoc_typehints_format`
to suppress the leading module names of typehints of function signatures (ex.
``io.StringIO`` -> ``StringIO``)
* 9831: Autosummary now documents only the members specified in a module's
``__all__`` attribute if :confval:`autosummary_ignore_module_all` is set to
``False``. The default behaviour is unchanged. Autogen also now supports
this behavior with the ``--respect-module-all`` switch.
* 9555: autosummary: Improve error messages on failure to load target object
* 9800: extlinks: Emit warning if a hardcoded link is replaceable
by an extlink, suggesting a replacement.
* 9961: html: Support nested <kbd> HTML elements in other HTML builders
* 10013: html: Allow to change the loading method of JS via ``loading_method``
parameter for :meth:`Sphinx.add_js_file()`
* 9551: html search: "Hide Search Matches" link removes "highlight" parameter
from URL
* 9815: html theme: Wrap sidebar components in div to allow customizing their
layout via CSS
* 9827: i18n: Sort items in glossary by translated terms
* 9899: py domain: Allows to specify cross-reference specifier (``.`` and
``~``) as ``:type:`` option
* 9894: linkcheck: add option ``linkcheck_exclude_documents`` to disable link
checking in matched documents.
* 9793: sphinx-build: Allow to use the parallel build feature in macOS on macOS
and Python3.8+
* 10055: sphinx-build: Create directories when ``-w`` option given
* 9993: std domain: Allow to refer an inline target (ex. ``_`target name)
via :rst:role:`ref` role
* 9981: std domain: Strip value part of the option directive from general index
* 9391: texinfo: improve variable in ``samp`` role
* 9578: texinfo: Add :confval:`texinfo_cross_references` to disable cross
references for readability with standalone readers
* 9822 (and 9062), add new Intersphinx role :rst:role:`external` for explict
lookup in the external projects, without resolving to the local project.

Bugs fixed
----------

* 9866: autodoc: doccomment for the imported class was ignored
* 9883: autodoc: doccomment for the alias to mocked object was ignored
* 9908: autodoc: debug message is shown on building document using NewTypes
with Python 3.10
* 9968: autodoc: instance variables are not shown if __init__ method has
position-only-arguments
* 9194: autodoc: types under the "typing" module are not hyperlinked
* 10009: autodoc: Crashes if target object raises an error on getting docstring
* 10058: autosummary: Imported members are not shown when
``autodoc_class_signature = 'separated'``
* 9947: i18n: topic directive having a bullet list can't be translatable
* 9878: mathjax: MathJax configuration is placed after loading MathJax itself
* 9932: napoleon: empty "returns" section is generated even if no description
* 9857: Generated RFC links use outdated base url
* 9909: HTML, prevent line-wrapping in literal text.
* 10061: html theme: Configuration values added by themes are not be able to
override from conf.py
* 10073: imgconverter: Unnecessary availablity check is called for "data" URIs
* 9925: LaTeX: prohibit also with ``'xelatex'`` line splitting at dashes of
inline and parsed literals
* 9944: LaTeX: extra vertical whitespace for some nested declarations
* 9940: LaTeX: Multi-function declaration in Python domain has cramped
vertical spacing in latexpdf output
* 10015: py domain: types under the "typing" module are not hyperlinked defined
at info-field-list
* 9390: texinfo: Do not emit labels inside footnotes
* 9413: xml: Invalid XML was generated when cross referencing python objects
* 9979: Error level messages were displayed as warning messages
* 10057: Failed to scan documents if the project is placed onto the root
directory
* 9636: code-block: ``:dedent:`` without argument did strip newlines
Links

Update sphinx-autodoc-typehints from 1.15.1 to 1.15.2.

Changelog

1.15.2

- Log a warning instead of crashing when a type guard import fails to resolve
- When resolving type guard imports if the target module does not have source code (such is the case for C-extension modules) do nothing instead of crashing
Links

Update streamlit from 1.3.1 to 1.4.0.

Changelog

1.4.0

**Highlights**

- 馃摳聽Introducing `st.camera_input` for uploading images straight from your camera.

**Notable Changes**

- 馃殾聽Widgets now have the `disabled` parameter that removes interactivity.
- 馃毊聽Clear `st.experimental_memo` and `st.experimental_singleton` programmatically by using the `clear()` method on a cached function.
- 馃摠聽Developers can now configure the maximum size of a message to accommodate larger messages within the Streamlit application. See `server.maxMessageSize`.
- 馃悕聽We formally added support for Python 3.10.

**Other Changes**

- 馃樀鈥嶐煉燙alling `str` or `repr` on `threading.current_thread()` does not cause a RecursionError ([4172](https://github.com/streamlit/streamlit/issues/4172)).
- 馃摴聽Gracefully stop screencast recording when user removes permission to record ([4180](https://github.com/streamlit/streamlit/pull/4180)).
- 馃寚聽Better scale images by using a higher-quality image bilinear resampling algorithm ([4159](https://github.com/streamlit/streamlit/pull/4159)).
Links

Update nbqa from 1.2.2 to 1.2.3.

Changelog

1.2.3

~~~~~~~~~~~~~~~~~~
Removed (unnecessary) upper-bound on ``tomli``.
Links

Update hypothesis from 6.35.0 to 6.35.1.

Changelog

6.35.1

-------------------

This patch fixes ``hypothesis write`` output highlighting with :pypi:`rich`
version 12.0 and later.
Links

Update opentelemetry-exporter-gcp-trace from 1.0.0 to 1.1.0.

The bot wasn't able to find a changelog for this release. Got an idea?

Links

Update types-requests from 2.27.5 to 2.27.7.

The bot wasn't able to find a changelog for this release. Got an idea?

Links

Update pandas_market_calendars from 3.2 to 3.2.

Changelog

3.2

~~~~~~~~~~~~~~
- Major refactoring of the underlying code from `PR 150 <https://github.com/rsheftel/pandas_market_calendars/pull/150>`_
thanks to https://github.com/Stryder-Git
- Fixed 12/24/1999 early close on NYSE

3.1

~~~~~~~~~~~~~~
- Added September 11 holidays to TSX calendar
- Made the minimum version for exchange_calendars >= 3.3 to resolve problem with newer versions of pandas

3.0

~~~~~~~~~~~~~
- Major update to the date_range() functionality. This new behavior is more complete and consistent, but changes
behavior in some cases, so a new major version is warranted. For more discussion on the topic refer to
`PR 142 <https://github.com/rsheftel/pandas_market_calendars/pull/142>`_ and
`Issue 138 <https://github.com/rsheftel/pandas_market_calendars/issues/138>`_

2.1

~~~~~~~~~~~~~
- Updated to work with pandas 1.3
- Raise minimum python to 3.7
- NYSE calendar valid from 1885 to present. Includes all full day closes, early closes, and late opens. PR 141

2.0.1

~~~~~~~~~~~~~~~
- Fixed the TSE calendar for Christmas falling on a Saturday

2.0

~~~~~~~~~~~~
This version replaces the trading_calendars integration with exchange_calendars, closing out 120. `exchange_calendars <https://github.com/gerrymanoim/exchange_calendars>`_
if the fork of trading_calendars that is currently actively maintained. trading_calendars is now abandoned because
it's corporate sponsor is out of business and gone.

1.7

~~~~~~~~~~~~
This version eliminated the generic CMEExchangeCalendar. This calendar did not represent a specific market and thus
was not appropriate for any use. With the addition of the specific calendars for product types this is no longer
needed and is removed. To see the product specific calendars here: https://pandas-market-calendars.readthedocs.io/en/latest/calendars.html#futures-calendars

For the CMEEquityExchangeCalendar, this no longer is a mirror of the NYSE calendar as some of the holidays for the NYSE
are an open day with early close for CME. This calendar now has its own set of holiday assumptions. This may cause
some holidays missing until this calendar is fully tested and vetted.

1.6.2

~~~~~~~~~~~~~~
- Fix UK Holidays for 130
- Fix CME Bond calendar for Good Friday 132

1.6.1

~~~~~~~~~~~~~~~
- Add trading breaks to the trading_calendars import mirror
- Fix the CFE calendar for Good Friday 116
- Renamed XBOM to BSE to avoid conflict with trading_calendars

1.6

~~~~~~~~~~~~~
This is the first version of the merge of this project with the quantopian trading-calendars.

- Added the trading_calendars.py module that brings in all current and future calendars from the quantopian project
- All calendars from trading-calendars are now available in pandas_market_calendars

1.5

~~~~~~~~~~~~~
- Add the is_open_now() function
- Add TASE calendar from 114
- Holiday calendar is now cached to improve performance 117

1.4.2

~~~~~~~~~~~~~~~
- Fixed for changes to pandas 1.1.0

1.4.1

~~~~~~~~~~~~~~~
- Added CME_Bond calendar for bond and interest rate futures
- Added futures specific items to the documentations along with examples with breaks

1.4

~~~~~~~~~~~~~
- Add the concept of a break during the trading day. For example this can accommodate Asian markets that have a lunch
break, or futures markets that are open 24 hours with a break in the day for trade processing.
- Added product specific contract calendars for CME futures exchange. First calendars are the CME Agricultural and
CME Equity calendars
- Add ability to set time zone on schedule() function 42
- Add the Bombay exchange (XBOM) from 96
- Fixed Christmas holidays in SIX 100

1.3

~~~~~~~~~~~~~
- Fixes to support Pandas v1.0
- Remove support for Python 3.4 based on underlying packages removing support for v3.4
- Added ASXExchangeCalendar from PR 85
- Fixes to UK holidays in 84

1.2

~~~~~~~~~~~~~~
- Support calendars with valid business days on the weekend (PR 75)
- Fixed SSE 2019 labour's day holidays (PR 74)
- Better JPX calendar support for the time period 1949-2099 (PR 72)
- Reformat Japan's Ascension days, removed duplicate days (PR 68)
- Added German national holidays (PR 77)

1.1

~~~~~~~~~~~~
- add JPX Ascension Day holidays for 2019 from PR 64

1.0

~~~~~~~~~~~~~
- Official move to Python3 only support
- Version moved to 1.0 as the package has been around and stable long enough to warrant a 1.0

0.22

~~~~~~~~~~~~~~
- Added Shanghai Stock Exchange (SSE) calendar from PR 58
- Added HKEX calendar from PR 61
- Fixed tests for pandas v0.24 and higher

0.21

~~~~~~~~~~~~~~
- Added Oslo Stock Exchange (OSE) calendar
- Added GW Bush Holiday to NYSE calendar from PR 53 and 54

0.20

~~~~~~~~~~~~~~
- Improvements in the internals for how calendars are registered and aliased thanks for PR 45

0.19

~~~~~~~~~~~~~~
- schedule() method no longer raises exception if there are no valid trading days between start_date and end_date,
will now return an empty DataFrame

0.18

~~~~~~~~~~~~~~
- Changed NYSE holiday calendar to start 1/1/1900 (was previously 1/1/1970).
- Fixed an error that schedule() method would fail if the end date was prior to 1993

0.17

~~~~~~~~~~~~~~
- Added SIX (Swiss Exchange) calendar, Pull Request 36

0.16

~~~~~~~~~~~~~~
- Fixed the equinox for Japanese calendar, Pull Request 33
- Fixed Victoria Day for TSX, issue 34

0.15

~~~~~~~~~~~~~~
- Removed toolz as a required package and removed from the one test that required it
- Added daily closes on NYSE back to 1928 from PR 30 thanks to pldrouin

0.14

~~~~~~~~~~~~~
- Made default open and close times time-zone aware

0.13

~~~~~~~~~~~~~
- Corrected JPX calendar for issue 22

0.12

~~~~~~~~~~~~~~~
- Added new JPX calendar thanks to gabalese from PR 21

0.11

~~~~~~~~~~~~~~~
- Corrected the NYSE calendar for Independence Day on Thursday post 2013 to fix 20
- Added new convert_freq() function to convert a date_range to a lower frequency to fix 19

0.10

~~~~~~~~~~~~~~
- Added open_time_default and close_time_default as abstract property methods to fix 17

0.9

~~~~~~~~~~~~~
- Fix 12 to Eurex calendar

0.8

~~~~~~~~~~~~~
- Fix 10 to make merge_schedules work properly for more than 2 markets

0.7

~~~~~~~~~~~~~
- Fix a couple deprecated imports

0.6

~~~~~~~~~~~~~
- Added coveralls.io test coverage

0.5

~~~~~~~~~~~~~
- Added Python2.7 support

0.4

~~~
- Fixed bug 5

0.3

~~~
- Added Eurex calendar

0.2

~~~
- Fix to allow start_date and end_date to be the same in schedule()

0.1

~~~
- Initial version
Links

Update psutil from 5.8.0 to 5.9.0.

Changelog

5.9.0

=====

2021-12-29

**Enhancements**

- 1851_, [Linux]: `cpu_freq()`_ is slow on systems with many CPUs. Read current
frequency values for all CPUs from ``/proc/cpuinfo`` instead of opening many
files in ``/sys`` fs.  (patch by marxin)
- 1992_: `NoSuchProcess`_ message now specifies if the PID has been reused.
- 1992_: error classes (`NoSuchProcess`_, `AccessDenied`_, etc.) now have a better
formatted and separated ``__repr__`` and ``__str__`` implementations.
- 1996_, [BSD]: add support for MidnightBSD.  (patch by Saeed Rasooli)
- 1999_, [Linux]: `disk_partitions()`_: convert ``/dev/root`` device (an alias
used on some Linux distros) to real root device path.
- 2005_: ``PSUTIL_DEBUG`` mode now prints file name and line number of the debug
messages coming from C extension modules.
- 2042_: rewrite HISTORY.rst to use hyperlinks pointing to psutil API doc.

**Bug fixes**

- 1456_, [macOS], **[critical]**: `cpu_freq()`_ ``min`` and ``max`` are set to
0 if can't be determined (instead of crashing).
- 1512_, [macOS]: sometimes `Process.connections()`_ will crash with
``EOPNOTSUPP`` for one connection; this is now ignored.
- 1598_, [Windows]: `disk_partitions()`_ only returns mountpoints on drives
where it first finds one.
- 1874_, [SunOS]: swap output error due to incorrect range.
- 1892_, [macOS]: `cpu_freq()`_ broken on Apple M1.
- 1901_, [macOS]: different functions, especially `Process.open_files()`_ and
`Process.connections()`_, could randomly raise `AccessDenied`_ because the
internal buffer of ``proc_pidinfo(PROC_PIDLISTFDS)`` syscall was not big enough.
We now dynamically increase the buffer size until it's big enough instead of
giving up and raising `AccessDenied`_, which was a fallback to avoid crashing.
- 1904_, [Windows]: ``OpenProcess`` fails with ``ERROR_SUCCESS`` due to
``GetLastError()`` called after ``sprintf()``.  (patch by alxchk)
- 1913_, [Linux]: `wait_procs()`_ should catch ``subprocess.TimeoutExpired``
exception.
- 1919_, [Linux]: `sensors_battery()`_ can raise ``TypeError`` on PureOS.
- 1921_, [Windows]: `swap_memory()`_ shows committed memory instead of swap.
- 1940_, [Linux]: psutil does not handle ``ENAMETOOLONG`` when accessing process
file descriptors in procfs.  (patch by Nikita Radchenko)
- 1948_, **[critical]**: ``memoize_when_activated`` decorator is not thread-safe.
(patch by Xuehai Pan)
- 1953_, [Windows], **[critical]**: `disk_partitions()`_ crashes due to
insufficient buffer len. (patch by MaWe2019)
- 1965_, [Windows], **[critical]**: fix "Fatal Python error: deallocating None"
when calling `users()`_ multiple times.
- 1980_, [Windows]: 32bit / WoW64 processes fails to read `Process.name()`_ longer
than 128 characters resulting in `AccessDenied`_. This is now fixed.  (patch
by PetrPospisil)
- 1991_, **[critical]**: `process_iter()`_ is not thread safe and can raise
``TypeError`` if invoked from multiple threads.
- 1956_, [macOS]: `Process.cpu_times()`_ reports incorrect timings on M1 machines.
(patch by Olivier Dormond)
- 2023_, [Linux]: `cpu_freq()`_ return order is wrong on systems with more than
9 CPUs.
Links

@amor71 amor71 merged commit 80191b5 into master Jan 17, 2022
@amor71 amor71 deleted the pyup/scheduled-update-2022-01-17 branch January 17, 2022 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants