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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not load notebook elements when no notebook is running #278

Closed
wants to merge 2 commits into from

Conversation

peendebak
Copy link
Contributor

When the user is not running a jupyter notebook as a frontend then the graphical elements based on the notebook should not be loaded.

It is not possible to detemine from python itself whether the user is running a notebook (or just an ipython terminal), so the function frontend uses an enviroment variable to overrule the default setting. The default setting is still notebook.

Changes proposed in this pull request:

  • Add frontend() function
  • Do not load HiddenUpdateWidget when the frontend is not notebook

@giulioungaretti @alexcjohnson

@peendebak peendebak added this to the v0.1 colossal cleanup milestone Jul 22, 2016
Returns
frontend (string): frontend used. Default is notebook
"""
return os.environ.get('QCODESFRONTEND', 'notebook')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we really use environment variables for this?
I'd prefer config files so much more, @giulioungaretti @alexcjohnson

@giulioungaretti
Copy link
Contributor

@peendebak I really like this but that's because we are unix-y.
@MerlinSmiles I feel your preference coming from a windows based perspective.

So bottom line, I don't know what to chose for now :D

@MerlinSmiles
Copy link
Contributor

@giulioungaretti Maybe, but how do you run two versions of this, one in the notebook and one in a pure version?

To me environment variables are not organized at all, also not on osx, and this frontend, which is a nice addition, is not the only config thing we want.
Do we really want 500 environment variables to configure qcodes?

@eendebakpt
Copy link
Contributor

@MerlinSmiles You can run multiple versions by changing the environment variables ;-). Config files is also fine with me, but then how should one specify which config file will be used?

We also want to run multiple versions (for our different users)

@MerlinSmiles
Copy link
Contributor

@peendebak sure you can..., but is it convinient or standard procedure?
Do any other python packages use environment variables to configure the packages?

In my dream scenario, there would be qcodes.config files:

  1. in the package directory
  2. in the user directory
  3. in the working directory
    with the lowest priority for the first file, then all that config stuff could go in the first one, the stuff that should change for a system goes into the user directory, and finally the things for one specific experiment would go into the working directory.
    Also changing those config things like one can do in many packages like the matplotlib-rc-config stuff would be great.

There are so many hard-coded defaults in qcodes, i.e. plotting, data-location, that in my opinion are very user specific and it would be great to have them in config files.

Obviously this is just my very personal preference

@giulioungaretti
Copy link
Contributor

Where a configuration file setting exists with the same meaning as an environment variable, and both are present at application startup time, the environment variable setting takes precedence.

@giulioungaretti
Copy link
Contributor

that's the "golden rule". But note that env variables are way more dynamic and defined per shell (ok maybe not in windows).

So my proposal is to have both:
and actually I really like the idea of having conf files.

BUT none of this should ever be a concern of the casual user.

And we will add a tiny GUI to see and set these values.

@giulioungaretti
Copy link
Contributor

And it's quite a big feature. Not sure doable in v0.1

@MerlinSmiles
Copy link
Contributor

Ok, where can I read about that golden rule?

Yes you're right, probably not v0.1, but thought this should be discussed before adding 'hacks', well not sure if this is a hack or not.
But it would be great if one could do frontend = qcodes.config.frontend

@eendebakpt sorry for spamming in your PR, i totally like the idea!

@giulioungaretti
Copy link
Contributor

giulioungaretti commented Jul 22, 2016

How about:

Read config from:

  1. default.config: in the package directory ( those are the default safest setting, most likely something the user should never change as they will be under GIT)
  2. user.config: user dir ( those are settings that are personal to user, like operating system things, base paths and so on, not under qcodes control). If user.config changes a value of default.config the first takes precedence
  3. experiment.config: sits in the working directory (those are settings that one wants to change per experiment) If experiment.config changes a value of user.config the first takes precedence
  4. env_variables: for unix people If env_variables changes a value of experiment.config the first takes precedence

@MerlinSmiles
Copy link
Contributor

MerlinSmiles commented Jul 22, 2016

maybe add a qcodes_ prefix to all the files, just to be super-clear.
or have <anything>.qcodes-config and then order by filename in one folder, that would allow to have:

plotting1.qcodes-config
plotting2.qcodes-config
file_format.qcodes-config

and it makes sharing easy :D

@MerlinSmiles
Copy link
Contributor

Maybe we just copy this
http://pandas.pydata.org/pandas-docs/stable/options.html

@eendebakpt
Copy link
Contributor

Making a full config system is maybe too much for v0.1, but I consider this PR important because I want non-notebook users to be able to use qcodes. What about this:

  1. We make a module qcodes.config
  2. For v0.1 we use a quick hack (e.g. what we have now) to set qcodes.config.frontend.
  3. In time we change the backend of qcodes.config to whatever we want

@MerlinSmiles
Copy link
Contributor

@eendebakpt yes, I think that would be a good solution, maybe we want to follow the pandas thing, and call it options then too.

@alexcjohnson
Copy link
Contributor

What we talked about a while ago for this was making all front-end-dependent features explicitly opt-in within python, so then the casual user would just do something like

Import qcodes as qc
qc.config(frontend='notebook')

Then of course we could load these from files or environment variables, but the key is by default all frontend features are off with no config, so you can turn on what you want within your Python session.

@giulioungaretti
Copy link
Contributor

Not sure about having a function do do that.
I think we need to settle for a default that just works for most users, instead of having no gui at all.

@alexcjohnson
Copy link
Contributor

Everyone already has to include qc.show_subprocess_widget(), and all the other first-cell stuff to set up their system so doesn't seem too onerous to me. This could even obviate the show widget command.

@qcodes-bot
Copy link

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 1

See the complete overview on Codacy

""" Return frontend used

Returns
frontend (string): frontend used. Default is notebook

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Trailing whitespace

@qcodes-bot
Copy link

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 1

See the complete overview on Codacy

""" Return frontend used

Returns
frontend (string): frontend used. Default is notebook

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Trailing whitespace

@giulioungaretti
Copy link
Contributor

@MerlinSmiles @eendebakpt this is superseed by the new config options.

@giulioungaretti giulioungaretti deleted the nonotebook branch October 31, 2016 14:32
bors bot added a commit that referenced this pull request Oct 24, 2022
4754: Update pytest-asyncio requirement from ~=0.19.0 to ~=0.20.1 r=jenshnielsen a=dependabot[bot]

Updates the requirements on [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) to permit the latest version.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-asyncio/releases">pytest-asyncio's releases</a>.</em></p>
<blockquote>
<h2>pytest-asyncio 0.20.1</h2>
<hr />
<h2>title: 'pytest-asyncio: pytest support for asyncio'</h2>
<p><a href="https://pypi.python.org/pypi/pytest-asyncio"><img src="https://img.shields.io/pypi/v/pytest-asyncio.svg" alt="image" /></a></p>
<p><a href="https://github.com/pytest-dev/pytest-asyncio/actions?workflow=CI"><img src="https://github.com/pytest-dev/pytest-asyncio/workflows/CI/badge.svg" alt="image" /></a></p>
<p><a href="https://codecov.io/gh/pytest-dev/pytest-asyncio"><img src="https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/master/graph/badge.svg" alt="image" /></a></p>
<p><a href="https://github.com/pytest-dev/pytest-asyncio"><img src="https://img.shields.io/pypi/pyversions/pytest-asyncio.svg" alt="Supported Python versions" /></a></p>
<p><a href="https://github.com/ambv/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="image" /></a></p>
<p>pytest-asyncio is an Apache2 licensed library, written in Python, for
testing asyncio code with pytest.</p>
<p>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.</p>
<pre lang="{.sourceCode" data-meta=".python}"><code>`@pytest.mark.asyncio`
async def test_some_asyncio_code():
    res = await library.do_something()
    assert b&quot;expected result&quot; == res
</code></pre>
<p>pytest-asyncio has been strongly influenced by
<a href="https://github.com/eugeniy/pytest-tornado">pytest-tornado</a>.</p>
<h1>Features</h1>
<ul>
<li>fixtures for creating and injecting versions of the asyncio event
loop</li>
<li>fixtures for injecting unused tcp/udp ports</li>
<li>pytest markers for treating tests as asyncio coroutines</li>
<li>easy testing with non-default event loops</li>
<li>support for [async def]{.title-ref} fixtures and async generator
fixtures</li>
<li>support <em>auto</em> mode to handle all async fixtures and tests
automatically by asyncio; provide <em>strict</em> mode if a test suite
should work with different async frameworks simultaneously, e.g.
<code>asyncio</code> and <code>trio</code>.</li>
</ul>
<h1>Installation</h1>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-asyncio/blob/master/CHANGELOG.rst">pytest-asyncio's changelog</a>.</em></p>
<blockquote>
<h1>0.20.1 (22-10-21)</h1>
<ul>
<li>Fixes an issue that warned about using an old version of pytest, even though the most recent version was installed. <code>[#430](pytest-dev/pytest-asyncio#430) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/430&gt;</code>_</li>
</ul>
<h1>0.20.0 (22-10-21)</h1>
<ul>
<li>BREAKING: Removed <em>legacy</em> mode. If you're upgrading from v0.19 and you haven't configured <code>asyncio_mode = legacy</code>, you can upgrade without taking any additional action. If you're upgrading from an earlier version or you have explicitly enabled <em>legacy</em> mode, you need to switch to <em>auto</em> or <em>strict</em> mode before upgrading to this version.</li>
<li>Deprecate use of pytest v6.</li>
<li>Fixed an issue which prevented fixture setup from being cached. <code>[#404](pytest-dev/pytest-asyncio#404) &lt;https://github.com/pytest-dev/pytest-asyncio/pull/404&gt;</code>_</li>
</ul>
<h1>0.19.0 (22-07-13)</h1>
<ul>
<li>BREAKING: The default <code>asyncio_mode</code> is now <em>strict</em>. <code>[#293](pytest-dev/pytest-asyncio#293) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/293&gt;</code>_</li>
<li>Removes <code>setup.py</code> since all relevant configuration is present <code>setup.cfg</code>. Users requiring an editable installation of pytest-asyncio need to use pip v21.1 or newer. <code>[#283](pytest-dev/pytest-asyncio#283) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/283&gt;</code>_</li>
<li>Declare support for Python 3.11.</li>
</ul>
<h1>0.18.3 (22-03-25)</h1>
<ul>
<li>Adds <code>pytest-trio &lt;https://pypi.org/project/pytest-trio/&gt;</code>_ to the test dependencies</li>
<li>Fixes a bug that caused pytest-asyncio to try to set up async pytest_trio fixtures in strict mode. <code>[#298](pytest-dev/pytest-asyncio#298) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/298&gt;</code>_</li>
</ul>
<h1>0.18.2 (22-03-03)</h1>
<ul>
<li>Fix asyncio auto mode not marking static methods. <code>[#295](pytest-dev/pytest-asyncio#295) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/295&gt;</code>_</li>
<li>Fix a compatibility issue with Hypothesis 6.39.0. <code>[#302](pytest-dev/pytest-asyncio#302) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/302&gt;</code>_</li>
</ul>
<h1>0.18.1 (22-02-10)</h1>
<ul>
<li>Fixes a regression that prevented async fixtures from working in synchronous tests. <code>[#286](pytest-dev/pytest-asyncio#286) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/286&gt;</code>_</li>
</ul>
<h1>0.18.0 (22-02-07)</h1>
<ul>
<li>Raise a warning if <a href="https://github.com/pytest"><code>`@​pytest</code></a>.mark.asyncio` is applied to non-async function. <code>[#275](pytest-dev/pytest-asyncio#275) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/275&gt;</code>_</li>
<li>Support parametrized <code>event_loop</code> fixture. <code>[#278](pytest-dev/pytest-asyncio#278) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/278&gt;</code>_</li>
</ul>
<h1>0.17.2 (22-01-17)</h1>
<ul>
<li>Require <code>typing-extensions</code> on Python<!-- raw HTML omitted -->`_</li>
<li>Fix a regression in tests collection introduced by 0.17.1, the plugin works fine with non-python tests again. <code>[#267](pytest-dev/pytest-asyncio#267) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/267&gt;</code>_</li>
</ul>
<h1>0.17.1 (22-01-16)</h1>
<ul>
<li>Fixes a bug that prevents async Hypothesis tests from working without explicit <code>asyncio</code> marker when <code>--asyncio-mode=auto</code> is set. <code>[#258](pytest-dev/pytest-asyncio#258) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/258&gt;</code>_</li>
<li>Fixed a bug that closes the default event loop if the loop doesn't exist <code>[#257](pytest-dev/pytest-asyncio#257) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/257&gt;</code>_</li>
<li>Added type annotations. <code>[#198](pytest-dev/pytest-asyncio#198) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/198&gt;</code>_</li>
<li>Show asyncio mode in pytest report headers. <code>[#266](pytest-dev/pytest-asyncio#266) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/266&gt;</code>_</li>
<li>Relax <code>asyncio_mode</code> type definition; it allows to support pytest 6.1+. <code>[#262](pytest-dev/pytest-asyncio#262) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/262&gt;</code>_</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/c8d017407d39dd81d6864fa9a58ba1240d54be9f"><code>c8d0174</code></a> fix: Do not warn about outdated pytest version when pytest&gt;=7 is installed. (...</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/6450ddbe974f5359d56317ba8bdda8b2ab48655a"><code>6450ddb</code></a> Prepare release of v0.20.0. (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/428">#428</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/150f29c107fbd76641de47e040d43840769ef92c"><code>150f29c</code></a> Build(deps): Bump hypothesis in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/427">#427</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/adc88090f341d9872e9e9b4d22a94cdadf60b3bc"><code>adc8809</code></a> Build(deps): Bump typing-extensions in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/425">#425</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/4abf9d1df228ed8b083721d7affa73e4a08d13c3"><code>4abf9d1</code></a> Build(deps): Bump zipp from 3.8.1 to 3.9.0 in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/424">#424</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/eb487bcb076f44dedcdb33e74972bf06c37027ee"><code>eb487bc</code></a> Build(deps): Bump hypothesis in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/423">#423</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/907c461f172e52159a595e2592176c7feac04a43"><code>907c461</code></a> Refactor pytest_pycollect_makeitems (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/421">#421</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/d45ab217c80117854b510edc6c9fdd457b6b07fc"><code>d45ab21</code></a> feat: Add deprecation warning for pytest &lt; 7. (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/420">#420</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/cab20f4d346e9e52e5ffc93854de3ec881e7d342"><code>cab20f4</code></a> Build(deps): Bump importlib-metadata in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/415">#415</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/d9f77567189c96536b39b43520f4b40895b34fb9"><code>d9f7756</code></a> Build(deps): Bump hypothesis in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/416">#416</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/pytest-dev/pytest-asyncio/compare/v0.19.0...v0.20.1">compare view</a></li>
</ul>
</details>
<br />


You can trigger a rebase of this PR by commenting ``@dependabot` rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- ``@dependabot` rebase` will rebase this PR
- ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it
- ``@dependabot` merge` will merge this PR after your CI passes on it
- ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it
- ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging
- ``@dependabot` reopen` will reopen this PR if it is closed
- ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

4755: Bump actions/upload-artifact from 3.1.0 to 3.1.1 r=jenshnielsen a=dependabot[bot]

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.0 to 3.1.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/actions/upload-artifact/releases">actions/upload-artifact's releases</a>.</em></p>
<blockquote>
<h2>v3.1.1</h2>
<ul>
<li>Update actions/core package to latest version to remove <code>set-output</code> deprecation warning <a href="https://github-redirect.dependabot.com/actions/upload-artifact/issues/351">#351</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/actions/upload-artifact/commit/83fd05a356d7e2593de66fc9913b3002723633cb"><code>83fd05a</code></a> Bump actions-core to v1.10.0 (<a href="https://github-redirect.dependabot.com/actions/upload-artifact/issues/356">#356</a>)</li>
<li>See full diff in <a href="https://github.com/actions/upload-artifact/compare/v3.1.0...v3.1.1">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/upload-artifact&package-manager=github_actions&previous-version=3.1.0&new-version=3.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

You can trigger a rebase of this PR by commenting ``@dependabot` rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- ``@dependabot` rebase` will rebase this PR
- ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it
- ``@dependabot` merge` will merge this PR after your CI passes on it
- ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it
- ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging
- ``@dependabot` reopen` will reopen this PR if it is closed
- ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
bors bot added a commit that referenced this pull request Oct 24, 2022
4754: Update pytest-asyncio requirement from ~=0.19.0 to ~=0.20.1 r=jenshnielsen a=dependabot[bot]

Updates the requirements on [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) to permit the latest version.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-asyncio/releases">pytest-asyncio's releases</a>.</em></p>
<blockquote>
<h2>pytest-asyncio 0.20.1</h2>
<hr />
<h2>title: 'pytest-asyncio: pytest support for asyncio'</h2>
<p><a href="https://pypi.python.org/pypi/pytest-asyncio"><img src="https://img.shields.io/pypi/v/pytest-asyncio.svg" alt="image" /></a></p>
<p><a href="https://github.com/pytest-dev/pytest-asyncio/actions?workflow=CI"><img src="https://github.com/pytest-dev/pytest-asyncio/workflows/CI/badge.svg" alt="image" /></a></p>
<p><a href="https://codecov.io/gh/pytest-dev/pytest-asyncio"><img src="https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/master/graph/badge.svg" alt="image" /></a></p>
<p><a href="https://github.com/pytest-dev/pytest-asyncio"><img src="https://img.shields.io/pypi/pyversions/pytest-asyncio.svg" alt="Supported Python versions" /></a></p>
<p><a href="https://github.com/ambv/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="image" /></a></p>
<p>pytest-asyncio is an Apache2 licensed library, written in Python, for
testing asyncio code with pytest.</p>
<p>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.</p>
<pre lang="{.sourceCode" data-meta=".python}"><code>`@pytest.mark.asyncio`
async def test_some_asyncio_code():
    res = await library.do_something()
    assert b&quot;expected result&quot; == res
</code></pre>
<p>pytest-asyncio has been strongly influenced by
<a href="https://github.com/eugeniy/pytest-tornado">pytest-tornado</a>.</p>
<h1>Features</h1>
<ul>
<li>fixtures for creating and injecting versions of the asyncio event
loop</li>
<li>fixtures for injecting unused tcp/udp ports</li>
<li>pytest markers for treating tests as asyncio coroutines</li>
<li>easy testing with non-default event loops</li>
<li>support for [async def]{.title-ref} fixtures and async generator
fixtures</li>
<li>support <em>auto</em> mode to handle all async fixtures and tests
automatically by asyncio; provide <em>strict</em> mode if a test suite
should work with different async frameworks simultaneously, e.g.
<code>asyncio</code> and <code>trio</code>.</li>
</ul>
<h1>Installation</h1>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-asyncio/blob/master/CHANGELOG.rst">pytest-asyncio's changelog</a>.</em></p>
<blockquote>
<h1>0.20.1 (22-10-21)</h1>
<ul>
<li>Fixes an issue that warned about using an old version of pytest, even though the most recent version was installed. <code>[#430](pytest-dev/pytest-asyncio#430) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/430&gt;</code>_</li>
</ul>
<h1>0.20.0 (22-10-21)</h1>
<ul>
<li>BREAKING: Removed <em>legacy</em> mode. If you're upgrading from v0.19 and you haven't configured <code>asyncio_mode = legacy</code>, you can upgrade without taking any additional action. If you're upgrading from an earlier version or you have explicitly enabled <em>legacy</em> mode, you need to switch to <em>auto</em> or <em>strict</em> mode before upgrading to this version.</li>
<li>Deprecate use of pytest v6.</li>
<li>Fixed an issue which prevented fixture setup from being cached. <code>[#404](pytest-dev/pytest-asyncio#404) &lt;https://github.com/pytest-dev/pytest-asyncio/pull/404&gt;</code>_</li>
</ul>
<h1>0.19.0 (22-07-13)</h1>
<ul>
<li>BREAKING: The default <code>asyncio_mode</code> is now <em>strict</em>. <code>[#293](pytest-dev/pytest-asyncio#293) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/293&gt;</code>_</li>
<li>Removes <code>setup.py</code> since all relevant configuration is present <code>setup.cfg</code>. Users requiring an editable installation of pytest-asyncio need to use pip v21.1 or newer. <code>[#283](pytest-dev/pytest-asyncio#283) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/283&gt;</code>_</li>
<li>Declare support for Python 3.11.</li>
</ul>
<h1>0.18.3 (22-03-25)</h1>
<ul>
<li>Adds <code>pytest-trio &lt;https://pypi.org/project/pytest-trio/&gt;</code>_ to the test dependencies</li>
<li>Fixes a bug that caused pytest-asyncio to try to set up async pytest_trio fixtures in strict mode. <code>[#298](pytest-dev/pytest-asyncio#298) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/298&gt;</code>_</li>
</ul>
<h1>0.18.2 (22-03-03)</h1>
<ul>
<li>Fix asyncio auto mode not marking static methods. <code>[#295](pytest-dev/pytest-asyncio#295) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/295&gt;</code>_</li>
<li>Fix a compatibility issue with Hypothesis 6.39.0. <code>[#302](pytest-dev/pytest-asyncio#302) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/302&gt;</code>_</li>
</ul>
<h1>0.18.1 (22-02-10)</h1>
<ul>
<li>Fixes a regression that prevented async fixtures from working in synchronous tests. <code>[#286](pytest-dev/pytest-asyncio#286) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/286&gt;</code>_</li>
</ul>
<h1>0.18.0 (22-02-07)</h1>
<ul>
<li>Raise a warning if <a href="https://github.com/pytest"><code>`@​pytest</code></a>.mark.asyncio` is applied to non-async function. <code>[#275](pytest-dev/pytest-asyncio#275) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/275&gt;</code>_</li>
<li>Support parametrized <code>event_loop</code> fixture. <code>[#278](pytest-dev/pytest-asyncio#278) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/278&gt;</code>_</li>
</ul>
<h1>0.17.2 (22-01-17)</h1>
<ul>
<li>Require <code>typing-extensions</code> on Python<!-- raw HTML omitted -->`_</li>
<li>Fix a regression in tests collection introduced by 0.17.1, the plugin works fine with non-python tests again. <code>[#267](pytest-dev/pytest-asyncio#267) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/267&gt;</code>_</li>
</ul>
<h1>0.17.1 (22-01-16)</h1>
<ul>
<li>Fixes a bug that prevents async Hypothesis tests from working without explicit <code>asyncio</code> marker when <code>--asyncio-mode=auto</code> is set. <code>[#258](pytest-dev/pytest-asyncio#258) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/258&gt;</code>_</li>
<li>Fixed a bug that closes the default event loop if the loop doesn't exist <code>[#257](pytest-dev/pytest-asyncio#257) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/257&gt;</code>_</li>
<li>Added type annotations. <code>[#198](pytest-dev/pytest-asyncio#198) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/198&gt;</code>_</li>
<li>Show asyncio mode in pytest report headers. <code>[#266](pytest-dev/pytest-asyncio#266) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/266&gt;</code>_</li>
<li>Relax <code>asyncio_mode</code> type definition; it allows to support pytest 6.1+. <code>[#262](pytest-dev/pytest-asyncio#262) &lt;https://github.com/pytest-dev/pytest-asyncio/issues/262&gt;</code>_</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/c8d017407d39dd81d6864fa9a58ba1240d54be9f"><code>c8d0174</code></a> fix: Do not warn about outdated pytest version when pytest&gt;=7 is installed. (...</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/6450ddbe974f5359d56317ba8bdda8b2ab48655a"><code>6450ddb</code></a> Prepare release of v0.20.0. (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/428">#428</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/150f29c107fbd76641de47e040d43840769ef92c"><code>150f29c</code></a> Build(deps): Bump hypothesis in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/427">#427</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/adc88090f341d9872e9e9b4d22a94cdadf60b3bc"><code>adc8809</code></a> Build(deps): Bump typing-extensions in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/425">#425</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/4abf9d1df228ed8b083721d7affa73e4a08d13c3"><code>4abf9d1</code></a> Build(deps): Bump zipp from 3.8.1 to 3.9.0 in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/424">#424</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/eb487bcb076f44dedcdb33e74972bf06c37027ee"><code>eb487bc</code></a> Build(deps): Bump hypothesis in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/423">#423</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/907c461f172e52159a595e2592176c7feac04a43"><code>907c461</code></a> Refactor pytest_pycollect_makeitems (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/421">#421</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/d45ab217c80117854b510edc6c9fdd457b6b07fc"><code>d45ab21</code></a> feat: Add deprecation warning for pytest &lt; 7. (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/420">#420</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/cab20f4d346e9e52e5ffc93854de3ec881e7d342"><code>cab20f4</code></a> Build(deps): Bump importlib-metadata in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/415">#415</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest-asyncio/commit/d9f77567189c96536b39b43520f4b40895b34fb9"><code>d9f7756</code></a> Build(deps): Bump hypothesis in /dependencies/default (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-asyncio/issues/416">#416</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/pytest-dev/pytest-asyncio/compare/v0.19.0...v0.20.1">compare view</a></li>
</ul>
</details>
<br />


You can trigger a rebase of this PR by commenting ``@dependabot` rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- ``@dependabot` rebase` will rebase this PR
- ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it
- ``@dependabot` merge` will merge this PR after your CI passes on it
- ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it
- ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging
- ``@dependabot` reopen` will reopen this PR if it is closed
- ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants