[PATCH 14/14] iotests/check: always enable all python warnings

Daniel P. Berrangé posted 14 patches 4 months ago
Maintainers: John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Elena Ufimtseva <elena.ufimtseva@oracle.com>, Jagannathan Raman <jag.raman@oracle.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
[PATCH 14/14] iotests/check: always enable all python warnings
Posted by Daniel P. Berrangé 4 months ago
Of most importance is that this gives us a heads-up if anything
we rely on has been deprecated. The default python behaviour
only emits a warning if triggered from __main__ which is very
limited.

Setting the env variable further ensures that any python child
processes will also display warnings.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/qemu-iotests/check | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 545f9ec7bd..d9b7c1d598 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -21,6 +21,7 @@ import sys
 import argparse
 import shutil
 from pathlib import Path
+import warnings
 
 from findtests import TestFinder
 from testenv import TestEnv
@@ -137,6 +138,9 @@ def make_argparser() -> argparse.ArgumentParser:
 
 
 if __name__ == '__main__':
+    warnings.simplefilter("default")
+    os.environ["PYTHONWARNINGS"] = "default"
+
     args = make_argparser().parse_args()
 
     env = TestEnv(source_dir=args.source_dir,
-- 
2.49.0


Re: [PATCH 14/14] iotests/check: always enable all python warnings
Posted by John Snow 2 months, 3 weeks ago
On Tue, Jul 15, 2025 at 10:32 AM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> Of most importance is that this gives us a heads-up if anything
> we rely on has been deprecated. The default python behaviour
> only emits a warning if triggered from __main__ which is very
> limited.
>
> Setting the env variable further ensures that any python child
> processes will also display warnings.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: John Snow <jsnow@redhat.com>

Thanks for this one. I sent a PR for the first two patches, I will
stage everything else.

> ---
>  tests/qemu-iotests/check | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
> index 545f9ec7bd..d9b7c1d598 100755
> --- a/tests/qemu-iotests/check
> +++ b/tests/qemu-iotests/check
> @@ -21,6 +21,7 @@ import sys
>  import argparse
>  import shutil
>  from pathlib import Path
> +import warnings
>
>  from findtests import TestFinder
>  from testenv import TestEnv
> @@ -137,6 +138,9 @@ def make_argparser() -> argparse.ArgumentParser:
>
>
>  if __name__ == '__main__':
> +    warnings.simplefilter("default")
> +    os.environ["PYTHONWARNINGS"] = "default"
> +
>      args = make_argparser().parse_args()
>
>      env = TestEnv(source_dir=args.source_dir,
> --
> 2.49.0
>