[PATCH 2/3] tests/functional: fix formatting of exception args

Daniel P. Berrangé posted 3 patches 1 month ago
Maintainers: Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>
There is a newer version of this series
[PATCH 2/3] tests/functional: fix formatting of exception args
Posted by Daniel P. Berrangé 1 month ago
On HTTP 404 errors, we failed to include the URL in the exception
that was raised, while for the catch-all exception we failed to
include the URL and forgot the placeholder for the exception
details too.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/functional/qemu_test/asset.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index b5a6136d36..ae2bec3ea5 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -168,12 +168,13 @@ def fetch(self):
                 # indicate a broken test rather than a transient
                 # server or networking problem
                 if e.code == 404:
-                    raise AssetError(self, "Unable to download: "
-                                     "HTTP error %d" % e.code)
+                    raise AssetError(self, "Unable to download %s: "
+                                     "HTTP error %d" % (self.url, e.code))
                 continue
             except Exception as e:
                 tmp_cache_file.unlink()
-                raise AssetError(self, "Unable to download: " % e)
+                raise AssetError(self, "Unable to download %s: %s" % (
+                    self.url, e))
 
         if not os.path.exists(tmp_cache_file):
             raise AssetError(self, "Download retries exceeded", transient=True)
-- 
2.50.1


Re: [PATCH 2/3] tests/functional: fix formatting of exception args
Posted by Thomas Huth 1 month ago
On 29/08/2025 10.31, Daniel P. Berrangé wrote:
> On HTTP 404 errors, we failed to include the URL in the exception
> that was raised, while for the catch-all exception we failed to
> include the URL and forgot the placeholder for the exception
> details too.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/functional/qemu_test/asset.py | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
> index b5a6136d36..ae2bec3ea5 100644
> --- a/tests/functional/qemu_test/asset.py
> +++ b/tests/functional/qemu_test/asset.py
> @@ -168,12 +168,13 @@ def fetch(self):
>                   # indicate a broken test rather than a transient
>                   # server or networking problem
>                   if e.code == 404:
> -                    raise AssetError(self, "Unable to download: "
> -                                     "HTTP error %d" % e.code)
> +                    raise AssetError(self, "Unable to download %s: "
> +                                     "HTTP error %d" % (self.url, e.code))
>                   continue
>               except Exception as e:
>                   tmp_cache_file.unlink()
> -                raise AssetError(self, "Unable to download: " % e)
> +                raise AssetError(self, "Unable to download %s: %s" % (
> +                    self.url, e))
>   
>           if not os.path.exists(tmp_cache_file):
>               raise AssetError(self, "Download retries exceeded", transient=True)

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