[PATCH 10/14] functional: 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 10/14] functional: 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/functional/qemu_test/testcase.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index 71c7160adc..2a78e735f1 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -19,6 +19,7 @@
 from subprocess import run
 import sys
 import tempfile
+import warnings
 import unittest
 import uuid
 
@@ -235,6 +236,9 @@ def tearDown(self):
         self._log_fh.close()
 
     def main():
+        warnings.simplefilter("default")
+        os.environ["PYTHONWARNINGS"] = "default"
+
         path = os.path.basename(sys.argv[0])[:-3]
 
         cache = os.environ.get("QEMU_TEST_PRECACHE", None)
-- 
2.49.0


Re: [PATCH 10/14] functional: always enable all python warnings
Posted by Thomas Huth 4 months ago
On 15/07/2025 16.30, Daniel P. Berrangé 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>
> ---
>   tests/functional/qemu_test/testcase.py | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
> index 71c7160adc..2a78e735f1 100644
> --- a/tests/functional/qemu_test/testcase.py
> +++ b/tests/functional/qemu_test/testcase.py
> @@ -19,6 +19,7 @@
>   from subprocess import run
>   import sys
>   import tempfile
> +import warnings
>   import unittest
>   import uuid
>   
> @@ -235,6 +236,9 @@ def tearDown(self):
>           self._log_fh.close()
>   
>       def main():
> +        warnings.simplefilter("default")
> +        os.environ["PYTHONWARNINGS"] = "default"
> +
>           path = os.path.basename(sys.argv[0])[:-3]
>   
>           cache = os.environ.get("QEMU_TEST_PRECACHE", None)

Acked-by: Thomas Huth <thuth@redhat.com>


Re: [PATCH 10/14] functional: always enable all python warnings
Posted by John Snow 2 months, 3 weeks ago
On Tue, Jul 15, 2025 at 11:15 AM Thomas Huth <thuth@redhat.com> wrote:
>
> On 15/07/2025 16.30, Daniel P. Berrangé 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>

Looks like 8, 9, 10 already got merged; skipping.

> > ---
> >   tests/functional/qemu_test/testcase.py | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
> > index 71c7160adc..2a78e735f1 100644
> > --- a/tests/functional/qemu_test/testcase.py
> > +++ b/tests/functional/qemu_test/testcase.py
> > @@ -19,6 +19,7 @@
> >   from subprocess import run
> >   import sys
> >   import tempfile
> > +import warnings
> >   import unittest
> >   import uuid
> >
> > @@ -235,6 +236,9 @@ def tearDown(self):
> >           self._log_fh.close()
> >
> >       def main():
> > +        warnings.simplefilter("default")
> > +        os.environ["PYTHONWARNINGS"] = "default"
> > +
> >           path = os.path.basename(sys.argv[0])[:-3]
> >
> >           cache = os.environ.get("QEMU_TEST_PRECACHE", None)
>
> Acked-by: Thomas Huth <thuth@redhat.com>
>