From f59293c180f846a220762701006d25655095991f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 23 Oct 2021 09:09:29 +0200 Subject: [PATCH] Fix test_describe_empty to work without global -Werror Fix test_describe_empty to work when the test suite is run without global -Werror. This is e.g. desirable for packagers who don't want the test suite for a fixed version to suddenly start failing due to DeprecationWarnings in dependencies that otherwise don't break the package. Since the test expects either a ValueError or a RuntimeWarning, it seems that the easiest way to assert for that is to inject the "error" filter for the scope of the call. --- dask/dataframe/tests/test_dataframe.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dask/dataframe/tests/test_dataframe.py b/dask/dataframe/tests/test_dataframe.py index 32edb488..e0d88ba8 100644 --- a/dask/dataframe/tests/test_dataframe.py +++ b/dask/dataframe/tests/test_dataframe.py @@ -570,7 +570,11 @@ def test_describe_empty(): ) with pytest.raises((ValueError, RuntimeWarning)): - ddf_len0.describe(percentiles_method="dask").compute() + with warnings.catch_warnings(): + # ensure that the warning is turned into an error since this is + # the easiest way to assert for exception-or-warning + warnings.simplefilter("error") + ddf_len0.describe(percentiles_method="dask").compute() with pytest.raises(ValueError): ddf_nocols.describe(percentiles_method="dask").compute() -- 2.33.1