Skip to content

Commit

Permalink
Merge pull request #2502 from eerovaher/remote-test-modules
Browse files Browse the repository at this point in the history
Recommend a better way to mark remote data tests in remote test modules
  • Loading branch information
bsipocz authored Sep 11, 2022
2 parents 8bfeac0 + 361b242 commit 1ff3b7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 2 additions & 5 deletions astroquery/atomic/tests/test_atomic_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

from ...atomic import AtomicLineList

pytestmark = pytest.mark.remote_data


@pytest.mark.remote_data
def test_default_form_values():
default_response = AtomicLineList._request(
method="GET", url=AtomicLineList.FORM_URL,
Expand All @@ -28,7 +29,6 @@ def test_default_form_values():
'wave': u'Angstrom'}


@pytest.mark.remote_data
def test_query_with_default_params():
table = AtomicLineList.query_object(cache=False)
assert isinstance(table, Table)
Expand All @@ -43,7 +43,6 @@ def test_query_with_default_params():
1.02916 Zn XXX E1 1*-6* 1-6 1/2-* 1.33E+12 0.00 - 97174700.00'''.strip()


@pytest.mark.remote_data
def test_query_with_wavelength_params():
result = AtomicLineList.query_object(
wavelength_range=(15 * u.nm, 200 * u.Angstrom),
Expand All @@ -66,15 +65,13 @@ def test_query_with_wavelength_params():
'0.00 - 502481.80']))


@pytest.mark.remote_data
def test_empty_result_set():
result = AtomicLineList.query_object(wavelength_accuracy=0, cache=False)
assert isinstance(result, Table)
assert not result
assert len(result) == 0


@pytest.mark.remote_data
def test_lower_upper_ranges():
result = AtomicLineList.query_object(
lower_level_energy_range=u.Quantity((600 * u.cm**(-1), 1000 * u.cm**(-1))),
Expand Down
10 changes: 8 additions & 2 deletions docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ the ``test_module.py`` file.
``test_module_remote.py``
-------------------------

The remote tests are much easier. Just decorate the test class or test
functions with ``@pytest.mark.remote_data``.
The remote tests are much easier. The file must contain the following::

import pytest

pytestmark = pytest.mark.remote_data

This ensures that the test functions in remote test module are only executed if
the ``--remote-data`` flag is used.

``setup_package.py``
--------------------
Expand Down

0 comments on commit 1ff3b7f

Please sign in to comment.