summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2016-09-16 13:40:18 -0700
committerDylan Baker <dylan@pnwbakers.com>2016-09-16 13:40:18 -0700
commitf07654a8362afa9fb451af3d79c2c67f647a4bf8 (patch)
tree2608c0ef0997b24de14051191ca4695faf4d6da0
parentf3be91c93f569f56cc0691d67ac53766ade0b1f5 (diff)
unittests: Add test for DriverClassifier.get_glxinfo
Ensure that it converts bytes to str and also collects correctly. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r--unittests/framework/test_driver_classifier.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/unittests/framework/test_driver_classifier.py b/unittests/framework/test_driver_classifier.py
index a4b043a13..4c208421f 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'