[Piglit] [PATCH 1/2] unittests: Add test for DriverClassifier.get_glxinfo

Dylan Baker dylan at pnwbakers.com
Fri Sep 16 22:48:50 UTC 2016


piglit is broken on python3 without these, I'm planning to push soon.

Quoting Dylan Baker (2016-09-16 13:46:04)
> Ensure that it converts bytes to str and also collects correctly.
> 
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>  unittests/framework/test_driver_classifier.py | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/unittests/framework/test_driver_classifier.py b/unittests/framework/test_driver_classifier.py
> index a4b043a..4c20842 100644
> --- a/unittests/framework/test_driver_classifier.py
> +++ b/unittests/framework/test_driver_classifier.py
> @@ -19,10 +19,23 @@
>  # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
>  # IN THE SOFTWARE.
>  
> +"""Tests for the driver_classifier module."""
> +
> +from __future__ import (
> +    absolute_import, division, print_function, unicode_literals
> +)
> +
> +try:
> +    import mock
> +except ImportError:
> +    from unittest import mock
> +
>  import pytest
>  import six
> +
>  from framework import driver_classifier
>  
> +
>  class DriverClassifierTester(driver_classifier.DriverClassifier):
>      """Test class for the driver classifier, taking in a fixed
>  
> @@ -58,3 +71,15 @@ class TestDriverClassifier(object):
>          categories list comes back.
>          """
>          assert DriverClassifierTester(renderer).categories == categories
> +
> +    def test_collect_glxinfo(self):
> +        """Should set self.renderer."""
> +        test = driver_classifier.DriverClassifier()
> +        with mock.patch('framework.driver_classifier.subprocess.check_output',
> +                        mock.Mock(return_value=b'some data\nand some more\n'
> +                                               b'OpenGL renderer string: '
> +                                               b'sentinal\nand some other '
> +                                               b'stuff')):
> +            test.collect_glxinfo()
> +        assert isinstance(test.renderer, six.text_type)
> +        assert test.renderer == 'sentinal'
> -- 
> 2.9.3
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20160916/4639ad02/attachment.sig>


More information about the Piglit mailing list