diff mbox series

[v2,2/5] qemu-iotests: Fix FilePaths docstring

Message ID 20200820235427.374645-3-nsoffer@redhat.com (mailing list archive)
State New, archived
Headers show
Series iotest.FilePath fixes and cleanups | expand

Commit Message

Nir Soffer Aug. 20, 2020, 11:54 p.m. UTC
When this class was extracted from FilePath, the docstring was not
updated for generating multiple files, and the example usage was
referencing unrelated file.

Fixes: de263986b5dc
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
---
 tests/qemu-iotests/iotests.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Max Reitz Aug. 25, 2020, 10:39 a.m. UTC | #1
On 21.08.20 01:54, Nir Soffer wrote:
> When this class was extracted from FilePath, the docstring was not
> updated for generating multiple files, and the example usage was
> referencing unrelated file.
> 
> Fixes: de263986b5dc
> Signed-off-by: Nir Soffer <nsoffer@redhat.com>
> ---
>  tests/qemu-iotests/iotests.py | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>
Max Reitz Aug. 25, 2020, 10:48 a.m. UTC | #2
On 21.08.20 01:54, Nir Soffer wrote:
> When this class was extracted from FilePath, the docstring was not
> updated for generating multiple files, and the example usage was
> referencing unrelated file.
> 
> Fixes: de263986b5dc
> Signed-off-by: Nir Soffer <nsoffer@redhat.com>
> ---
>  tests/qemu-iotests/iotests.py | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 16a04df8a3..f34a1d7ef1 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -450,14 +450,16 @@ def file_pattern(name):
>  
>  class FilePaths:
>      """
> -    FilePaths is an auto-generated filename that cleans itself up.
> +    Context manager generating multiple file names. The generated files are
> +    removed when exiting the context.
>  
> -    Use this context manager to generate filenames and ensure that the file
> -    gets deleted::
> +    Example usage:
> +
> +        with FilePaths(['test.img', 'test.sock']) as (img_path, sock_path):

On second thought, this isn’t a great example because image files and
sockets should go into different base directories.

Max

> +            # Use img_path and sock_path here...
> +
> +        # img_path and sock_path are automatically removed here.
>  
> -        with FilePaths(['test.img']) as img_path:
> -            qemu_img('create', img_path, '1G')
> -        # migration_sock_path is automatically deleted
>      """
>      def __init__(self, names, base_dir=test_dir):
>          self.paths = []
>
Nir Soffer Aug. 25, 2020, 11:17 a.m. UTC | #3
On Tue, Aug 25, 2020 at 1:48 PM Max Reitz <mreitz@redhat.com> wrote:
>
> On 21.08.20 01:54, Nir Soffer wrote:
> > When this class was extracted from FilePath, the docstring was not
> > updated for generating multiple files, and the example usage was
> > referencing unrelated file.
> >
> > Fixes: de263986b5dc
> > Signed-off-by: Nir Soffer <nsoffer@redhat.com>
> > ---
> >  tests/qemu-iotests/iotests.py | 14 ++++++++------
> >  1 file changed, 8 insertions(+), 6 deletions(-)
> >
> > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> > index 16a04df8a3..f34a1d7ef1 100644
> > --- a/tests/qemu-iotests/iotests.py
> > +++ b/tests/qemu-iotests/iotests.py
> > @@ -450,14 +450,16 @@ def file_pattern(name):
> >
> >  class FilePaths:
> >      """
> > -    FilePaths is an auto-generated filename that cleans itself up.
> > +    Context manager generating multiple file names. The generated files are
> > +    removed when exiting the context.
> >
> > -    Use this context manager to generate filenames and ensure that the file
> > -    gets deleted::
> > +    Example usage:
> > +
> > +        with FilePaths(['test.img', 'test.sock']) as (img_path, sock_path):
>
> On second thought, this isn’t a great example because image files and
> sockets should go into different base directories.

Right, will improve it in v3.

>
> Max
>
> > +            # Use img_path and sock_path here...
> > +
> > +        # img_path and sock_path are automatically removed here.
> >
> > -        with FilePaths(['test.img']) as img_path:
> > -            qemu_img('create', img_path, '1G')
> > -        # migration_sock_path is automatically deleted
> >      """
> >      def __init__(self, names, base_dir=test_dir):
> >          self.paths = []
> >
>
>
diff mbox series

Patch

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 16a04df8a3..f34a1d7ef1 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -450,14 +450,16 @@  def file_pattern(name):
 
 class FilePaths:
     """
-    FilePaths is an auto-generated filename that cleans itself up.
+    Context manager generating multiple file names. The generated files are
+    removed when exiting the context.
 
-    Use this context manager to generate filenames and ensure that the file
-    gets deleted::
+    Example usage:
+
+        with FilePaths(['test.img', 'test.sock']) as (img_path, sock_path):
+            # Use img_path and sock_path here...
+
+        # img_path and sock_path are automatically removed here.
 
-        with FilePaths(['test.img']) as img_path:
-            qemu_img('create', img_path, '1G')
-        # migration_sock_path is automatically deleted
     """
     def __init__(self, names, base_dir=test_dir):
         self.paths = []