=================
pytest-remotedata
=================
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.5796951.svg
:target: https://doi.org/10.5281/zenodo.5796951
:alt: 10.5281/zenodo.5796951
.. image:: https://github.com/astropy/pytest-remotedata/workflows/Run%20unit%20tests/badge.svg
:target: https://github.com/astropy/pytest-remotedata/actions
:alt: CI Status
This package provides a plugin for the `pytest`_ framework that allows
developers to control unit tests that require access to data from the internet.
It was originally part of the `astropy`_ core package, but has been moved to a
separate package in order to be of more general use.
.. _pytest: https://pytest.org/en/latest/
.. _astropy: https://astropy.org/
Motivation
----------
Many software packages provide features that require access to data from the
internet. These features need to be tested, but unit tests that access the
internet can dominate the overall runtime of a test suite.
The ``pytest-remotedata`` plugin allows developers to indicate which unit tests
require access to the internet, and to control when and whether such tests
should execute as part of any given run of the test suite.
Installation
------------
The ``pytest-remotedata`` plugin can be installed using ``pip``::
$ pip install pytest-remotedata
It is also possible to install the latest development version from the source
repository::
$ git clone https://github.com/astropy/pytest-remotedata
$ cd pytest-remotedata
$ pip install .
In either case, the plugin will automatically be registered for use with
``pytest``.
Usage
-----
Installing this plugin makes two decorators available for use with ``pytest``:
* ``remote_data`` for marking tests that require data from the internet
* ``internet_off`` for marking tests that should run only when internet access
is disabled
These decorators can be used to mark test functions, methods, and classes using
``@pytest.mark``. For example, consider the following test function that
requires access to data from the internet:
.. code-block:: python
import pytest
from urllib.request import urlopen
@pytest.mark.remote_data
def test_remote_data():
urlopen('https://astropy.org')
Marking the ``test_remote_data`` function with ``@pytest.mark.remote_data``
indicates to ``pytest`` that this test should be run only when access to remote
data sources is explicitly requested.
When this plugin is installed, the ``--remote-data`` command line option is
added to the ``pytest`` command line interface.
The default behavior is to skip tests that are marked with ``remote_data``.
If the ``--remote-data`` option is not provided to the ``pytest`` command, or
if ``--remote-data=none`` is provided, all tests that are marked with
``remote_data`` will be skipped. All tests that are marked with
``internet_off`` will be executed.
Sometimes it is useful to check that certain tests do not unexpectedly access
the internet. Strict remote data access checking can be enabled by setting
``remote_data_strict = true`` in the tested package's ``setup.cfg`` file. If
this option is enabled, any test that attempts to access the network but is not
marked with ``@pytest.mark.remote_data`` will fail.
Providing either the ``--remote-data`` option, or ``--remote-data=any`` to the
``pytest`` command line interface will cause all tests that are marked with
``remote-data`` to execute. Any tests that are marked with ``internet_off``
will be skipped.
Running the tests with ``--remote-data=astropy`` will cause only tests that
receive remote data from Astropy data sources to be run. Tests with any other
data sources will be skipped. This is indicated in the test code by marking
test functions with ``@pytest.mark.remote_data(source='astropy')``.
Running only the tests marked as ``remote_data``, use the built-in pytest
machinery, e.g., ``pytest -m remote_data --remote-data``.
In the future, we intend to support a configurable way to indicate specific
remote data sources in addition to ``astropy``.
Development Status
------------------
Questions, bug reports, and feature requests can be submitted on `github`_.
.. _github: https://github.com/astropy/pytest-remotedata
License
-------
This plugin is licensed under a 3-clause BSD style license - see the
``LICENSE.rst`` file.
Raw data
{
"_id": null,
"home_page": "https://github.com/astropy/pytest-remotedata",
"name": "pytest-remotedata",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "remote,data,pytest,py.test",
"author": "The Astropy Developers",
"author_email": "astropy.team@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ff/b7/e39d14f37df7303fd6643db638db0e7722a8d168212d6deb36244f844b68/pytest-remotedata-0.4.1.tar.gz",
"platform": null,
"description": "=================\npytest-remotedata\n=================\n\n.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.5796951.svg\n :target: https://doi.org/10.5281/zenodo.5796951\n :alt: 10.5281/zenodo.5796951\n\n.. image:: https://github.com/astropy/pytest-remotedata/workflows/Run%20unit%20tests/badge.svg\n :target: https://github.com/astropy/pytest-remotedata/actions\n :alt: CI Status\n\nThis package provides a plugin for the `pytest`_ framework that allows\ndevelopers to control unit tests that require access to data from the internet.\nIt was originally part of the `astropy`_ core package, but has been moved to a\nseparate package in order to be of more general use.\n\n.. _pytest: https://pytest.org/en/latest/\n.. _astropy: https://astropy.org/\n\n\nMotivation\n----------\n\nMany software packages provide features that require access to data from the\ninternet. These features need to be tested, but unit tests that access the\ninternet can dominate the overall runtime of a test suite.\n\nThe ``pytest-remotedata`` plugin allows developers to indicate which unit tests\nrequire access to the internet, and to control when and whether such tests\nshould execute as part of any given run of the test suite.\n\nInstallation\n------------\n\nThe ``pytest-remotedata`` plugin can be installed using ``pip``::\n\n $ pip install pytest-remotedata\n\nIt is also possible to install the latest development version from the source\nrepository::\n\n $ git clone https://github.com/astropy/pytest-remotedata\n $ cd pytest-remotedata\n $ pip install .\n\nIn either case, the plugin will automatically be registered for use with\n``pytest``.\n\nUsage\n-----\n\nInstalling this plugin makes two decorators available for use with ``pytest``:\n\n* ``remote_data`` for marking tests that require data from the internet\n* ``internet_off`` for marking tests that should run only when internet access\n is disabled\n\nThese decorators can be used to mark test functions, methods, and classes using\n``@pytest.mark``. For example, consider the following test function that\nrequires access to data from the internet:\n\n.. code-block:: python\n\n import pytest\n from urllib.request import urlopen\n\n @pytest.mark.remote_data\n def test_remote_data():\n urlopen('https://astropy.org')\n\nMarking the ``test_remote_data`` function with ``@pytest.mark.remote_data``\nindicates to ``pytest`` that this test should be run only when access to remote\ndata sources is explicitly requested.\n\nWhen this plugin is installed, the ``--remote-data`` command line option is\nadded to the ``pytest`` command line interface.\n\nThe default behavior is to skip tests that are marked with ``remote_data``.\nIf the ``--remote-data`` option is not provided to the ``pytest`` command, or\nif ``--remote-data=none`` is provided, all tests that are marked with\n``remote_data`` will be skipped. All tests that are marked with\n``internet_off`` will be executed.\n\nSometimes it is useful to check that certain tests do not unexpectedly access\nthe internet. Strict remote data access checking can be enabled by setting\n``remote_data_strict = true`` in the tested package's ``setup.cfg`` file. If\nthis option is enabled, any test that attempts to access the network but is not\nmarked with ``@pytest.mark.remote_data`` will fail.\n\n\nProviding either the ``--remote-data`` option, or ``--remote-data=any`` to the\n``pytest`` command line interface will cause all tests that are marked with\n``remote-data`` to execute. Any tests that are marked with ``internet_off``\nwill be skipped.\n\nRunning the tests with ``--remote-data=astropy`` will cause only tests that\nreceive remote data from Astropy data sources to be run. Tests with any other\ndata sources will be skipped. This is indicated in the test code by marking\ntest functions with ``@pytest.mark.remote_data(source='astropy')``.\n\nRunning only the tests marked as ``remote_data``, use the built-in pytest\nmachinery, e.g., ``pytest -m remote_data --remote-data``.\n\nIn the future, we intend to support a configurable way to indicate specific\nremote data sources in addition to ``astropy``.\n\nDevelopment Status\n------------------\n\nQuestions, bug reports, and feature requests can be submitted on `github`_.\n\n.. _github: https://github.com/astropy/pytest-remotedata\n\nLicense\n-------\nThis plugin is licensed under a 3-clause BSD style license - see the\n``LICENSE.rst`` file.\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Pytest plugin for controlling remote data access.",
"version": "0.4.1",
"project_urls": {
"Homepage": "https://github.com/astropy/pytest-remotedata"
},
"split_keywords": [
"remote",
"data",
"pytest",
"py.test"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "02709d5e2a5020c4721115b48fa6efa765ffff1cd679ed89049fa4c9a3c62f55",
"md5": "79c3c1fb0532d28c3b931b2bbbbb5d56",
"sha256": "4e840bd8733091c2a84e52528ee2c2a98aa2d4a26376ba20448f211bccd30a35"
},
"downloads": -1,
"filename": "pytest_remotedata-0.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "79c3c1fb0532d28c3b931b2bbbbb5d56",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 8583,
"upload_time": "2023-09-26T04:00:12",
"upload_time_iso_8601": "2023-09-26T04:00:12.927737Z",
"url": "https://files.pythonhosted.org/packages/02/70/9d5e2a5020c4721115b48fa6efa765ffff1cd679ed89049fa4c9a3c62f55/pytest_remotedata-0.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ffb7e39d14f37df7303fd6643db638db0e7722a8d168212d6deb36244f844b68",
"md5": "30a44b25501b3cdfe72c58cb17338ea7",
"sha256": "05c08bf638cdd1ed66eb01738a1647c3c714737c3ec3abe009d2c1f793b4bb59"
},
"downloads": -1,
"filename": "pytest-remotedata-0.4.1.tar.gz",
"has_sig": false,
"md5_digest": "30a44b25501b3cdfe72c58cb17338ea7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 13279,
"upload_time": "2023-09-26T04:00:14",
"upload_time_iso_8601": "2023-09-26T04:00:14.367463Z",
"url": "https://files.pythonhosted.org/packages/ff/b7/e39d14f37df7303fd6643db638db0e7722a8d168212d6deb36244f844b68/pytest-remotedata-0.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-26 04:00:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "astropy",
"github_project": "pytest-remotedata",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pytest-remotedata"
}