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

Dylan Baker dylan at pnwbakers.com
Fri Sep 16 20:46:04 UTC 2016


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



More information about the Piglit mailing list