diff --git a/CHANGES.rst b/CHANGES.rst index d0c35e5b91..dfedaec0c4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -42,6 +42,10 @@ Infrastructure, Utility and Other Changes and Additions - Callback hooks are deleted before caching. Potentially all cached queries prior to this PR will be rendered invalid. [#2295] +- The modules that make use of the ``astroquery.utils.tap.model.job.Job`` class + (e.g. Gaia) no longer print messages about where the results of async queries + were written if the ``verbose`` setting is ``False``. [#2299] + 0.4.5 (2021-12-24) ================== diff --git a/astroquery/utils/tap/model/job.py b/astroquery/utils/tap/model/job.py index 4e74fb09c5..8dc1eb1986 100755 --- a/astroquery/utils/tap/model/job.py +++ b/astroquery/utils/tap/model/job.py @@ -299,7 +299,8 @@ def save_results(self, verbose=False): output = self.outputFile else: output = self.outputFileUser - print(f"Saving results to: {output}") + if verbose: + print(f"Saving results to: {output}") self.connHandler.dump_to_file(output, response) def wait_for_job_end(self, verbose=False): diff --git a/astroquery/utils/tap/model/tests/test_job.py b/astroquery/utils/tap/model/tests/test_job.py index 6fc9e50863..1e01f5e8a1 100644 --- a/astroquery/utils/tap/model/tests/test_job.py +++ b/astroquery/utils/tap/model/tests/test_job.py @@ -35,7 +35,7 @@ def test_job_basic(): job.get_results() -def test_job_get_results(): +def test_job_get_results(capsys, tmpdir): job = Job(async_job=True) jobid = "12345" outputFormat = "votable" @@ -82,6 +82,14 @@ def test_job_get_results(): if cn not in res.colnames: pytest.fail(f"{cn} column name not found: {res.colnames}") + # Regression test for #2299; messages were printed even with `verbose=False` + capsys.readouterr() + job._Job__resultInMemory = False + job.save_results(verbose=False) + assert 'Saving results to:' not in capsys.readouterr().out + job.save_results(verbose=True) + assert 'Saving results to:' in capsys.readouterr().out + def test_job_phase(): job = Job(async_job=True)