framework: deepcopy TestProfile's filters when copying it

Submitted by Andres Gomez on July 19, 2018, 10:39 p.m.

Details

Message ID 20180719223905.29797-1-agomez@igalia.com
State Accepted
Commit f363ec73caf54d7c4daf7a03bc1066e7f79a8fe3
Headers show
Series "framework: deepcopy TestProfile's filters when copying it" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Andres Gomez July 19, 2018, 10:39 p.m.
This avoids modifications in the original filters object.

Detected through Travis CI.

Fixed also a couple of typos.

Fixes: 1f0f2ad25 ("framework: Add filters class")
Cc: Dylan Baker <dylanx.c.baker@intel.com>
Cc: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Andres Gomez <agomez@igalia.com>
---
 framework/profile.py                        | 5 ++++-
 unittests/framework/summary/test_feature.py | 2 +-
 unittests/framework/utils.py                | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/framework/profile.py b/framework/profile.py
index a6cac2cf0..8d6fd0706 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -501,11 +501,14 @@  class TestProfile(object):
         This method creates a copy with references to the original instance
         using copy.copy. This allows profiles to be "subclassed" by other
         profiles, without modifying the original.
+
+        copy.deepcopy is used for the filters so the original is
+        actually not modified in this case.
         """
         new = copy.copy(self)
         new.test_list = copy.copy(self.test_list)
         new.forced_test_list = copy.copy(self.forced_test_list)
-        new.filters = copy.copy(self.filters)
+        new.filters = copy.deepcopy(self.filters)
         return new
 
     def itertests(self):
diff --git a/unittests/framework/summary/test_feature.py b/unittests/framework/summary/test_feature.py
index fc05941b6..905484991 100644
--- a/unittests/framework/summary/test_feature.py
+++ b/unittests/framework/summary/test_feature.py
@@ -77,7 +77,7 @@  PROFILE.test_list['spec@gl-2.0@d'] = _maketest('fail')
 
 
 class TestFeatResult(object):
-    """Tests fro the FeatResult class."""
+    """Tests for the FeatResult class."""
 
     @pytest.fixture(scope='session')
     def feature(self, tmpdir_factory):
diff --git a/unittests/framework/utils.py b/unittests/framework/utils.py
index bb3a19146..15117f97d 100644
--- a/unittests/framework/utils.py
+++ b/unittests/framework/utils.py
@@ -32,7 +32,7 @@  from framework.test.base import Test as _Test
 
 
 class Test(_Test):
-    """A Test dericed class with a stub interpret_result.
+    """A Test derived class with a stub interpret_result.
 
     This class provides a way to test the Test class.
     """

Comments

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>

Quoting Andres Gomez (2018-07-19 15:39:05)
> This avoids modifications in the original filters object.
> 
> Detected through Travis CI.
> 
> Fixed also a couple of typos.
> 
> Fixes: 1f0f2ad25 ("framework: Add filters class")
> Cc: Dylan Baker <dylanx.c.baker@intel.com>
> Cc: Michel Dänzer <michel.daenzer@amd.com>
> Signed-off-by: Andres Gomez <agomez@igalia.com>
> ---
>  framework/profile.py                        | 5 ++++-
>  unittests/framework/summary/test_feature.py | 2 +-
>  unittests/framework/utils.py                | 2 +-
>  3 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/framework/profile.py b/framework/profile.py
> index a6cac2cf0..8d6fd0706 100644
> --- a/framework/profile.py
> +++ b/framework/profile.py
> @@ -501,11 +501,14 @@ class TestProfile(object):
>          This method creates a copy with references to the original instance
>          using copy.copy. This allows profiles to be "subclassed" by other
>          profiles, without modifying the original.
> +
> +        copy.deepcopy is used for the filters so the original is
> +        actually not modified in this case.
>          """
>          new = copy.copy(self)
>          new.test_list = copy.copy(self.test_list)
>          new.forced_test_list = copy.copy(self.forced_test_list)
> -        new.filters = copy.copy(self.filters)
> +        new.filters = copy.deepcopy(self.filters)
>          return new
>  
>      def itertests(self):
> diff --git a/unittests/framework/summary/test_feature.py b/unittests/framework/summary/test_feature.py
> index fc05941b6..905484991 100644
> --- a/unittests/framework/summary/test_feature.py
> +++ b/unittests/framework/summary/test_feature.py
> @@ -77,7 +77,7 @@ PROFILE.test_list['spec@gl-2.0@d'] = _maketest('fail')
>  
>  
>  class TestFeatResult(object):
> -    """Tests fro the FeatResult class."""
> +    """Tests for the FeatResult class."""
>  
>      @pytest.fixture(scope='session')
>      def feature(self, tmpdir_factory):
> diff --git a/unittests/framework/utils.py b/unittests/framework/utils.py
> index bb3a19146..15117f97d 100644
> --- a/unittests/framework/utils.py
> +++ b/unittests/framework/utils.py
> @@ -32,7 +32,7 @@ from framework.test.base import Test as _Test
>  
>  
>  class Test(_Test):
> -    """A Test dericed class with a stub interpret_result.
> +    """A Test derived class with a stub interpret_result.
>  
>      This class provides a way to test the Test class.
>      """
> -- 
> 2.18.0
>
On Thu, 19 Jul 2018 at 19:47, Dylan Baker <dylan@pnwbakers.com> wrote:

> Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
>

Reviewed-by: Rhys Kidd <rhyskidd@gmail.com>

Eric Engestrom and I had been looking at those regressions, and came to a
similar conclusion.


>
> Quoting Andres Gomez (2018-07-19 15:39:05)
> > This avoids modifications in the original filters object.
> >
> > Detected through Travis CI.
> >
> > Fixed also a couple of typos.
> >
> > Fixes: 1f0f2ad25 ("framework: Add filters class")
> > Cc: Dylan Baker <dylanx.c.baker@intel.com>
> > Cc: Michel Dänzer <michel.daenzer@amd.com>
> > Signed-off-by: Andres Gomez <agomez@igalia.com>
> > ---
> >  framework/profile.py                        | 5 ++++-
> >  unittests/framework/summary/test_feature.py | 2 +-
> >  unittests/framework/utils.py                | 2 +-
> >  3 files changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/framework/profile.py b/framework/profile.py
> > index a6cac2cf0..8d6fd0706 100644
> > --- a/framework/profile.py
> > +++ b/framework/profile.py
> > @@ -501,11 +501,14 @@ class TestProfile(object):
> >          This method creates a copy with references to the original
> instance
> >          using copy.copy. This allows profiles to be "subclassed" by
> other
> >          profiles, without modifying the original.
> > +
> > +        copy.deepcopy is used for the filters so the original is
> > +        actually not modified in this case.
> >          """
> >          new = copy.copy(self)
> >          new.test_list = copy.copy(self.test_list)
> >          new.forced_test_list = copy.copy(self.forced_test_list)
> > -        new.filters = copy.copy(self.filters)
> > +        new.filters = copy.deepcopy(self.filters)
> >          return new
> >
> >      def itertests(self):
> > diff --git a/unittests/framework/summary/test_feature.py
> b/unittests/framework/summary/test_feature.py
> > index fc05941b6..905484991 100644
> > --- a/unittests/framework/summary/test_feature.py
> > +++ b/unittests/framework/summary/test_feature.py
> > @@ -77,7 +77,7 @@ PROFILE.test_list['spec@gl-2.0@d'] = _maketest('fail')
> >
> >
> >  class TestFeatResult(object):
> > -    """Tests fro the FeatResult class."""
> > +    """Tests for the FeatResult class."""
> >
> >      @pytest.fixture(scope='session')
> >      def feature(self, tmpdir_factory):
> > diff --git a/unittests/framework/utils.py b/unittests/framework/utils.py
> > index bb3a19146..15117f97d 100644
> > --- a/unittests/framework/utils.py
> > +++ b/unittests/framework/utils.py
> > @@ -32,7 +32,7 @@ from framework.test.base import Test as _Test
> >
> >
> >  class Test(_Test):
> > -    """A Test dericed class with a stub interpret_result.
> > +    """A Test derived class with a stub interpret_result.
> >
> >      This class provides a way to test the Test class.
> >      """
> > --
> > 2.18.0
> >
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
>