Skip to main content

pytest-remotedata

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.

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:

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').

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.

License

This plugin is licensed under a 3-clause BSD style license - see the LICENSE.rst file.

Metadata

Release files for pytest-remotedata 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-remotedata 0.3.3
File Size Uploaded Provenance Actions
pytest-remotedata-0.3.3.tar.gz 12.7 kB Without provenance Details for pytest-remotedata-0.3.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-remotedata 0.3.3
File Interpreter ABI Platform Actions
pytest_remotedata-0.3.3-py3-none-any.whl Python 3 none any Details for pytest_remotedata-0.3.3-py3-none-any.whl

Total release size: 21.3 kB

Release files / pytest-remotedata-0.3.3.tar.gz

Download URL pytest-remotedata-0.3.3.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
66920bf1c62928b079d0e611379111a0d49f10a9509ced54c8269514ccce6ee3
BLAKE2b-256 checksum
How to use checksums
a276a09bc381bb3d31de97a684c9e680a74d03c2a30997c59fc2966409259003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / pytest_remotedata-0.3.3-py3-none-any.whl

Download URL pytest_remotedata-0.3.3-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ee2801f20afc9174676d85c9a22e8fb960c3fff94c86d80b7dc8ac5c03163f3
BLAKE2b-256 checksum
How to use checksums
0e37872bab8f32ea31c06596a2b2a97316cbb0f0aff90791acc750680f40ab95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Security for pytest-remotedata 0.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page