On Thu, Sep 26, 2019 at 07:34:23PM +0200, Philippe Mathieu-Daudé wrote:
> We are going to use the same pattern. Instead of keeping
> copy/pasting this code, extract as a local function.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
> ---
>  tests/acceptance/boot_linux_console.py | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/acceptance/boot_linux_console.py 
> b/tests/acceptance/boot_linux_console.py
> index 8a9a314ab4..079590f0c8 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -19,6 +19,11 @@ from avocado.utils import process
>  from avocado.utils import archive
>  
>  
> +def gunzip(in_pathname_gz, out_pathname):
> +    with gzip.open(in_pathname_gz, 'rb') as f_in:
> +        with open(out_pathname, 'wb') as f_out:
> +            shutil.copyfileobj(f_in, f_out)
> +
>  class BootLinuxConsole(Test):
>      """
>      Boots a Linux kernel and checks that the console is operational and the
> @@ -166,10 +171,7 @@ class BootLinuxConsole(Test):
>          initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
>          initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
>          initrd_path = self.workdir + "rootfs.cpio"
> -
> -        with gzip.open(initrd_path_gz, 'rb') as f_in:
> -            with open(initrd_path, 'wb') as f_out:
> -                shutil.copyfileobj(f_in, f_out)

I'd rather see this eliminated...

> +        gunzip(initrd_path_gz, initrd_path)

... and this becoming:

    archive.gzip_uncompress(initrd_path_gz, initrd_path)

- Cleber.

>  
>          self.vm.set_machine('malta')
>          self.vm.set_console()
> -- 
> 2.20.1
> 

Reply via email to