Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use pytest markers for intensive tests #12764

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

Merged
merged 5 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
python: 3.9
toxenv: py39-test-alldeps
toxargs: -v --develop
toxposargs: --open-files
toxposargs: --open-files --run-slow

- name: Python 3.8 with oldest supported version of all dependencies
os: ubuntu-18.04
Expand All @@ -87,7 +87,7 @@ jobs:
os: macos-latest
python: 3.9
toxenv: py39-test-alldeps
toxposargs: --durations=50
toxposargs: --durations=50 --run-slow

steps:
- name: Checkout code
Expand Down
3 changes: 2 additions & 1 deletion .pyinstaller/run_astropy_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
# Run the tests!
sys.exit(pytest.main(['astropy_tests',
'-k ' + ' and '.join('not ' + test for test in SKIP_TESTS)],
plugins=['pytest_doctestplus.plugin',
plugins=['pytest_astropy.plugin',
'pytest_doctestplus.plugin',
'pytest_openfiles.plugin',
'pytest_remotedata.plugin',
'pytest_astropy_header.display']))
1 change: 1 addition & 0 deletions astropy/convolution/tests/test_discretize.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_gaussian_eval_2D(mode):


@pytest.mark.skipif('not HAS_SCIPY')
@pytest.mark.slow
def test_gaussian_eval_2D_integrate_mode():
"""
Discretize Gaussian with integrate mode
Expand Down
1 change: 1 addition & 0 deletions astropy/coordinates/tests/test_spectral_coordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ def test_spectral_coord_from_sky_coord_without_distance():


@pytest.mark.parametrize('specsys', list(EXPECTED_VELOCITY_FRAMES))
@pytest.mark.slow
def test_spectralcoord_accuracy(specsys):

# This is a test to check the numerical results of transformations between
Expand Down
12 changes: 4 additions & 8 deletions astropy/io/ascii/tests/test_c_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,16 +1038,14 @@ def test_fast_tab_with_names(parallel, read_tab):
read_tab(content, data_start=1, parallel=parallel, names=head)


@pytest.mark.skipif(not os.getenv('TEST_READ_HUGE_FILE'),
reason='Environment variable TEST_READ_HUGE_FILE must be '
'defined to run this test')
@pytest.mark.hugemem
def test_read_big_table(tmpdir):
"""Test reading of a huge file.

This test generates a huge CSV file (~2.3Gb) before reading it (see
https://github.com/astropy/astropy/pull/5319). The test is run only if the
environment variable ``TEST_READ_HUGE_FILE`` is defined. Note that running
the test requires quite a lot of memory (~18Gb when reading the file) !!
``--run-hugemem`` cli option is given. Note that running the test requires
quite a lot of memory (~18Gb when reading the file) !!

"""
NB_ROWS = 250000
Expand All @@ -1072,9 +1070,7 @@ def test_read_big_table(tmpdir):
assert len(t) == NB_ROWS


@pytest.mark.skipif(not os.getenv('TEST_READ_HUGE_FILE'),
reason='Environment variable TEST_READ_HUGE_FILE must be '
'defined to run this test')
@pytest.mark.hugemem
def test_read_big_table2(tmpdir):
"""Test reading of a file with a huge column.
"""
Expand Down
1 change: 1 addition & 0 deletions astropy/io/fits/tests/test_fitsdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def test_quiet(self, capsys):
assert out == ""
assert err == ""

@pytest.mark.slow
def test_path(self, capsys):
os.mkdir(self.temp('sub/'))
tmp_b = self.temp('sub/ascii.fits')
Expand Down
1 change: 1 addition & 0 deletions astropy/io/fits/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,7 @@ def test_open_comp_image_in_update_mode(self):
# opening and closing it.
assert mtime == os.stat(self.temp('comp.fits')).st_mtime

@pytest.mark.slow
def test_open_scaled_in_update_mode_compressed(self):
"""
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/88 2
Expand Down
1 change: 1 addition & 0 deletions astropy/io/fits/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2682,6 +2682,7 @@ def readfile(filename):
readfile(self.data('memtest.fits'))

@pytest.mark.skipif('not HAVE_OBJGRAPH')
@pytest.mark.slow
def test_reference_leak2(self, tmpdir):
"""
Regression test for https://github.com/astropy/astropy/pull/4539
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def asdf_check(ff):
helpers.assert_roundtrip_tree(tree, tmpdir, asdf_check_func=asdf_check)


@pytest.mark.slow
def test_generic_projections(tmpdir):
from astropy.io.misc.asdf.tags.transform import projections

Expand Down
4 changes: 3 additions & 1 deletion astropy/samp/tests/test_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import time

from astropy.samp.hub import SAMPHubServer
import pytest

from astropy.samp import conf
from astropy.samp.hub import SAMPHubServer


def setup_module(module):
Expand All @@ -24,6 +25,7 @@ def test_SAMPHubServer_run():
hub.stop()


@pytest.mark.slow
def test_SAMPHubServer_run_repeated():
"""
Test that SAMPHub can be restarted after it has been stopped, including
Expand Down
4 changes: 3 additions & 1 deletion astropy/samp/tests/test_hub_script.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import sys

from astropy.samp.hub_script import hub_script
import pytest

from astropy.samp import conf
from astropy.samp.hub_script import hub_script


def setup_module(module):
Expand All @@ -18,6 +19,7 @@ def teardown_function(function):
sys.argv = function.sys_argv_orig


@pytest.mark.slow
def test_hub_script():
sys.argv.append('-m') # run in multiple mode
sys.argv.append('-w') # disable web profile
Expand Down
1 change: 1 addition & 0 deletions astropy/units/tests/test_quantity_ufuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_removal_addition(self):
assert np.add in qh.UFUNC_HELPERS
assert np.add not in qh.UNSUPPORTED_UFUNCS

@pytest.mark.slow
def test_thread_safety(self, fast_thread_switching):
def dummy_ufunc(*args, **kwargs):
return np.sqrt(*args, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions astropy/utils/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ def test_download_parallel_partial_success(temp_cache, valid_urls, invalid_urls)
# assert not any([is_url_in_cache(u) for (u, c) in td])


@pytest.mark.slow
def test_download_parallel_partial_success_lock_safe(temp_cache, valid_urls, invalid_urls):
"""Check that a partially successful parallel download leaves the cache unlocked.

Expand Down
2 changes: 2 additions & 0 deletions astropy/utils/tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ def _get_foo(cls): return 1
assert B.__dict__['foo'].__doc__ == "The foo."


@pytest.mark.slow
def test_classproperty_lazy_threadsafe(fast_thread_switching):
"""
Test that a class property with lazy=True is thread-safe.
Expand Down Expand Up @@ -555,6 +556,7 @@ def foo(cls):
assert values == [values[0]] * workers


@pytest.mark.slow
def test_lazyproperty_threadsafe(fast_thread_switching):
"""
Test thread safety of lazyproperty.
Expand Down
2 changes: 1 addition & 1 deletion docs/development/releasing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ of the tests actually run), using tox to do a thorough test in an isolated
environment::

$ pip install tox --upgrade
$ TEST_READ_HUGE_FILE=1 tox -e test-alldeps -- --remote-data=any
$ tox -e test-alldeps -- --remote-data=any --run-slow --run-hugemem

Additional notes
----------------
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test = # Required to run the astropy test suite.
pytest>=7.0
pytest-doctestplus>=0.12
pytest-astropy-header>=0.2.1
pytest-astropy>=0.9
pytest-astropy>=0.10
pytest-xdist
test_all = # Required for testing, plus packages used by particular tests.
pytest>=7.0
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ isolated_build = true
pypi_filter = https://raw.githubusercontent.com/astropy/ci-helpers/main/pip_pinnings.txt

# Pass through the following environment variables which are needed for the CI
passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI IS_CRON ARCH_ON_CI TEST_READ_HUGE_FILE
passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI IS_CRON ARCH_ON_CI

# For coverage, we need to pass extra options to the C compiler
setenv =
Expand Down Expand Up @@ -151,6 +151,7 @@ commands =
--exclude-module tkinter \
--collect-submodules=py \
--hidden-import pytest \
--hidden-import pytest_astropy.plugin \
--hidden-import pytest_openfiles.plugin \
--hidden-import pytest_remotedata.plugin \
--hidden-import pytest_doctestplus.plugin \
Expand Down