From c5289ff386a231cb4005f346b8f21b207efa5651 Mon Sep 17 00:00:00 2001 From: Josh Meyers Date: Mon, 16 Sep 2024 22:47:58 -0700 Subject: [PATCH] Remove doc mentions of nosetests --- docs/install.rst | 4 ---- setup.py | 24 +++++++++++------------- tests/test_config_image.py | 4 ++-- tests/test_download.py | 2 +- tests/test_main.py | 2 +- tests/test_roman.py | 4 ++-- tests/test_wcs.py | 2 +- tests/time_all_tests | 5 ----- 8 files changed, 18 insertions(+), 29 deletions(-) delete mode 100755 tests/time_all_tests diff --git a/docs/install.rst b/docs/install.rst index d7fc47ec9fd..908f93a304d 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -73,10 +73,6 @@ You can also run them with multiple jobs (e.g. for 4 jobs) by typing:: You need the ``pytest-xdist`` and ``pytest-timeout`` plugins for this to work. -If you prefer to use nosetests, the equivalent command is:: - - nosetests --processes=4 --process-timeout=60 test*.py - .. note:: If your system does not have ``pytest`` installed, and you do not want diff --git a/setup.py b/setup.py index 1bae8495c85..d18d9332ca9 100644 --- a/setup.py +++ b/setup.py @@ -244,7 +244,7 @@ def supports_gpu(compiler, cc_type): extra_cflags = copt[cc_type] extra_lflags = lopt[cc_type] return try_compile(cpp_code, compiler, extra_cflags, extra_lflags) - + # Check for the fftw3 library in some likely places def find_fftw_lib(output=False): import distutils.sysconfig @@ -434,29 +434,29 @@ def find_eigen_dir(output=False): if output: print("Downloaded %s. Unpacking tarball."%fname) with tarfile.open(fname) as tar: - + def is_within_directory(directory, target): - + abs_directory = os.path.abspath(directory) abs_target = os.path.abspath(target) - + prefix = os.path.commonprefix([abs_directory, abs_target]) - + return prefix == abs_directory - + def safe_extract(tar, path=".", members=None, *, numeric_owner=False): # Avoid security vulnerability in tar.extractall function. # This bit of code was added by the Advanced Research Center at Trellix in PR #1188. # For more information about the security vulnerability, see # https://github.com/advisories/GHSA-gw9q-c7gh-j9vm - + for member in tar.getmembers(): member_path = os.path.join(path, member.name) if not is_within_directory(path, member_path): raise Exception("Attempted Path Traversal in Tar File") - - tar.extractall(path, members, numeric_owner=numeric_owner) - + + tar.extractall(path, members, numeric_owner=numeric_owner) + safe_extract(tar, dir) os.remove(fname) # This actually extracts into a subdirectory with a name eigen-eigen-5a0156e40feb/ @@ -1345,9 +1345,7 @@ def run_tests(self): build_dep = ['setuptools>=38,<72', 'pybind11>=2.2', 'numpy>=1.17'] run_dep = ['astropy', 'LSSTDESC.Coord'] -test_dep = ['pytest', 'pytest-xdist', 'pytest-timeout', 'nose', 'scipy', 'pyyaml'] -# Note: Even though we don't use nosetests, nose is required for some tests to work. -# cf. https://gist.github.com/dannygoldstein/e18866ebb9c39a2739f7b9f16440e2f5 +test_dep = ['pytest', 'pytest-xdist', 'pytest-timeout', 'scipy', 'pyyaml'] # If Eigen doesn't exist in the normal places, download it. find_eigen_dir(output=True) diff --git a/tests/test_config_image.py b/tests/test_config_image.py index 163e57a5a66..169f1be527c 100644 --- a/tests/test_config_image.py +++ b/tests/test_config_image.py @@ -2095,7 +2095,7 @@ def test_index_key(run_slow): images1 = [ galsim.fits.readMulti('output/index_key%02d.fits'%n) for n in range(nfiles) ] if run_slow: - # For nose tests skip these 3 to save some time. + # For pytest tests, skip these 3 to save some time. # images5 is really the hardest test, and images1 is the easiest, so those two will # give good diagnostics for any errors. @@ -2839,7 +2839,7 @@ def test_chromatic(run_slow): if run_slow: bp_file = 'LSST_r.dat' else: - # In nosetests, use a simple bandpass to go faster. + # In pytest, use a simple bandpass to go faster. bp_file = 'chromatic_reference_images/simple_bandpass.dat' # First check a chromatic galaxy with a regular PSF. diff --git a/tests/test_download.py b/tests/test_download.py index 4583f9e58b8..516d15a4c1f 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -80,7 +80,7 @@ def test_args(): assert args.nolink is True # Some invalid parameters - # To avoid ugly text output during nosetests runs, redirect stderr to stdout for a moment. + # To avoid ugly text output during pytest runs, redirect stderr to stdout for a moment. sys_stderr = sys.stderr sys.stderr = sys.stdout with assert_raises(SystemExit): diff --git a/tests/test_main.py b/tests/test_main.py index 302321495e0..2b9f78dc02a 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -138,7 +138,7 @@ def test_args(): galsim.main.parse_args([config_file, '-j', '3']) # The ones handled by ArgumentParser raise SystemExit and print to stderr - # To avoid ugly text output during nosetests runs, redirect stderr to stdout for a moment. + # To avoid ugly text output during pytest runs, redirect stderr to stdout for a moment. sys_stderr = sys.stderr sys.stderr = sys.stdout with assert_raises(SystemExit): diff --git a/tests/test_roman.py b/tests/test_roman.py index 115fb4d09a1..96f52ada074 100644 --- a/tests/test_roman.py +++ b/tests/test_roman.py @@ -645,7 +645,7 @@ def test_roman_psfs(run_slow): # - fully chromatic PSFs with interpolation, but only interpolating between two wavelengths. # - achromatic PSFs. # - # We also only test pupil_bin=4,8 in nosetests runs. Tests of pupil_bin=1,2 are done in + # We also only test pupil_bin=4,8 in pytest runs. Tests of pupil_bin=1,2 are done in # __main__ runs. # Providing a wavelength returns achromatic PSFs @@ -748,7 +748,7 @@ def test_roman_psfs(run_slow): { 'pupil_bin':8 }, ] if run_slow: - # A few more that are too slow to run in regular nosetests + # A few more that are too slow to run in regular pytest kwargs_list.extend([ { 'pupil_bin':1 }, { 'pupil_bin':2 }, diff --git a/tests/test_wcs.py b/tests/test_wcs.py index 35ef63ab224..ef037e22706 100644 --- a/tests/test_wcs.py +++ b/tests/test_wcs.py @@ -486,7 +486,7 @@ def do_wcs_image(wcs, name, run_slow, approx=False): # used to be a problem if the wcs returned ra values that jump from 360 to 0. # Not very stringent test, since we're just checking that we don't have some pixels # that are orders of magnitude different from the average. So rtol=2 is good. - # (1 is fine for the nosetests runs, but one of the edge cases fails in main runs. It's not + # (1 is fine for the pytest runs, but one of the edge cases fails in main runs. It's not # a problem I think, just one of the weird wcs types has a more variable pixel area.) np.testing.assert_allclose(im.array, area*sky_level, rtol=2) diff --git a/tests/time_all_tests b/tests/time_all_tests deleted file mode 100755 index 47c88308f0f..00000000000 --- a/tests/time_all_tests +++ /dev/null @@ -1,5 +0,0 @@ -#/bin/bash -#time run_all_tests | grep time | sort -n -k 5 | gawk '{print; n++; sum+=$5} END { print "total time for",n,"tests = ",sum }' - -# Another option... -time nosetests -s | grep time | sort -n -k 5 | gawk '{print; n++; sum+=$5} END { print "total time for",n,"tests = ",sum }'