[Piglit] [PATCH 33/49] unittests: port test_lists to pytest

Dylan Baker dylan at pnwbakers.com
Fri Jul 29 18:39:19 UTC 2016


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 tox.ini                                            |  4 +-
 unittests/suites/__init__.py                       |  0
 unittests/{test_lists.py => suites/test_native.py} | 48 +++++++++++-----------
 3 files changed, 26 insertions(+), 26 deletions(-)
 create mode 100644 unittests/suites/__init__.py
 rename unittests/{test_lists.py => suites/test_native.py} (64%)

diff --git a/tox.ini b/tox.ini
index 7bc9430..5ea976a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -31,6 +31,6 @@ deps =
     wrapt
     {accel,noaccel}: nose 
 commands = 
-    {accel,noaccel}: nosetests unittests -e generators -e framework []
-    {accel,noaccel}: py.test -rw unittests/framework
+    {accel,noaccel}: nosetests unittests -e generators -e framework -e suites []
+    {accel,noaccel}: py.test -rw unittests/framework unittests/suites
     generator: py.test -rw unittests/generators
diff --git a/unittests/suites/__init__.py b/unittests/suites/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/unittests/test_lists.py b/unittests/suites/test_native.py
similarity index 64%
rename from unittests/test_lists.py
rename to unittests/suites/test_native.py
index 7707e64..6055bf6 100644
--- a/unittests/test_lists.py
+++ b/unittests/suites/test_native.py
@@ -30,27 +30,27 @@ from __future__ import (
     absolute_import, division, print_function, unicode_literals
 )
 import importlib
-import os.path as path
-
-from nose.plugins.skip import SkipTest
-
-from . import utils
-
-
- at utils.nose.generator
-def gen_test_import():
-    """ Generates a bunch of tests to import the various test modules """
-    def check_import(module):
-        """ Test that a module can be imported """
-        if not path.exists('bin'):
-            raise SkipTest(
-                "Piglit has not been compiled, this test will not work")
-
-        importlib.import_module(module)
-
-    # Test the various OpenGL modules
-    for module in ['all', 'quick', 'gpu', 'sanity', 'cpu', 'llvmpipe', 'cl',
-                   'quick_cl', 'shader', 'glslparser']:
-        check_import.description = \
-            "tests.{}: Can be successfully imported".format(module)
-        yield check_import, "tests." + module
+import os.path
+
+import pytest
+
+MODULES = [
+    'all',
+    pytest.mark.skipif(not os.path.exists('generated_tests/cl/builtin'),
+                       reason='Requires that CL functionality is built')('cl'),
+    'cpu',
+    'glslparser',
+    'gpu',
+    'llvmpipe',
+    'quick',
+    'shader',
+]
+
+
+ at pytest.mark.parametrize('name', MODULES)
+ at pytest.mark.skipif(not os.path.exists('bin'),
+                    reason='This test requires the C layer to be built.')
+def test_import(name):
+    """Test that each built-in module can be imported."""
+
+    importlib.import_module('tests.{}'.format(name))
-- 
2.9.0



More information about the Piglit mailing list