[Piglit] [PATCH 04/20] unittests: split utils module
Dylan Baker
dylan at pnwbakers.com
Wed Jun 1 23:50:11 UTC 2016
---
unittests/backends_tests.py | 16 +--
unittests/base_tests.py | 35 +++---
unittests/compressed_backend_tests.py | 54 ++++-----
unittests/core_tests.py | 30 ++---
unittests/deqp_tests.py | 26 ++---
unittests/dmesg_tests.py | 6 +-
unittests/exceptions_tests.py | 2 +-
unittests/generators/test_generators.py | 6 +-
unittests/generators/test_glsl.py | 12 +-
unittests/gleantest_tests.py | 6 +-
unittests/glsl_parser_test_tests.py | 44 ++++----
unittests/grouptools_tests.py | 4 +-
unittests/gtest_tests.py | 2 +-
unittests/json_backend_tests.py | 54 ++++-----
unittests/json_results_update_tests.py | 32 +++---
unittests/json_tests.py | 18 +--
unittests/junit_backends_tests.py | 34 +++---
unittests/log_tests.py | 8 +-
unittests/monitoring_tests.py | 16 +--
unittests/oglconform_tests.py | 4 +-
unittests/opencv_tests.py | 2 +-
unittests/opengl_tests.py | 52 ++++-----
unittests/options_tests.py | 2 +-
unittests/piglit_test_tests.py | 8 +-
unittests/profile_tests.py | 72 ++++++------
unittests/results_tests.py | 8 +-
unittests/run_parser_tests.py | 14 +--
unittests/shader_test_tests.py | 10 +-
unittests/status_tests.py | 22 ++--
unittests/summary_common_tests.py | 6 +-
unittests/summary_console_tests.py | 2 +-
unittests/summary_html_tests.py | 2 +-
unittests/test_lists.py | 2 +-
unittests/utils/__init__.py | 1 +
unittests/{utils.py => utils/nose.py} | 180 +++---------------------------
unittests/utils/piglit.py | 189 ++++++++++++++++++++++++++++++++
36 files changed, 508 insertions(+), 473 deletions(-)
create mode 100644 unittests/utils/__init__.py
rename unittests/{utils.py => utils/nose.py} (70%)
create mode 100644 unittests/utils/piglit.py
diff --git a/unittests/backends_tests.py b/unittests/backends_tests.py
index 81466ec..41eb5b6 100644
--- a/unittests/backends_tests.py
+++ b/unittests/backends_tests.py
@@ -67,7 +67,7 @@ def _registry_teardown():
# Tests
- at utils.nose_generator
+ at utils.nose.generator
def test_get_backend():
""" Generate tests to get various backends """
# We use a hand generated list here to ensure that we are getting what we
@@ -101,7 +101,7 @@ def test_get_backend_notimplemented():
@nt.with_setup(teardown=_registry_teardown)
- at utils.test_in_tempdir
+ at utils.nose.test_in_tempdir
def test_load():
"""backends.load(): works as expected.
@@ -130,7 +130,7 @@ def test_load():
@nt.raises(backends.BackendError)
- at utils.test_in_tempdir
+ at utils.nose.test_in_tempdir
def test_load_unknown():
"""backends.load(): An error is raised if no modules supportes `extension`
"""
@@ -141,9 +141,9 @@ def test_load_unknown():
backends.load(file_path)
- at utils.no_error
+ at utils.nose.no_error
@nt.with_setup(_notimplemented_setup, _registry_teardown)
- at utils.test_in_tempdir
+ at utils.nose.test_in_tempdir
def test_load_resume():
"""backends.load: works for resuming (no extension known)."""
backends.BACKENDS['test_backend'] = backends.register.Registry(
@@ -162,7 +162,7 @@ def test_load_resume():
@nt.raises(backends.BackendNotImplementedError)
@nt.with_setup(_notimplemented_setup, _registry_teardown)
- at utils.test_in_tempdir
+ at utils.nose.test_in_tempdir
def test_load_notimplemented():
"""backends.load(): An error is raised if a loader isn't properly implmented.
"""
@@ -204,7 +204,7 @@ def test_set_meta_notimplemented():
@nt.with_setup(_notimplemented_setup, _registry_teardown)
@nt.raises(backends.BackendNotImplementedError)
- at utils.not_raises(backends.BackendError)
+ at utils.nose.not_raises(backends.BackendError)
def test_load_trailing_dot():
"""framework.backends.load: handles the result name ending in '.'
@@ -217,7 +217,7 @@ def test_load_trailing_dot():
@nt.with_setup(_notimplemented_setup, _registry_teardown)
- at utils.test_in_tempdir
+ at utils.nose.test_in_tempdir
@nt.raises(backends.BackendError)
def test_load_old():
"""backends.load(): Ignores files ending in '.old'
diff --git a/unittests/base_tests.py b/unittests/base_tests.py
index f788b60..1933d71 100644
--- a/unittests/base_tests.py
+++ b/unittests/base_tests.py
@@ -35,7 +35,6 @@ except ImportError:
import six
import nose.tools as nt
from nose.plugins.attrib import attr
-import six
try:
import psutil
@@ -78,7 +77,7 @@ class TimeoutTest(Test):
def test_run_return_early():
""" Test.run() exits early when Test._run_command() has exception """
def helper():
- raise utils.TestFailure("The test didn't return early")
+ raise utils.nose.TestFailure("The test didn't return early")
# Of course, this won't work if you actually have a foobarcommand in your
# path...
@@ -98,9 +97,9 @@ def test_timeout_kill_children():
This test could leave processes running if it fails.
"""
- utils.module_check('psutil')
+ utils.nose.module_check('psutil')
if six.PY2:
- utils.module_check('subprocess32')
+ utils.nose.module_check('subprocess32')
import subprocess32 as subprocess # pylint: disable=import-error
elif six.PY3:
import subprocess
@@ -169,7 +168,7 @@ def test_timeout_kill_children():
for child in reversed(children):
child.kill()
- raise utils.TestFailure(
+ raise utils.nose.TestFailure(
'Test process had children when it should not')
@@ -183,8 +182,8 @@ def test_timeout():
"""
if six.PY2:
- utils.module_check('subprocess32')
- utils.binary_check('sleep', 1)
+ utils.nose.module_check('subprocess32')
+ utils.nose.binary_check('sleep', 1)
test = TimeoutTest(['sleep', '60'])
test.timeout = 1
@@ -196,8 +195,8 @@ def test_timeout():
def test_timeout_timeout():
"""test.base.Test: Sets status to 'timeout' when timeout exceeded"""
if six.PY2:
- utils.module_check('subprocess32')
- utils.binary_check('sleep', 1)
+ utils.nose.module_check('subprocess32')
+ utils.nose.binary_check('sleep', 1)
test = TimeoutTest(['sleep', '60'])
test.timeout = 1
@@ -210,8 +209,8 @@ def test_timeout_pass():
"""test.base.Test: Doesn't change status when timeout not exceeded
"""
if six.PY2:
- utils.module_check('subprocess32')
- utils.binary_check('true')
+ utils.nose.module_check('subprocess32')
+ utils.nose.binary_check('true')
test = TimeoutTest(['true'])
test.timeout = 1
@@ -254,7 +253,7 @@ def test_run_command_early():
"""
class Test_(Test):
def interpret_result(self):
- raise utils.TestFailure("The test didn't return early")
+ raise utils.nose.TestFailure("The test didn't return early")
def _run_command(self):
raise TestRunError('an error', 'skip')
@@ -299,7 +298,7 @@ def test_mutation():
@mock.patch('framework.test.base.options.OPTIONS', new_callable=Options)
def test_ValgrindMixin_command(mock_opts):
"""test.base.ValgrindMixin.command: overrides self.command"""
- class _Test(ValgrindMixin, utils.Test):
+ class _Test(ValgrindMixin, utils.piglit.Test):
pass
mock_opts.valgrind = True
@@ -311,7 +310,7 @@ def test_ValgrindMixin_command(mock_opts):
class TestValgrindMixinRun(object):
@classmethod
def setup_class(cls):
- class _NoRunTest(utils.Test):
+ class _NoRunTest(utils.piglit.Test):
def run(self):
self.interpret_result()
@@ -320,7 +319,7 @@ class TestValgrindMixinRun(object):
cls.test = _Test
- @utils.nose_generator
+ @utils.nose.generator
def test_bad_valgrind_true(self):
"""Test non-pass status when options.OPTIONS.valgrind is True."""
def test(status, expected):
@@ -341,7 +340,7 @@ class TestValgrindMixinRun(object):
test.description = desc.format(status, 'skip')
yield test, status, 'skip'
- @utils.nose_generator
+ @utils.nose.generator
def test_valgrind_false(self):
"""Test non-pass status when options.OPTIONS.valgrind is False."""
def test(status):
@@ -403,10 +402,10 @@ def test_interpret_result_greater_zero():
class TestExecuteTraceback(object):
"""Test.execute tests for Traceback handling."""
@classmethod
- @utils.capture_stderr # The exception will be printed
+ @utils.nose.capture_stderr # The exception will be printed
def setup_class(cls):
test = TestTest(['foo'])
- test.run = mock.Mock(side_effect=utils.SentinalException)
+ test.run = mock.Mock(side_effect=utils.nose.SentinalException)
test.execute(mock.Mock(spec=six.text_type),
mock.Mock(spec=log.BaseLog),
diff --git a/unittests/compressed_backend_tests.py b/unittests/compressed_backend_tests.py
index 270b9b4..c3be896 100644
--- a/unittests/compressed_backend_tests.py
+++ b/unittests/compressed_backend_tests.py
@@ -89,7 +89,7 @@ def _add_compression(value):
def _test_compressor(mode):
"""Helper to simplify testing compressors."""
func = compression.COMPRESSORS[mode]
- with utils.tempdir() as t:
+ with utils.nose.tempdir() as t:
with func(os.path.join(t, 'file')) as f:
f.write('foo')
@@ -99,7 +99,7 @@ def _test_decompressor(mode):
func = compression.COMPRESSORS[mode]
dec = compression.DECOMPRESSORS[mode]
- with utils.tempdir() as t:
+ with utils.nose.tempdir() as t:
path = os.path.join(t, 'file')
with func(path) as f:
@@ -111,7 +111,7 @@ def _test_decompressor(mode):
def _test_extension():
"""Create an final file and return the extension."""
- with utils.tempdir() as d:
+ with utils.nose.tempdir() as d:
obj = _TestBackend(d)
obj.initialize()
with obj.write_test('foo') as t:
@@ -123,11 +123,11 @@ def _test_extension():
if each.startswith('results.txt'):
name, ext = os.path.splitext(each)
if name.endswith('.'):
- raise utils.TestFailure(
+ raise utils.nose.TestFailure(
'extra trailing "." in name "{}"'.format(name))
break
else:
- raise utils.TestFailure('No results file generated')
+ raise utils.nose.TestFailure('No results file generated')
return ext
@@ -135,7 +135,7 @@ def _test_extension():
# Tests
- at utils.no_error
+ at utils.nose.no_error
def test_compress_none():
"""framework.backends.compression: can compress to 'none'"""
_test_compressor('none')
@@ -148,28 +148,28 @@ def test_decompress_none():
@_add_compression('foobar')
- at utils.set_env(PIGLIT_COMPRESSION='foobar')
+ at utils.nose.set_env(PIGLIT_COMPRESSION='foobar')
def testget_mode_env():
"""framework.backends.compression.get_mode: uses PIGlIT_COMPRESSION environment variable"""
nt.eq_(compression.get_mode(), 'foobar')
@_add_compression('foobar')
- at utils.set_env(PIGLIT_COMPRESSION=None)
- at utils.set_piglit_conf(('core', 'compression', 'foobar'))
+ at utils.nose.set_env(PIGLIT_COMPRESSION=None)
+ at utils.piglit.set_piglit_conf(('core', 'compression', 'foobar'))
def testget_mode_piglit_conf():
"""framework.backends.compression.get_mode: uses piglit.conf [core]:compression value if env is unset"""
nt.eq_(compression.get_mode(), 'foobar')
- at utils.set_env(PIGLIT_COMPRESSION=None)
- at utils.set_piglit_conf(('core', 'compression', None))
+ at utils.nose.set_env(PIGLIT_COMPRESSION=None)
+ at utils.piglit.set_piglit_conf(('core', 'compression', None))
def testget_mode_default():
"""framework.backends.compression.get_mode: uses DEFAULT if env and piglit.conf are unset"""
nt.eq_(compression.get_mode(), compression.DEFAULT)
- at utils.no_error
+ at utils.nose.no_error
def test_compress_gz():
"""framework.backends.compression: can compress to 'gz'"""
_test_compressor('gz')
@@ -180,13 +180,13 @@ def test_decompress_gz():
_test_decompressor('gz')
- at utils.set_env(PIGLIT_COMPRESSION='gz')
+ at utils.nose.set_env(PIGLIT_COMPRESSION='gz')
def test_gz_output():
"""framework.backends: when using gz compression a gz file is created"""
nt.eq_(_test_extension(), '.gz')
- at utils.no_error
+ at utils.nose.no_error
def test_compress_bz2():
"""framework.backends.compression: can compress to 'bz2'"""
_test_compressor('bz2')
@@ -197,13 +197,13 @@ def test_decompress_bz2():
_test_decompressor('bz2')
- at utils.set_env(PIGLIT_COMPRESSION='bz2')
+ at utils.nose.set_env(PIGLIT_COMPRESSION='bz2')
def test_bz2_output():
"""framework.backends: when using bz2 compression a bz2 file is created"""
nt.eq_(_test_extension(), '.bz2')
- at utils.no_error
+ at utils.nose.no_error
def test_compress_xz():
"""framework.backends.compression: can compress to 'xz'"""
_test_compressor('xz')
@@ -214,15 +214,15 @@ def test_decompress_xz():
_test_decompressor('xz')
- at utils.set_env(PIGLIT_COMPRESSION='xz')
+ at utils.nose.set_env(PIGLIT_COMPRESSION='xz')
def test_xz_output():
"""framework.backends: when using xz compression a xz file is created"""
nt.eq_(_test_extension(), '.xz')
@_add_compression('foobar')
- at utils.set_env(PIGLIT_COMPRESSION=None)
- at utils.set_piglit_conf(('core', 'compression', 'foobar'))
+ at utils.nose.set_env(PIGLIT_COMPRESSION=None)
+ at utils.piglit.set_piglit_conf(('core', 'compression', 'foobar'))
def test_update_piglit_conf():
"""framework.backends.compression: The compression mode honors updates to piglit.conf.
@@ -233,8 +233,8 @@ def test_update_piglit_conf():
nt.eq_(compression.get_mode(), 'foobar')
- at utils.set_env(PIGLIT_COMPRESSION='xz')
- at utils.test_in_tempdir
+ at utils.nose.set_env(PIGLIT_COMPRESSION='xz')
+ at utils.nose.test_in_tempdir
def test_xz_shell_override():
"""framework.backends.compression: the xz shell utility path can overwrite"""
if six.PY3:
@@ -254,33 +254,33 @@ def test_xz_shell_override():
f.write('foobar')
- at utils.set_piglit_conf(('core', 'compression', 'bz2'))
+ at utils.piglit.set_piglit_conf(('core', 'compression', 'bz2'))
def test_write_compressed_one_suffix_bz2():
"""backends.abstract.write_compressed: bz2 Does not duplicate compression suffixes
"""
- with utils.tempdir() as d:
+ with utils.nose.tempdir() as d:
with abstract.write_compressed(os.path.join(d, 'results.txt.bz2')) as f:
f.write('foo')
nt.eq_(os.listdir(d)[0], 'results.txt.bz2')
- at utils.set_piglit_conf(('core', 'compression', 'gz'))
+ at utils.piglit.set_piglit_conf(('core', 'compression', 'gz'))
def test_write_compressed_one_suffix_gz():
"""backends.abstract.write_compressed: gz Does not duplicate compression suffixes
"""
- with utils.tempdir() as d:
+ with utils.nose.tempdir() as d:
with abstract.write_compressed(os.path.join(d, 'results.txt.gz')) as f:
f.write('foo')
nt.eq_(os.listdir(d)[0], 'results.txt.gz')
- at utils.set_piglit_conf(('core', 'compression', 'gz'))
+ at utils.piglit.set_piglit_conf(('core', 'compression', 'gz'))
def test_write_compressed_one_suffix_mixed():
"""backends.abstract.write_compressed: does not generate two different compression suffixes
"""
- with utils.tempdir() as d:
+ with utils.nose.tempdir() as d:
with abstract.write_compressed(os.path.join(d, 'results.txt.bz2')) as f:
f.write('foo')
diff --git a/unittests/core_tests.py b/unittests/core_tests.py
index 825fb73..4d83e73 100644
--- a/unittests/core_tests.py
+++ b/unittests/core_tests.py
@@ -88,7 +88,7 @@ def _save_core_config(func):
restore_piglitconf = True
core.PIGLIT_CONFIG = core.PiglitConfig(allow_no_value=True)
except Exception as e:
- raise utils.UtilsError(e)
+ raise utils.nose.UtilsError(e)
func(*args, **kwargs)
@@ -104,12 +104,12 @@ def _save_core_config(func):
core.PIGLIT_CONFIG = core.PiglitConfig(
allow_no_value=True)
except Exception as e:
- raise utils.UtilsError(e)
+ raise utils.nose.UtilsError(e)
return inner
- at utils.no_error
+ at utils.nose.no_error
def test_PiglitConfig_init():
"""core.PiglitConfig: initializes"""
core.PiglitConfig()
@@ -124,7 +124,7 @@ def test_parse_listfile_return():
"""
contents = "/tmp/foo\n/tmp/bar\n"
- with utils.tempfile(contents) as tfile:
+ with utils.nose.tempfile(contents) as tfile:
results = core.parse_listfile(tfile)
nt.ok_(isinstance(results, collections.Container))
@@ -135,7 +135,7 @@ class Test_parse_listfile_TrailingWhitespace(object):
@classmethod
def setup_class(cls):
contents = "/tmp/foo\n/tmp/foo \n/tmp/foo\t\n"
- with utils.tempfile(contents) as tfile:
+ with utils.nose.tempfile(contents) as tfile:
cls.results = core.parse_listfile(tfile)
def test_newlines(self):
@@ -166,7 +166,7 @@ def test_parse_listfile_tilde():
contents = "~/foo\n"
expected = os.path.expandvars("$HOME/foo")
- with utils.tempfile(contents) as tfile:
+ with utils.nose.tempfile(contents) as tfile:
results = core.parse_listfile(tfile)
nt.eq_(results[0], expected,
@@ -176,7 +176,7 @@ def test_parse_listfile_tilde():
@_save_core_config
def test_xdg_config_home():
"""core.get_config() finds $XDG_CONFIG_HOME/piglit.conf"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.environ['XDG_CONFIG_HOME'] = tdir
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write(_CONF_FILE)
@@ -189,7 +189,7 @@ def test_xdg_config_home():
@_save_core_config
def test_config_home_fallback():
"""core.get_config() finds $HOME/.config/piglit.conf"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.environ['HOME'] = tdir
os.mkdir(os.path.join(tdir, '.config'))
with open(os.path.join(tdir, '.config/piglit.conf'), 'w') as f:
@@ -201,10 +201,10 @@ def test_config_home_fallback():
@_save_core_config
- at utils.test_in_tempdir
+ at utils.nose.test_in_tempdir
def test_local():
"""core.get_config() finds ./piglit.conf"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.chdir(tdir)
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
@@ -277,7 +277,7 @@ class TestPiglitConfig(object):
nt.eq_(self.conf.safe_get('invalid', 'invalid', fallback='foo'), 'foo')
- at utils.capture_stderr
+ at utils.nose.capture_stderr
@nt.raises(exceptions.PiglitException)
def test_check_dir_exists_fail():
"""core.check_dir: if the directory exists and failifexsits is True fail"""
@@ -303,7 +303,7 @@ def test_check_dir_stat_ENOTDIR():
nt.eq_(makedirs.called, 1)
- at utils.not_raises(OSError)
+ at utils.nose.not_raises(OSError)
def test_check_dir_makedirs_pass():
"""core.check_dir: If makedirs fails with EEXIST pass"""
with mock.patch('framework.core.os.stat', mock.Mock()):
@@ -323,16 +323,16 @@ def test_check_dir_makedirs_fail():
core.check_dir('foo', False)
- at nt.raises(utils.SentinalException)
+ at nt.raises(utils.nose.SentinalException)
def test_check_dir_handler():
"""core.check_dir: Handler is called if not failifexists."""
with mock.patch('framework.core.os.stat',
mock.Mock(side_effect=OSError('foo', errno.ENOTDIR))):
core.check_dir('foo',
- handler=mock.Mock(side_effect=utils.SentinalException))
+ handler=mock.Mock(side_effect=utils.nose.SentinalException))
- at utils.skip(not six.PY3, 'Test is only relevant on python 3.x')
+ at utils.nose.skip(not six.PY3, 'Test is only relevant on python 3.x')
def test_check_dir_stat_FileNotFoundError():
"""core.check_dir: FileNotFoundError is raised and failifexsits is False continue"""
with mock.patch('framework.core.os.stat',
diff --git a/unittests/deqp_tests.py b/unittests/deqp_tests.py
index 7119fed..b0e314f 100644
--- a/unittests/deqp_tests.py
+++ b/unittests/deqp_tests.py
@@ -44,7 +44,7 @@ from . import utils
# pylint:disable=line-too-long,invalid-name
-doc_formatter = utils.DocFormatter({'separator': grouptools.SEPARATOR})
+doc_formatter = utils.nose.DocFormatter({'separator': grouptools.SEPARATOR})
class _DEQPTestTest(deqp.DEQPBaseTest):
@@ -52,23 +52,23 @@ class _DEQPTestTest(deqp.DEQPBaseTest):
extra_args = ['extra']
- at utils.set_piglit_conf(('deqp_test', 'test_env', 'from conf'))
- at utils.set_env(_PIGLIT_TEST_ENV='from env')
+ at utils.piglit.set_piglit_conf(('deqp_test', 'test_env', 'from conf'))
+ at utils.nose.set_env(_PIGLIT_TEST_ENV='from env')
def test_get_option_env():
"""deqp.get_option: if env is set it overrides piglit.conf"""
nt.eq_(deqp.get_option('_PIGLIT_TEST_ENV', ('deqp_test', 'test_env')),
'from env')
- at utils.set_piglit_conf(('deqp_test', 'test_env', 'from conf'))
- at utils.set_env(_PIGLIT_TEST_ENV=None)
+ at utils.piglit.set_piglit_conf(('deqp_test', 'test_env', 'from conf'))
+ at utils.nose.set_env(_PIGLIT_TEST_ENV=None)
def test_get_option_conf():
"""deqp.get_option: if env is not set a value is taken from piglit.conf"""
nt.eq_(deqp.get_option('_PIGLIT_TEST_ENV', ('deqp_test', 'test_env')),
'from conf')
- at utils.set_env(_PIGLIT_TEST_ENV=None)
+ at utils.nose.set_env(_PIGLIT_TEST_ENV=None)
def test_get_option_default():
"""deqp.get_option: default value is returned when env and conf are unset
"""
@@ -77,7 +77,7 @@ def test_get_option_default():
'foobar')
- at utils.set_env(_PIGLIT_TEST_ENV=None)
+ at utils.nose.set_env(_PIGLIT_TEST_ENV=None)
def test_get_option_conf_no_section():
"""deqp.get_option: if a no_section error is raised and env is unset None is return
"""
@@ -85,9 +85,9 @@ def test_get_option_conf_no_section():
# The first argument ensures the sectio exists
- at utils.set_piglit_conf(('deqp_test', 'test_env', 'from conf'),
+ at utils.piglit.set_piglit_conf(('deqp_test', 'test_env', 'from conf'),
('deqp_test', 'not_exists', None))
- at utils.set_env(_PIGLIT_TEST_ENV=None)
+ at utils.nose.set_env(_PIGLIT_TEST_ENV=None)
def test_get_option_conf_no_option():
"""deqp.get_option: if a no_option error is raised and env is unset None is return
"""
@@ -114,14 +114,14 @@ class TestMakeProfile(object):
def test_iter_deqp_test_cases_test():
"""deqp.iter_deqp_test_cases: correctly detects a TEST: line"""
- with utils.tempfile('TEST: a.deqp.test') as tfile:
+ with utils.nose.tempfile('TEST: a.deqp.test') as tfile:
gen = deqp.iter_deqp_test_cases(tfile)
nt.eq_('a.deqp.test', next(gen))
def test_iter_deqp_test_cases_group():
"""deqp.iter_deqp_test_casesgen_caselist_txt: correctly detects a GROUP: line"""
- with utils.tempfile('GROUP: a group\nTEST: a.deqp.test') as tfile:
+ with utils.nose.tempfile('GROUP: a group\nTEST: a.deqp.test') as tfile:
gen = deqp.iter_deqp_test_cases(tfile)
nt.eq_('a.deqp.test', next(gen))
@@ -130,12 +130,12 @@ def test_iter_deqp_test_cases_group():
def test_iter_deqp_test_cases_bad():
"""deqp.iter_deqp_test_casesgen_caselist_txt: PiglitFatalException is raised if line is not TEST: or GROUP:
"""
- with utils.tempfile('this will fail') as tfile:
+ with utils.nose.tempfile('this will fail') as tfile:
gen = deqp.iter_deqp_test_cases(tfile)
nt.eq_('a.deqp.test', next(gen))
- at utils.no_error
+ at utils.nose.no_error
def test_DEQPBaseTest_initialize():
"""deqp.DEQPBaseTest: can be initialized (with abstract methods overwritten)
"""
diff --git a/unittests/dmesg_tests.py b/unittests/dmesg_tests.py
index b2f537c..0b0490d 100644
--- a/unittests/dmesg_tests.py
+++ b/unittests/dmesg_tests.py
@@ -170,7 +170,7 @@ def test_update_result_regex_match():
nt.assert_not_equal(result.result, 'pass')
- at utils.nose_generator
+ at utils.nose.generator
def test_update_result_specific():
"""Generator that tests specific result mappings."""
dmesg_ = TestDmesg()
@@ -191,7 +191,7 @@ def test_update_result_specific():
yield test, initial, expected
- at utils.nose_generator
+ at utils.nose.generator
def test_linuxdmesg_gzip_errors():
"""Generator to test exceptions that need to be passed when reading
config.gz.
@@ -280,7 +280,7 @@ def test_dummydmesg_update_result():
nt.eq_(result.result, mock.sentinel.result)
- at utils.nose_generator
+ at utils.nose.generator
def test_get_dmesg():
"""Generate tests for get_dmesg."""
tests = [
diff --git a/unittests/exceptions_tests.py b/unittests/exceptions_tests.py
index 72d39b8..7b40933 100644
--- a/unittests/exceptions_tests.py
+++ b/unittests/exceptions_tests.py
@@ -31,7 +31,7 @@ from framework import exceptions
@nt.raises(SystemExit)
- at utils.capture_stderr
+ at utils.nose.capture_stderr
@exceptions.handler
def test_handle_PiglitFatalError():
"""exceptions.handler: Handles PiglitFatalError"""
diff --git a/unittests/generators/test_generators.py b/unittests/generators/test_generators.py
index 6e93d91..9ad0aaf 100644
--- a/unittests/generators/test_generators.py
+++ b/unittests/generators/test_generators.py
@@ -69,11 +69,11 @@ def discover_generators():
return contents
- at utils.nose_generator
+ at utils.nose.generator
def test_generators():
"""Generate tests for the various generators."""
- @utils.test_in_tempdir
+ @utils.nose.test_in_tempdir
def test(name):
"""Tester function."""
msg = ''
@@ -87,7 +87,7 @@ def test_generators():
if proc.returncode != 0:
err = err.decode('utf-8')
- raise utils.TestFailure(
+ raise utils.nose.TestFailure(
"failed with message:\n {}".format(err))
description = 'generator: {} runs successfully'
diff --git a/unittests/generators/test_glsl.py b/unittests/generators/test_glsl.py
index c587997..84802c2 100644
--- a/unittests/generators/test_glsl.py
+++ b/unittests/generators/test_glsl.py
@@ -96,7 +96,7 @@ class TestCompare(object):
('>', operator.gt),
]
- @utils.nose_generator
+ @utils.nose.generator
def test_glsl_glsl(self):
"""Test GLSLVersion <cmp> GLSLVersion."""
def expected(first, second, op):
@@ -113,7 +113,7 @@ class TestCompare(object):
test.description = desc.format(ver1, name, ver2)
yield test, ver1, ver2, op
- @utils.nose_generator
+ @utils.nose.generator
def test_glsles_glsles(self):
"""Test GLSLESVersion <cmp> GLSLESVersion."""
def expected(first, second, op):
@@ -141,7 +141,7 @@ class TestCompare(object):
"""generated_tests.modules.glsl: GLSLESVersion <cmp> GLSLVersion."""
return glsl.Version('100') < glsl.Version('110')
- @utils.nose_generator
+ @utils.nose.generator
def test_glsl_int(self):
"""Test GLSLVersion <cmp> GLSLVersion."""
def expected(first, second, op):
@@ -168,7 +168,7 @@ class TestCompare(object):
yield (test, int(ver1), glsl.Version(ver2), op,
expected(ver1, ver2, op))
- @utils.nose_generator
+ @utils.nose.generator
def test_glsl_float(self):
"""Test GLSLVersion <cmp> GLSLVersion."""
def expected(first, second, op):
@@ -195,7 +195,7 @@ class TestCompare(object):
yield (test, float(ver1) / 100, glsl.Version(ver2), op,
expected(ver1, ver2, op))
- @utils.nose_generator
+ @utils.nose.generator
def test_glsles_int(self):
"""Test GLSLESVersion <cmp> GLSLESVersion."""
def expected(first, second, op):
@@ -224,7 +224,7 @@ class TestCompare(object):
yield (test, int(ver1[:3]), glsl.Version(ver2), op,
expected(ver1, ver2, op))
- @utils.nose_generator
+ @utils.nose.generator
def test_glsles_float(self):
"""Test GLSLESVersion <cmp> GLSLESVersion."""
def expected(first, second, op):
diff --git a/unittests/gleantest_tests.py b/unittests/gleantest_tests.py
index e0e3902..bac37e6 100644
--- a/unittests/gleantest_tests.py
+++ b/unittests/gleantest_tests.py
@@ -37,7 +37,7 @@ from . import utils
from framework.test.base import TestIsSkip
- at utils.no_error
+ at utils.nose.no_error
def test_initialize_gleantest():
"""test.gleantest.GleanTest: class initializes correctly"""
GleanTest('name')
@@ -87,7 +87,7 @@ def test_is_skip_not_glx(mock_opts):
@mock.patch('framework.test.gleantest.options.OPTIONS', new_callable=Options)
- at utils.not_raises(TestIsSkip)
+ at utils.nose.not_raises(TestIsSkip)
def test_is_skip_glx(mock_opts):
"""test.gleantest.GleanTest.is_skip: Does not skip when platform is glx"""
mock_opts.env['PIGLIT_PLATFORM'] = 'glx'
@@ -96,7 +96,7 @@ def test_is_skip_glx(mock_opts):
@mock.patch('framework.test.gleantest.options.OPTIONS', new_callable=Options)
- at utils.not_raises(TestIsSkip)
+ at utils.nose.not_raises(TestIsSkip)
def test_is_skip_glx_egl(mock_opts):
"""test.gleantest.GleanTest.is_skip: Does not skip when platform is mixed_glx_egl
"""
diff --git a/unittests/glsl_parser_test_tests.py b/unittests/glsl_parser_test_tests.py
index 7fb9902..c66e998 100644
--- a/unittests/glsl_parser_test_tests.py
+++ b/unittests/glsl_parser_test_tests.py
@@ -71,7 +71,7 @@ teardown = _setup.teardown
def _check_config(content):
""" This is the test that actually checks the glsl config section """
- with utils.tempfile(content) as tfile:
+ with utils.nose.tempfile(content) as tfile:
return glsl.GLSLParserTest(tfile), tfile
@@ -81,7 +81,7 @@ def test_no_config_start():
content = ('// expect_result: pass\n'
'// glsl_version: 1.10\n'
'// [end config]\n')
- with utils.tempfile(content) as tfile:
+ with utils.nose.tempfile(content) as tfile:
with nt.assert_raises(glsl.GLSLParserNoConfigError) as exc:
glsl.GLSLParserTest(tfile)
nt.assert_equal(
@@ -96,7 +96,7 @@ def test_find_config_start():
content = ('// [config]\n'
'// glsl_version: 1.10\n'
'//\n')
- with utils.tempfile(content) as tfile:
+ with utils.nose.tempfile(content) as tfile:
glsl.GLSLParserTest(tfile)
@@ -104,7 +104,7 @@ def test_find_config_start():
def test_no_config_end():
"""test.glsl_parser_test.GLSLParserTest: exception is raised if [end config] section is missing
"""
- with utils.tempfile('// [config]\n') as tfile:
+ with utils.nose.tempfile('// [config]\n') as tfile:
glsl.GLSLParserTest(tfile)
@@ -115,7 +115,7 @@ def test_no_expect_result():
content = ('// [config]\n'
'// glsl_version: 1.10\n'
'//\n')
- with utils.tempfile(content) as tfile:
+ with utils.nose.tempfile(content) as tfile:
glsl.GLSLParserTest(tfile)
@@ -126,7 +126,7 @@ def test_no_glsl_version():
content = ('// [config]\n'
'// expect_result: pass\n'
'// [end config]\n')
- with utils.tempfile(content) as tfile:
+ with utils.nose.tempfile(content) as tfile:
glsl.GLSLParserTest(tfile)
@@ -205,7 +205,7 @@ def test_glslparser_initializer():
*/
""")
- with utils.tempfile(content) as f:
+ with utils.nose.tempfile(content) as f:
glsl.GLSLParserTest(f)
@@ -217,7 +217,7 @@ def check_config_to_command(config, result):
nt.eq_(inst.command, result)
- at utils.nose_generator
+ at utils.nose.generator
def test_config_to_command():
""" Generate tests that confirm the config file is correctly parsed """
content = [
@@ -254,11 +254,11 @@ def test_bad_section_name():
'// new_awesome_key: foo\n'
'// [end config]\n')
- with utils.tempfile(content) as tfile:
+ with utils.nose.tempfile(content) as tfile:
glsl.GLSLParserTest(tfile)
- at utils.not_raises(exceptions.PiglitFatalError)
+ at utils.nose.not_raises(exceptions.PiglitFatalError)
def test_good_section_names():
"""test.glsl_parser_test.GLSLParserTest: A section name in the _CONFIG_KEYS does not raise an error"""
content = ('// [config]\n'
@@ -271,14 +271,14 @@ def test_good_section_names():
_check_config(content)
- at utils.nose_generator
+ at utils.nose.generator
def test_duplicate_entries():
""" Generate tests for duplicate keys in the config block """
@nt.raises(exceptions.PiglitFatalError)
def check_no_duplicates(content):
""" Ensure that duplicate entries raise an error """
- with utils.tempfile(content) as tfile:
+ with utils.nose.tempfile(content) as tfile:
glsl.GLSLParserTest(tfile)
@@ -298,7 +298,7 @@ def test_duplicate_entries():
yield check_no_duplicates, test
- at utils.nose_generator
+ at utils.nose.generator
def glslparser_exetensions_seperators():
""" GlslParserTest() can only have [A-Za-z_] as characters
@@ -327,18 +327,18 @@ def glslparser_exetensions_seperators():
for name, value in problems:
test = content.format(value)
- with utils.tempfile(test) as tfile:
+ with utils.nose.tempfile(test) as tfile:
check_bad_character.description = (
'test.glsl_parser_test.GLSLParserTest: require_extensions {0} '
'should raise an error'.format(name))
yield check_bad_character, tfile
- at utils.nose_generator
+ at utils.nose.generator
def test_good_extensions():
""" Generates tests with good extensions which shouldn't raise errors """
- @utils.not_raises(exceptions.PiglitFatalError)
+ @utils.nose.not_raises(exceptions.PiglitFatalError)
def check_good_extension(file_):
""" A good extension should not raise a GLSLParserException """
glsl.GLSLParserTest(file_)
@@ -360,15 +360,15 @@ def test_good_extensions():
'test.glsl_parser_test.GLSLParserTest: '
'require_extension {} is valid'.format(x))
- with utils.tempfile(test) as tfile:
+ with utils.nose.tempfile(test) as tfile:
yield check_good_extension, tfile
- at utils.nose_generator
+ at utils.nose.generator
def test_get_glslparsertest_gles2():
"""GLSLParserTest: gets gles2 binary if glsl is 1.00 or 3.00"""
def test(content, expected):
- with utils.tempfile(content) as f:
+ with utils.nose.tempfile(content) as f:
t = glsl.GLSLParserTest(f)
nt.eq_(os.path.basename(t.command[0]), expected)
@@ -485,12 +485,12 @@ def test_binary_skip():
*/
""")
- with utils.tempfile(content) as f:
+ with utils.nose.tempfile(content) as f:
test = glsl.GLSLParserTest(f)
test.is_skip()
- at utils.nose_generator
+ at utils.nose.generator
def test_add_compatability():
"""test.glsl_parser_test.GLSLParserTest: Adds ARB_ES<ver>_COMPATIBILITY
when shader is gles but only gl is available"""
@@ -506,7 +506,7 @@ def test_add_compatability():
@mock.patch('framework.test.glsl_parser_test._HAS_GLES_BIN', False)
def test(ver, expected):
- with utils.tempfile(content.format(ver)) as f:
+ with utils.nose.tempfile(content.format(ver)) as f:
test = glsl.GLSLParserTest(f)
nt.assert_in(expected, test.gl_required)
diff --git a/unittests/grouptools_tests.py b/unittests/grouptools_tests.py
index 3a3b2d0..9b52884 100644
--- a/unittests/grouptools_tests.py
+++ b/unittests/grouptools_tests.py
@@ -29,12 +29,12 @@ import nose.tools as nt
import framework.grouptools as grouptools
from . import utils
-doc_formatter = utils.DocFormatter({ # pylint: disable=invalid-name
+doc_formatter = utils.nose.DocFormatter({ # pylint: disable=invalid-name
'separator': grouptools.SEPARATOR,
})
- at utils.nose_generator
+ at utils.nose.generator
def generate_tests():
"""Generate tests for the groups tools module.
diff --git a/unittests/gtest_tests.py b/unittests/gtest_tests.py
index 568d649..4e4b516 100644
--- a/unittests/gtest_tests.py
+++ b/unittests/gtest_tests.py
@@ -30,7 +30,7 @@ from . import utils
from framework.test import GTest
- at utils.no_error
+ at utils.nose.no_error
def test_initialize_gtest():
"""test.gtest.GTest: Class initializes"""
GTest(['/bin/true'])
diff --git a/unittests/json_backend_tests.py b/unittests/json_backend_tests.py
index 7d76b74..cf19d30 100644
--- a/unittests/json_backend_tests.py
+++ b/unittests/json_backend_tests.py
@@ -39,11 +39,11 @@ from .backends_tests import BACKEND_INITIAL_META
def setup_module():
- utils.set_compression('none')
+ utils.piglit.set_compression('none')
def teardown_module():
- utils.unset_compression()
+ utils.piglit.unset_compression()
def test_initialize_jsonbackend():
@@ -53,21 +53,21 @@ def test_initialize_jsonbackend():
arguments
"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
func = backends.json.JSONBackend(tdir)
nt.ok_(isinstance(func, backends.json.JSONBackend))
def test_json_initialize_metadata():
"""backends.json.JSONBackend.initialize(): produces a metadata.json file"""
- with utils.tempdir() as f:
+ with utils.nose.tempdir() as f:
test = backends.json.JSONBackend(f)
test.initialize(BACKEND_INITIAL_META)
nt.ok_(os.path.exists(os.path.join(f, 'metadata.json')))
-class TestJSONTestMethod(utils.StaticDirectory):
+class TestJSONTestMethod(utils.nose.StaticDirectory):
@classmethod
def setup_class(cls):
cls.test_name = grouptools.join('a', 'test', 'group', 'test1')
@@ -87,7 +87,7 @@ class TestJSONTestMethod(utils.StaticDirectory):
"""backends.json.JSONBackend.write_test(): adds tests to a 'tests' directory"""
nt.ok_(os.path.exists(os.path.join(self.tdir, 'tests', '0.json')))
- @utils.no_error
+ @utils.nose.no_error
def test_json_is_valid(self):
"""backends.json.JSONBackend.write_test(): produces valid json"""
with open(os.path.join(self.tdir, 'tests', '0.json'), 'r') as f:
@@ -101,7 +101,7 @@ class TestJSONTestMethod(utils.StaticDirectory):
nt.assert_dict_equal({self.test_name: self.result}, test)
-class TestJSONTestFinalize(utils.StaticDirectory):
+class TestJSONTestFinalize(utils.nose.StaticDirectory):
# We're explictely setting none here since the default can change from none
@classmethod
def setup_class(cls):
@@ -128,7 +128,7 @@ class TestJSONTestFinalize(utils.StaticDirectory):
"""
nt.ok_(os.path.exists(os.path.join(self.tdir, 'results.json')))
- @utils.no_error
+ @utils.nose.no_error
def test_results_valid(self):
"""backends.json.JSONBackend.finalize(): results.json is valid"""
with open(os.path.join(self.tdir, 'results.json'), 'r') as f:
@@ -137,10 +137,10 @@ class TestJSONTestFinalize(utils.StaticDirectory):
def test_update_results_current():
"""backends.json.update_results(): returns early when the results_version is current"""
- data = utils.JSON_DATA.copy()
+ data = utils.piglit.JSON_DATA.copy()
data['results_version'] = backends.json.CURRENT_JSON_VERSION
- with utils.tempdir() as d:
+ with utils.nose.tempdir() as d:
with open(os.path.join(d, 'main'), 'w') as f:
json.dump(data, f, default=backends.json.piglit_encoder)
@@ -165,10 +165,10 @@ def test_update_results_old():
testing of the update process.
"""
- data = utils.JSON_DATA.copy()
+ data = utils.piglit.JSON_DATA.copy()
data['results_version'] = 0
- with utils.tempdir() as d:
+ with utils.nose.tempdir() as d:
with open(os.path.join(d, 'main'), 'w') as f:
json.dump(data, f)
@@ -183,13 +183,13 @@ def test_update_results_old():
@nt.raises(AssertionError)
def test_json_resume_non_folder():
"""backends.json._resume: doesn't accept a file"""
- with utils.tempfile('') as f:
+ with utils.nose.tempfile('') as f:
backends.json._resume(f)
def test_resume_load_valid():
"""backends.json._resume: loads valid results"""
- with utils.tempdir() as f:
+ with utils.nose.tempdir() as f:
backend = backends.json.JSONBackend(f)
backend.initialize(BACKEND_INITIAL_META)
with backend.write_test("group1/test1") as t:
@@ -209,7 +209,7 @@ def test_resume_load_valid():
def test_resume_load_invalid():
"""backends.json._resume: ignores invalid results"""
- with utils.tempdir() as f:
+ with utils.nose.tempdir() as f:
backend = backends.json.JSONBackend(f)
backend.initialize(BACKEND_INITIAL_META)
with backend.write_test("group1/test1") as t:
@@ -237,7 +237,7 @@ def test_resume_load_incomplete():
to split some code out and allow this to be done in the resume path.
"""
- with utils.tempdir() as f:
+ with utils.nose.tempdir() as f:
backend = backends.json.JSONBackend(f)
backend.initialize(BACKEND_INITIAL_META)
with backend.write_test("group1/test1") as t:
@@ -258,42 +258,42 @@ def test_resume_load_incomplete():
)
- at utils.no_error
+ at utils.nose.no_error
def test_load_results_folder_as_main():
"""backends.json.load_results: takes a folder with a file named main in it
"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
with open(os.path.join(tdir, 'main'), 'w') as tfile:
- tfile.write(json.dumps(utils.JSON_DATA,
+ tfile.write(json.dumps(utils.piglit.JSON_DATA,
default=backends.json.piglit_encoder))
backends.json.load_results(tdir, 'none')
- at utils.no_error
+ at utils.nose.no_error
def test_load_results_folder():
"""backends.json.load_results: takes a folder with a file named results.json"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
with open(os.path.join(tdir, 'results.json'), 'w') as tfile:
- tfile.write(json.dumps(utils.JSON_DATA,
+ tfile.write(json.dumps(utils.piglit.JSON_DATA,
default=backends.json.piglit_encoder))
backends.json.load_results(tdir, 'none')
- at utils.no_error
+ at utils.nose.no_error
def test_load_results_file():
"""backends.json.load_results: Loads a file passed by name"""
- with utils.resultfile() as tfile:
+ with utils.piglit.resultfile() as tfile:
backends.json.load_results(tfile.name, 'none')
def test_load_json():
"""backends.load(): Loads .json files."""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
filename = os.path.join(tdir, 'results.json')
with open(filename, 'w') as f:
- json.dump(utils.JSON_DATA, f, default=backends.json.piglit_encoder)
+ json.dump(utils.piglit.JSON_DATA, f, default=backends.json.piglit_encoder)
result = backends.load(filename)
@@ -319,6 +319,6 @@ def test_piglit_decoder_old_result():
@nt.raises(exceptions.PiglitFatalError)
def test_load_bad_json():
"""backends.json._load: Raises fatal error if json is corrupt"""
- with utils.tempfile('{"bad json": }') as f:
+ with utils.nose.tempfile('{"bad json": }') as f:
with open(f, 'r') as tfile:
backends.json._load(tfile)
diff --git a/unittests/json_results_update_tests.py b/unittests/json_results_update_tests.py
index 5f4fc00..6f1e0f7 100644
--- a/unittests/json_results_update_tests.py
+++ b/unittests/json_results_update_tests.py
@@ -44,11 +44,11 @@ from framework import backends, results
def setup_module():
- utils.set_compression('none')
+ utils.piglit.set_compression('none')
def teardown_module():
- utils.unset_compression()
+ utils.piglit.unset_compression()
class TestV0toV1(object):
@@ -145,7 +145,7 @@ class TestV0toV1(object):
},
})
- with utils.tempfile(json.dumps(cls.DATA)) as t:
+ with utils.nose.tempfile(json.dumps(cls.DATA)) as t:
with open(t, 'r') as f:
cls.RESULT = backends.json._update_zero_to_one(backends.json._load(f))
@@ -226,7 +226,7 @@ class TestV0toV1(object):
"""backends.json.update_results (0 -> 1): Correctly handle new single entry subtests correctly"""
nt.ok_('group3/groupA/test' in six.iterkeys(self.RESULT.tests))
- @utils.test_in_tempdir
+ @utils.nose.test_in_tempdir
def _load_with_update(self, data=None):
"""If the file is not results.json, it will be renamed.
@@ -269,15 +269,15 @@ class TestV0toV1(object):
data['tests']['sometest']['info'] = \
'Returncode: 1\n\nErrors:stderr\n\nOutput: stdout\n\nmore\n\nstuff'
- with utils.tempfile(
+ with utils.nose.tempfile(
json.dumps(data, default=backends.json.piglit_encoder)) as t:
with open(t, 'r') as f:
backends.json._update_zero_to_one(backends.json._load(f))
- @utils.DocFormatter({'current': backends.json.CURRENT_JSON_VERSION})
+ @utils.nose.DocFormatter({'current': backends.json.CURRENT_JSON_VERSION})
def test_load_results(self):
"""backends.json.update_results (1 -> {current}): load_results properly updates"""
- with utils.tempdir() as d:
+ with utils.nose.tempdir() as d:
tempfile = os.path.join(d, 'results.json')
with open(tempfile, 'w') as f:
json.dump(self.DATA, f, default=backends.json.piglit_encoder)
@@ -326,7 +326,7 @@ class TestV2Update(object):
}
}
- with utils.tempfile(
+ with utils.nose.tempfile(
json.dumps(data, default=backends.json.piglit_encoder)) as t:
with open(t, 'r') as f:
cls.result = backends.json._update_one_to_two(
@@ -394,7 +394,7 @@ class TestV2NoUpdate(object):
}
}
- with utils.tempfile(
+ with utils.nose.tempfile(
json.dumps(data, default=backends.json.piglit_encoder)) as t:
with open(t, 'r') as f:
cls.result = backends.json._update_one_to_two(
@@ -471,7 +471,7 @@ class TestV2toV3(object):
}
}
- with utils.tempfile(
+ with utils.nose.tempfile(
json.dumps(data, default=backends.json.piglit_encoder)) as t:
with open(t, 'r') as f:
# pylint: disable=protected-access
@@ -537,7 +537,7 @@ class TestV3toV4(object):
@staticmethod
def _make_result(data):
"""Write data to a file and return a result.TestrunResult object."""
- with utils.tempfile(
+ with utils.nose.tempfile(
json.dumps(data, default=backends.json.piglit_encoder)) as t:
with open(t, 'r') as f:
# pylint: disable=protected-access
@@ -571,7 +571,7 @@ class TestV3toV4(object):
for new in self.new:
nt.assert_dict_equal(self.result.tests[new], self.TEST_DATA)
- @utils.not_raises(KeyError)
+ @utils.nose.not_raises(KeyError)
def test_missing(self):
"""backends.json.update_results (3 -> 4): updates successfully when tests to rename are not present"""
data = copy.copy(self.DATA)
@@ -627,7 +627,7 @@ class TestV4toV5(object):
"has at windows",
]
- with utils.tempfile(
+ with utils.nose.tempfile(
json.dumps(cls.DATA, default=backends.json.piglit_encoder)) as t:
with open(t, 'r') as f:
cls.result = backends.json._update_four_to_five(backends.json._load(f))
@@ -692,7 +692,7 @@ class TestV5toV6(object):
@classmethod
def setup_class(cls):
"""Class setup. Create a TestrunResult with v4 data."""
- with utils.tempfile(
+ with utils.nose.tempfile(
json.dumps(cls.DATA, default=backends.json.piglit_encoder)) as t:
with open(t, 'r') as f:
cls.result = backends.json._update_five_to_six(backends.json._load(f))
@@ -735,7 +735,7 @@ class TestV6toV7(object):
@classmethod
def setup_class(cls):
"""Class setup. Create a TestrunResult with v4 data."""
- with utils.tempfile(
+ with utils.nose.tempfile(
json.dumps(cls.DATA, default=backends.json.piglit_encoder)) as t:
with open(t, 'r') as f:
cls.result = backends.json._update_six_to_seven(backends.json._load(f))
@@ -784,7 +784,7 @@ class TestV7toV8(object):
cls.DATA['tests']['a at test'] = cls.DATA['tests']['a at test'].to_json()
cls.DATA['tests']['a at test']['time'] = 1.2
- with utils.tempfile(
+ with utils.nose.tempfile(
json.dumps(cls.DATA, default=backends.json.piglit_encoder)) as t:
with open(t, 'r') as f:
cls.result = backends.json._update_seven_to_eight(
diff --git a/unittests/json_tests.py b/unittests/json_tests.py
index 189d246..0d17f19 100644
--- a/unittests/json_tests.py
+++ b/unittests/json_tests.py
@@ -46,11 +46,11 @@ from framework.programs.run import _create_metadata
def setup_module():
- utils.set_compression('none')
+ utils.piglit.set_compression('none')
def teardown_module():
- utils.unset_compression()
+ utils.piglit.unset_compression()
# Helpers
@@ -61,7 +61,7 @@ class Namespace(object):
# Tests
# pylint: disable=too-many-public-methods
-class TestJsonOutput(utils.StaticDirectory):
+class TestJsonOutput(utils.nose.StaticDirectory):
"""Class for testing JSON output."""
@classmethod
def setup_class(cls):
@@ -99,20 +99,20 @@ class TestJsonOutput(utils.StaticDirectory):
def test_root_lspci(self):
"""JSON: lspci is a root key."""
- utils.platform_check('linux')
- utils.binary_check('lspci')
+ utils.nose.platform_check('linux')
+ utils.nose.binary_check('lspci')
nt.assert_in('lspci', self.json)
def test_root_uname(self):
"""JSON: uname is a root key."""
- utils.platform_check('linux')
- utils.binary_check('uname')
+ utils.nose.platform_check('linux')
+ utils.nose.binary_check('uname')
nt.assert_in('uname', self.json)
def test_root_glxinfo(self):
"""JSON: glxinfo is a root key."""
- utils.platform_check('linux')
- utils.binary_check('glxinfo')
+ utils.nose.platform_check('linux')
+ utils.nose.binary_check('glxinfo')
nt.assert_in('glxinfo', self.json)
def test_root_time_elapsed(self):
diff --git a/unittests/junit_backends_tests.py b/unittests/junit_backends_tests.py
index 50fb058..f034a55 100644
--- a/unittests/junit_backends_tests.py
+++ b/unittests/junit_backends_tests.py
@@ -41,7 +41,7 @@ from .backends_tests import BACKEND_INITIAL_META
JUNIT_SCHEMA = os.path.join(os.path.dirname(__file__), 'schema', 'junit-7.xsd')
-doc_formatter = utils.DocFormatter({'separator': grouptools.SEPARATOR})
+doc_formatter = utils.nose.DocFormatter({'separator': grouptools.SEPARATOR})
_XML = """\
<?xml version='1.0' encoding='utf-8'?>
@@ -62,14 +62,14 @@ time end: 4.5
def setup_module():
- utils.set_compression('none')
+ utils.piglit.set_compression('none')
def teardown_module():
- utils.unset_compression()
+ utils.piglit.unset_compression()
-class TestJunitNoTests(utils.StaticDirectory):
+class TestJunitNoTests(utils.nose.StaticDirectory):
@classmethod
def setup_class(cls):
super(TestJunitNoTests, cls).setup_class()
@@ -78,7 +78,7 @@ class TestJunitNoTests(utils.StaticDirectory):
test.finalize()
cls.test_file = os.path.join(cls.tdir, 'results.xml')
- @utils.no_error
+ @utils.nose.no_error
def test_xml_well_formed(self):
"""backends.junit.JUnitBackend: initialize and finalize produce well formed xml
@@ -115,7 +115,7 @@ class TestJUnitSingleTest(TestJunitNoTests):
def test_xml_valid(self):
"""backends.junit.JUnitBackend.write_test(): (once) produces valid xml"""
- utils.module_check('lxml')
+ utils.nose.module_check('lxml')
schema = etree.XMLSchema(file=JUNIT_SCHEMA)
with open(self.test_file, 'r') as f:
nt.ok_(schema.validate(etree.parse(f)), msg='xml is not valid')
@@ -158,7 +158,7 @@ class TestJUnitMultiTest(TestJUnitSingleTest):
@doc_formatter
def test_junit_replace():
"""backends.junit.JUnitBackend.write_test(): '{separator}' is replaced with '.'"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
result = results.TestResult()
result.time.end = 1.2345
result.result = 'pass'
@@ -178,10 +178,10 @@ def test_junit_replace():
'piglit.a.test.group')
- at utils.not_raises(etree.ParseError)
+ at utils.nose.not_raises(etree.ParseError)
def test_junit_skips_bad_tests():
"""backends.junit.JUnitBackend: skips illformed tests"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
result = results.TestResult()
result.time.end = 1.2345
result.result = 'pass'
@@ -199,7 +199,7 @@ def test_junit_skips_bad_tests():
test.finalize()
-class TestJUnitLoad(utils.StaticDirectory):
+class TestJUnitLoad(utils.nose.StaticDirectory):
"""Methods that test loading JUnit results."""
__instance = None
@@ -219,7 +219,7 @@ class TestJUnitLoad(utils.StaticDirectory):
cls.__instance = backends.junit._load(cls.xml_file)
return cls.__instance
- @utils.no_error
+ @utils.nose.no_error
def test_no_errors(self):
"""backends.junit._load: Raises no errors for valid junit."""
self.xml()
@@ -284,12 +284,12 @@ class TestJUnitLoad(utils.StaticDirectory):
nt.eq_(test, 1934)
- @utils.no_error
+ @utils.nose.no_error
def test_load_file(self):
"""backends.junit.load: Loads a file directly"""
backends.junit.REGISTRY.load(self.xml_file, 'none')
- @utils.no_error
+ @utils.nose.no_error
def test_load_dir(self):
"""backends.junit.load: Loads a directory"""
backends.junit.REGISTRY.load(self.tdir, 'none')
@@ -298,7 +298,7 @@ class TestJUnitLoad(utils.StaticDirectory):
def test_load_file_name():
"""backends.junit._load: uses the filename for name if filename != 'results'
"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
filename = os.path.join(tdir, 'foobar.xml')
with open(filename, 'w') as f:
f.write(_XML)
@@ -309,7 +309,7 @@ def test_load_file_name():
def test_load_folder_name():
"""backends.junit._load: uses the folder name if the result is 'results'"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.mkdir(os.path.join(tdir, 'a cool test'))
filename = os.path.join(tdir, 'a cool test', 'results.xml')
with open(filename, 'w') as f:
@@ -319,10 +319,10 @@ def test_load_folder_name():
nt.assert_equal(test.name, 'a cool test')
- at utils.test_in_tempdir
+ at utils.nose.test_in_tempdir
def test_load_default_name():
"""backends.junit._load: uses 'junit result' for name as fallback"""
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.chdir(tdir)
filename = 'results.xml'
diff --git a/unittests/log_tests.py b/unittests/log_tests.py
index d8d5766..40a9c15 100644
--- a/unittests/log_tests.py
+++ b/unittests/log_tests.py
@@ -36,7 +36,7 @@ TEST_STATE = {'total': 0, 'complete': 0, 'lastlength': 0, 'running': [],
'summary': collections.defaultdict(lambda: 0)}
- at utils.nose_generator
+ at utils.nose.generator
def test_initialize():
""" Generate tests for class initialization """
check_initialize = lambda c, *a: c(*a)
@@ -57,7 +57,7 @@ def test_log_factory_returns_log():
nt.ok_(isinstance(log_inst, log.BaseLog))
- at utils.nose_generator
+ at utils.nose.generator
def test_quietlog_log_state_update():
"""log.QuiteLog.log() updates shared state managed by LogManager"""
logger = log.LogManager('quiet', 100)
@@ -94,7 +94,7 @@ def check_for_output(func, args, file_=sys.stdout):
nt.eq_(file_.read(), '')
- at utils.nose_generator
+ at utils.nose.generator
def test_print_when_expected():
""" Generator that creates tests that ensure that methods print
@@ -144,7 +144,7 @@ def check_no_output(func, args, file_=sys.stdout):
msg='file.tell() is at {}, but should be at 0'.format(file_.tell()))
- at utils.nose_generator
+ at utils.nose.generator
def test_noprint_when_expected():
""" Generate tests for methods that shouldn't print
diff --git a/unittests/monitoring_tests.py b/unittests/monitoring_tests.py
index 20feb57..817ee55 100644
--- a/unittests/monitoring_tests.py
+++ b/unittests/monitoring_tests.py
@@ -58,7 +58,7 @@ class TestMonitoring(object):
def test_Monitoring_delete_rule(self):
"""monitorin.Monitoring: add and delete rule."""
- with utils.tempfile(self.init_contents) as tfile:
+ with utils.nose.tempfile(self.init_contents) as tfile:
self.monitoring.add_rule('error_file',
'file',
tfile,
@@ -77,7 +77,7 @@ class TestMonitoring(object):
def test_Monitoring_add_rule_bad_format(self):
"""monitoring.Monitoring: add non existing type rule."""
- with utils.tempfile(self.init_contents) as tfile:
+ with utils.nose.tempfile(self.init_contents) as tfile:
self.monitoring.add_rule('error_file_bad_type',
'bad_type',
tfile,
@@ -86,7 +86,7 @@ class TestMonitoring(object):
def test_Monitoring_file_error(self):
"""monitoring.Monitoring: error found on a file."""
- with utils.tempfile(self.init_contents) as tfile:
+ with utils.nose.tempfile(self.init_contents) as tfile:
self.monitoring.add_rule('error_file',
'file',
tfile,
@@ -103,7 +103,7 @@ class TestMonitoring(object):
def test_Monitoring_file_no_error(self):
"""monitoring.Monitoring: no error found on a file."""
- with utils.tempfile(self.init_contents) as tfile:
+ with utils.nose.tempfile(self.init_contents) as tfile:
self.monitoring.add_rule('no_error_file',
'file',
tfile,
@@ -120,7 +120,7 @@ class TestMonitoring(object):
def test_Monitoring_locked_file_error(self):
"""monitoring.Monitoring: error found on a locked file."""
- with utils.tempfile(self.init_contents) as tfile:
+ with utils.nose.tempfile(self.init_contents) as tfile:
self.monitoring.add_rule('error_locked_file',
'locked_file',
tfile,
@@ -137,7 +137,7 @@ class TestMonitoring(object):
def test_Monitoring_locked_file_no_error(self):
"""monitoring.Monitoring: no error found on a locked file."""
- with utils.tempfile(self.init_contents) as tfile:
+ with utils.nose.tempfile(self.init_contents) as tfile:
self.monitoring.add_rule('no_error_file',
'locked_file',
tfile,
@@ -154,7 +154,7 @@ class TestMonitoring(object):
def test_Monitoring_dmesg_error(self):
"""monitoring.Monitoring: error found on the dmesg."""
- utils.platform_check('linux')
+ utils.nose.platform_check('linux')
mock_out = mock.Mock(return_value=b'[1.0]This\n[2.0]is\n[3.0]dmesg')
with mock.patch('framework.dmesg.subprocess.check_output', mock_out):
@@ -173,7 +173,7 @@ class TestMonitoring(object):
def test_Monitoring_dmesg_no_error(self):
"""monitoring.Monitoring: no error found on the dmesg."""
- utils.platform_check('linux')
+ utils.nose.platform_check('linux')
mock_out = mock.Mock(return_value=b'[1.0]This\n[2.0]is\n[3.0]dmesg')
with mock.patch('framework.dmesg.subprocess.check_output', mock_out):
diff --git a/unittests/oglconform_tests.py b/unittests/oglconform_tests.py
index 6dbe40b..4997832 100644
--- a/unittests/oglconform_tests.py
+++ b/unittests/oglconform_tests.py
@@ -60,7 +60,7 @@ def test_make_profile(mock_temp):
msg='{} not in {}'.format(name, profile.test_list.keys()))
- at utils.not_raises(ValueError)
+ at utils.nose.not_raises(ValueError)
@mock.patch.object(oglconform.tempfile, 'NamedTemporaryFile')
def test_make_profile_missing(mock_temp):
"""tests.oglconform._make_profile: handles missing groups"""
@@ -114,7 +114,7 @@ def test_oglctest_interpret_result_skip():
nt.eq_(test.result.result, 'skip')
- at utils.nose_generator
+ at utils.nose.generator
def test_oglctest_interpret_result_skip_re():
"""Generate tests for various skip tests."""
values = [
diff --git a/unittests/opencv_tests.py b/unittests/opencv_tests.py
index b533f2b..ea60362 100644
--- a/unittests/opencv_tests.py
+++ b/unittests/opencv_tests.py
@@ -28,7 +28,7 @@ from . import utils
from framework.test import OpenCVTest
- at utils.no_error
+ at utils.nose.no_error
def test_initialize_opencvtest():
"""test.opencv.OpenCVTest: Class initializes"""
OpenCVTest('test_prog', 'testname')
diff --git a/unittests/opengl_tests.py b/unittests/opengl_tests.py
index cdbcc16..8b8be9c 100644
--- a/unittests/opengl_tests.py
+++ b/unittests/opengl_tests.py
@@ -298,27 +298,27 @@ class TestWflInfoOSError(object):
for f in cls.__patchers:
f.stop()
- @utils.not_raises(OSError)
+ @utils.nose.not_raises(OSError)
def test_gl_extensions(self):
"""test.opengl.WflInfo.gl_extensions: Handles OSError "no file" gracefully"""
self.inst.gl_extensions
- @utils.not_raises(OSError)
+ @utils.nose.not_raises(OSError)
def test_gl_version(self):
"""test.opengl.WflInfo.get_gl_version: Handles OSError "no file" gracefully"""
self.inst.gl_version
- @utils.not_raises(OSError)
+ @utils.nose.not_raises(OSError)
def test_gles_version(self):
"""test.opengl.WflInfo.get_gles_version: Handles OSError "no file" gracefully"""
self.inst.gles_version
- @utils.not_raises(OSError)
+ @utils.nose.not_raises(OSError)
def test_glsl_version(self):
"""test.opengl.WflInfo.glsl_version: Handles OSError "no file" gracefully"""
self.inst.glsl_version
- @utils.not_raises(OSError)
+ @utils.nose.not_raises(OSError)
def test_glsl_es_version(self):
"""test.opengl.WflInfo.glsl_es_version: Handles OSError "no file" gracefully"""
self.inst.glsl_es_version
@@ -351,27 +351,27 @@ class TestWflInfoCalledProcessError(object):
def setup(self):
self.inst = opengl.WflInfo()
- @utils.not_raises(subprocess.CalledProcessError)
+ @utils.nose.not_raises(subprocess.CalledProcessError)
def test_gl_extensions(self):
"""test.opengl.WflInfo.gl_extensions: Handles CalledProcessError gracefully"""
self.inst.gl_extensions
- @utils.not_raises(subprocess.CalledProcessError)
+ @utils.nose.not_raises(subprocess.CalledProcessError)
def test_gl_version(self):
"""test.opengl.WflInfo.get_gl_version: Handles CalledProcessError gracefully"""
self.inst.gl_version
- @utils.not_raises(subprocess.CalledProcessError)
+ @utils.nose.not_raises(subprocess.CalledProcessError)
def test_gles_version(self):
"""test.opengl.WflInfo.gles_version: Handles CalledProcessError gracefully"""
self.inst.gles_version
- @utils.not_raises(subprocess.CalledProcessError)
+ @utils.nose.not_raises(subprocess.CalledProcessError)
def test_glsl_version(self):
"""test.opengl.WflInfo.glsl_version: Handles CalledProcessError gracefully"""
self.inst.glsl_version
- @utils.not_raises(subprocess.CalledProcessError)
+ @utils.nose.not_raises(subprocess.CalledProcessError)
def test_glsl_es_version(self):
"""test.opengl.WflInfo.glsl_es_version: Handles CalledProcessError gracefully"""
self.inst.glsl_es_version
@@ -384,7 +384,7 @@ class TestFastSkipMixin(object):
@classmethod
def setup_class(cls):
"""Create a Class with FastSkipMixin, but patch various bits."""
- class _Test(opengl.FastSkipMixin, utils.Test):
+ class _Test(opengl.FastSkipMixin, utils.piglit.Test):
pass
cls._class = _Test
@@ -416,13 +416,13 @@ class TestFastSkipMixin(object):
self.test.gl_required.add('foobar')
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_should_not_skip(self):
"""test.opengl.FastSkipMixin.is_skip: runs when requires is in extensions"""
self.test.gl_required.add('bar')
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_extension_empty(self):
"""test.opengl.FastSkipMixin.is_skip: if extensions are empty test runs"""
self.test.gl_required.add('foobar')
@@ -430,7 +430,7 @@ class TestFastSkipMixin(object):
None):
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_requires_empty(self):
"""test.opengl.FastSkipMixin.is_skip: if gl_requires is empty test runs"""
self.test.is_skip()
@@ -441,12 +441,12 @@ class TestFastSkipMixin(object):
self.test.gl_version = 4.0
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_gl_version_gt(self):
"""test.opengl.FastSkipMixin.is_skip: runs if gl_version < __max_gl_version"""
self.test.gl_version = 1.0
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_gl_version_unset(self):
"""test.opengl.FastSkipMixin.is_skip: runs if __max_gl_version is None"""
self.test.gl_version = 1.0
@@ -454,7 +454,7 @@ class TestFastSkipMixin(object):
None):
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_gl_version_set(self):
"""test.opengl.FastSkipMixin.is_skip: runs if gl_version is None"""
self.test.is_skip()
@@ -465,12 +465,12 @@ class TestFastSkipMixin(object):
self.test.gles_version = 4.0
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_gles_version_gt(self):
"""test.opengl.FastSkipMixin.is_skip: runs if gles_version < __max_gles_version"""
self.test.gles_version = 1.0
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_gles_version_unset(self):
"""test.opengl.FastSkipMixin.is_skip: runs if __max_gles_version is None"""
self.test.gles_version = 1.0
@@ -478,7 +478,7 @@ class TestFastSkipMixin(object):
None):
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_gles_version_set(self):
"""test.opengl.FastSkipMixin.is_skip: runs if gles_version is None"""
self.test.is_skip()
@@ -489,12 +489,12 @@ class TestFastSkipMixin(object):
self.test.glsl_version = 4.0
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_glsl_version_gt(self):
"""test.opengl.FastSkipMixin.is_skip: runs if glsl_version < __max_glsl_version"""
self.test.glsl_version = 1.0
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_glsl_version_unset(self):
"""test.opengl.FastSkipMixin.is_skip: runs if __max_glsl_version is None"""
self.test.glsl_version = 1.0
@@ -502,7 +502,7 @@ class TestFastSkipMixin(object):
None):
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_glsl_version_set(self):
"""test.opengl.FastSkipMixin.is_skip: runs if glsl_version is None"""
self.test.is_skip()
@@ -513,12 +513,12 @@ class TestFastSkipMixin(object):
self.test.glsl_es_version = 4.0
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_glsl_es_version_gt(self):
"""test.opengl.FastSkipMixin.is_skip: runs if glsl_es_version < __max_glsl_es_version"""
self.test.glsl_es_version = 1.0
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_glsl_es_version_unset(self):
"""test.opengl.FastSkipMixin.is_skip: runs if __max_glsl_es_version is None"""
self.test.glsl_es_version = 1.0
@@ -526,7 +526,7 @@ class TestFastSkipMixin(object):
None):
self.test.is_skip()
- @utils.not_raises(TestIsSkip)
+ @utils.nose.not_raises(TestIsSkip)
def test_max_glsl_es_version_set(self):
"""test.opengl.FastSkipMixin.is_skip: runs if glsl_es_version is None"""
self.test.is_skip()
diff --git a/unittests/options_tests.py b/unittests/options_tests.py
index 8f5f7c1..ca03a0a 100644
--- a/unittests/options_tests.py
+++ b/unittests/options_tests.py
@@ -40,7 +40,7 @@ from framework import options
_RETYPE = type(re.compile(''))
- at utils.no_error
+ at utils.nose.no_error
def test_relist_init():
"""options._ReList: inializes"""
options._ReList()
diff --git a/unittests/piglit_test_tests.py b/unittests/piglit_test_tests.py
index a882e8d..76027fb 100644
--- a/unittests/piglit_test_tests.py
+++ b/unittests/piglit_test_tests.py
@@ -38,13 +38,13 @@ from framework.test.piglit_test import (PiglitBaseTest, PiglitGLTest,
PiglitCLTest)
- at utils.no_error
+ at utils.nose.no_error
def test_initialize_piglitgltest():
"""test.piglit_test.PiglitGLTest: Class initializes"""
PiglitGLTest(['/bin/true'])
- at utils.no_error
+ at utils.nose.no_error
def test_initialize_piglitcltest():
"""test.piglit_test.PiglitCLTest: Class initializes"""
PiglitCLTest(['/bin/true'])
@@ -105,7 +105,7 @@ def test_PiglitGLTest_include_and_exclude():
@mock.patch('framework.test.piglit_test.options.OPTIONS', new_callable=Options)
- at utils.not_raises(TestIsSkip)
+ at utils.nose.not_raises(TestIsSkip)
def test_PiglitGLTest_platform_in_require(mock_opts):
"""test.piglit_test.PiglitGLTest.is_skip(): does not skip if platform is in require_platforms"""
mock_opts.env['PIGLIT_PLATFORM'] = 'glx'
@@ -132,7 +132,7 @@ def test_PiglitGLTest_platform_in_exclude(mock_opts):
@mock.patch('framework.test.piglit_test.options.OPTIONS', new_callable=Options)
- at utils.not_raises(TestIsSkip)
+ at utils.nose.not_raises(TestIsSkip)
def test_PiglitGLTest_platform_not_in_exclude(mock_opts):
"""test.piglit_test.PiglitGLTest.is_skip(): does not skip if platform is in exclude_platforms"""
mock_opts.env['PIGLIT_PLATFORM'] = 'gbm'
diff --git a/unittests/profile_tests.py b/unittests/profile_tests.py
index 19c859d..1a2d450 100644
--- a/unittests/profile_tests.py
+++ b/unittests/profile_tests.py
@@ -41,7 +41,7 @@ from framework.test import GleanTest
sys.stderr = sys.stdout
- at utils.no_error
+ at utils.nose.no_error
def test_initialize_testprofile():
"""profile.TestProfile: class initializes"""
profile.TestProfile()
@@ -79,7 +79,7 @@ def test_testprofile_default_dmesg():
def test_testprofile_set_dmesg_true():
"""profile.TestProfile: Dmesg returns an appropriate dmesg is set to True"""
- utils.platform_check('linux')
+ utils.nose.platform_check('linux')
profile_ = profile.TestProfile()
profile_.dmesg = True
nt.ok_(isinstance(profile_.dmesg, dmesg.LinuxDmesg))
@@ -87,7 +87,7 @@ def test_testprofile_set_dmesg_true():
def test_testprofile_set_dmesg_false():
"""profile.TestProfile: Dmesg returns a DummyDmesg if set to False"""
- utils.platform_check('linux')
+ utils.nose.platform_check('linux')
profile_ = profile.TestProfile()
profile_.dmesg = True
profile_.dmesg = False
@@ -100,12 +100,12 @@ def test_testprofile_update_test_list():
group1 = grouptools.join('group1', 'test1')
group2 = grouptools.join('group1', 'test2')
- profile1.test_list[group1] = utils.Test(['test1'])
+ profile1.test_list[group1] = utils.piglit.Test(['test1'])
profile2 = profile.TestProfile()
- profile2.test_list[group1] = utils.Test(['test3'])
- profile2.test_list[group2] = utils.Test(['test2'])
+ profile2.test_list[group1] = utils.piglit.Test(['test3'])
+ profile2.test_list[group2] = utils.piglit.Test(['test2'])
with profile1.allow_reassignment:
profile1.update(profile2)
@@ -117,10 +117,10 @@ class TestPrepareTestListMatches(object):
"""Create tests for TestProfile.prepare_test_list filtering"""
def __init__(self):
self.data = profile.TestDict()
- self.data[grouptools.join('group1', 'test1')] = utils.Test(['thingy'])
- self.data[grouptools.join('group1', 'group3', 'test2')] = utils.Test(['thing'])
- self.data[grouptools.join('group3', 'test5')] = utils.Test(['other'])
- self.data[grouptools.join('group4', 'Test9')] = utils.Test(['is_caps'])
+ self.data[grouptools.join('group1', 'test1')] = utils.piglit.Test(['thingy'])
+ self.data[grouptools.join('group1', 'group3', 'test2')] = utils.piglit.Test(['thing'])
+ self.data[grouptools.join('group3', 'test5')] = utils.piglit.Test(['other'])
+ self.data[grouptools.join('group4', 'Test9')] = utils.piglit.Test(['is_caps'])
self.opts = None
self.__patcher = mock.patch('framework.profile.options.OPTIONS',
new_callable=options._Options)
@@ -151,7 +151,7 @@ class TestPrepareTestListMatches(object):
profile_.test_list = self.data
profile_._prepare_test_list()
- baseline = {grouptools.join('group3', 'test5'): utils.Test(['other'])}
+ baseline = {grouptools.join('group3', 'test5'): utils.piglit.Test(['other'])}
nt.assert_dict_equal(dict(profile_.test_list), baseline)
@@ -192,35 +192,35 @@ class TestPrepareTestListMatches(object):
nt.assert_not_in(grouptools.join('group4', 'Test9'), profile_.test_list)
- at utils.no_error
+ at utils.nose.no_error
def test_testprofile_group_manager_no_name_args_eq_one():
"""profile.TestProfile.group_manager: no name and len(args) == 1 is valid"""
prof = profile.TestProfile()
- with prof.group_manager(utils.Test, 'foo') as g:
+ with prof.group_manager(utils.piglit.Test, 'foo') as g:
g(['a'])
def test_testprofile_group_manager_no_name_args_gt_one():
"""profile.TestProfile.group_manager: no name and len(args) > 1 is valid"""
prof = profile.TestProfile()
- with prof.group_manager(utils.Test, 'foo') as g:
+ with prof.group_manager(utils.piglit.Test, 'foo') as g:
g(['a', 'b'])
nt.assert_in(grouptools.join('foo', 'a b'), prof.test_list)
- at utils.no_error
+ at utils.nose.no_error
def test_testprofile_group_manager_name():
"""profile.TestProfile.group_manager: name plus len(args) > 1 is valid"""
prof = profile.TestProfile()
- with prof.group_manager(utils.Test, 'foo') as g:
+ with prof.group_manager(utils.piglit.Test, 'foo') as g:
g(['a', 'b'], 'a')
def test_testprofile_group_manager_is_added():
"""profile.TestProfile.group_manager: Tests are added to the profile"""
prof = profile.TestProfile()
- with prof.group_manager(utils.Test, 'foo') as g:
+ with prof.group_manager(utils.piglit.Test, 'foo') as g:
g(['a', 'b'], 'a')
nt.assert_in(grouptools.join('foo', 'a'), prof.test_list)
@@ -229,7 +229,7 @@ def test_testprofile_group_manager_is_added():
def test_testprofile_groupmanager_kwargs():
"""profile.TestProfile.group_manager: Extra kwargs are passed to the Test"""
prof = profile.TestProfile()
- with prof.group_manager(utils.Test, 'foo') as g:
+ with prof.group_manager(utils.piglit.Test, 'foo') as g:
g(['a'], run_concurrent=True)
test = prof.test_list[grouptools.join('foo', 'a')]
@@ -239,7 +239,7 @@ def test_testprofile_groupmanager_kwargs():
def test_testprofile_groupmanager_default_args():
"""profile.TestProfile.group_manager: group_manater kwargs are passed to the Test"""
prof = profile.TestProfile()
- with prof.group_manager(utils.Test, 'foo', run_concurrent=True) as g:
+ with prof.group_manager(utils.piglit.Test, 'foo', run_concurrent=True) as g:
g(['a'])
test = prof.test_list[grouptools.join('foo', 'a')]
@@ -249,7 +249,7 @@ def test_testprofile_groupmanager_default_args():
def test_testprofile_groupmanager_kwargs_overwrite():
"""profile.TestProfile.group_manager: default_args are overwritten by kwargs"""
prof = profile.TestProfile()
- with prof.group_manager(utils.Test, 'foo', run_concurrent=True) as g:
+ with prof.group_manager(utils.piglit.Test, 'foo', run_concurrent=True) as g:
g(['a'], run_concurrent=False)
test = prof.test_list[grouptools.join('foo', 'a')]
@@ -277,8 +277,8 @@ def test_testdict_key_not_string():
"""
test = profile.TestDict()
- for x in [None, utils.Test(['foo']), ['a'], {'a': 1}]:
- test[x] = utils.Test(['foo'])
+ for x in [None, utils.piglit.Test(['foo']), ['a'], {'a': 1}]:
+ test[x] = utils.piglit.Test(['foo'])
@nt.raises(exceptions.PiglitFatalError)
@@ -298,24 +298,24 @@ def test_testdict_value_not_valid():
def test_testdict_reassignment():
"""profile.TestDict: reassigning a key raises an exception"""
test = profile.TestDict()
- test['foo'] = utils.Test(['foo'])
- test['foo'] = utils.Test(['foo', 'bar'])
+ test['foo'] = utils.piglit.Test(['foo'])
+ test['foo'] = utils.piglit.Test(['foo', 'bar'])
@nt.raises(exceptions.PiglitFatalError)
def test_testdict_reassignment_lower():
"""profile.TestDict: reassigning a key raises an exception (capitalization is ignored)"""
test = profile.TestDict()
- test['foo'] = utils.Test(['foo'])
- test['Foo'] = utils.Test(['foo', 'bar'])
+ test['foo'] = utils.piglit.Test(['foo'])
+ test['Foo'] = utils.piglit.Test(['foo', 'bar'])
def test_testdict_allow_reassignment():
"""profile.TestDict: allow_reassignment works"""
test = profile.TestDict()
- test['a'] = utils.Test(['foo'])
+ test['a'] = utils.piglit.Test(['foo'])
with test.allow_reassignment:
- test['a'] = utils.Test(['bar'])
+ test['a'] = utils.piglit.Test(['bar'])
nt.ok_(test['a'].command == ['bar'])
@@ -323,9 +323,9 @@ def test_testdict_allow_reassignment():
def test_testprofile_allow_reassignment():
"""profile.TestProfile: allow_reassignment wrapper works"""
prof = profile.TestProfile()
- prof.test_list['a'] = utils.Test(['foo'])
+ prof.test_list['a'] = utils.piglit.Test(['foo'])
with prof.allow_reassignment:
- prof.test_list['a'] = utils.Test(['bar'])
+ prof.test_list['a'] = utils.piglit.Test(['bar'])
nt.ok_(prof.test_list['a'].command == ['bar'])
@@ -334,9 +334,9 @@ def test_testprofile_allow_reassignment_with_groupmanager():
"""profile.TestProfile: allow_reassignment wrapper works with groupmanager"""
testname = grouptools.join('a', 'b')
prof = profile.TestProfile()
- prof.test_list[testname] = utils.Test(['foo'])
+ prof.test_list[testname] = utils.piglit.Test(['foo'])
with prof.allow_reassignment:
- with prof.group_manager(utils.Test, 'a') as g:
+ with prof.group_manager(utils.piglit.Test, 'a') as g:
g(['bar'], 'b')
nt.ok_(prof.test_list[testname].command == ['bar'])
@@ -352,11 +352,11 @@ def test_testprofile_allow_reassignemnt_stacked():
"""
test = profile.TestDict()
- test['a'] = utils.Test(['foo'])
+ test['a'] = utils.piglit.Test(['foo'])
with test.allow_reassignment:
with test.allow_reassignment:
pass
- test['a'] = utils.Test(['bar'])
+ test['a'] = utils.piglit.Test(['bar'])
nt.ok_(test['a'].command == ['bar'])
@@ -364,8 +364,8 @@ def test_testprofile_allow_reassignemnt_stacked():
@nt.raises(exceptions.PiglitFatalError)
def test_testdict_update_reassignment():
"""profile.TestDict.update: Does not implictly allow reassignment"""
- test1 = utils.Test(['test1'])
- test2 = utils.Test(['test2'])
+ test1 = utils.piglit.Test(['test1'])
+ test2 = utils.piglit.Test(['test2'])
td1 = profile.TestDict()
td1['test1'] = test1
diff --git a/unittests/results_tests.py b/unittests/results_tests.py
index 466f1e4..7fd18a5 100644
--- a/unittests/results_tests.py
+++ b/unittests/results_tests.py
@@ -40,7 +40,7 @@ def dict_eq(one, two):
nt.assert_dict_equal(dict(one), dict(two))
- at utils.nose_generator
+ at utils.nose.generator
def test_generate_initialize():
""" Generator that creates tests to initialize all of the classes in core
@@ -50,7 +50,7 @@ def test_generate_initialize():
even work?
"""
- @utils.no_error
+ @utils.nose.no_error
def check(target):
target()
@@ -422,7 +422,7 @@ class TestStringDescriptor(object):
self.test.val = inst
nt.eq_(self.test.val, 'foo')
- @utils.no_error
+ @utils.nose.no_error
def test_set_str_unicode_literals(self):
"""results.StringDescriptor.__set__: handles unicode litterals in strs
"""
@@ -617,7 +617,7 @@ class TestTestrunResultFromDict(object):
cls.baseline = test
cls.test = results.TestrunResult.from_dict(test.to_json())
- @utils.nose_generator
+ @utils.nose.generator
def test_basic(self):
"""Generate tests for basic attributes"""
diff --git a/unittests/run_parser_tests.py b/unittests/run_parser_tests.py
index 7bb7676..9741fac 100644
--- a/unittests/run_parser_tests.py
+++ b/unittests/run_parser_tests.py
@@ -131,7 +131,7 @@ class TestBackend(_Helpers):
def test_option_conf(self):
""" Run parser: backend option replaces conf """
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.environ['XDG_CONFIG_HOME'] = tdir
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write(self._CONF)
@@ -144,7 +144,7 @@ class TestBackend(_Helpers):
self._unset_config()
self._move_piglit_conf()
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.environ['XDG_CONFIG_HOME'] = tdir
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write(self._CONF)
@@ -163,7 +163,7 @@ class TestBackend(_Helpers):
# from this test.
sys.stderr = open(os.devnull, 'w')
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write('[core]\nbackend=foobar')
@@ -202,7 +202,7 @@ class TestPlatform(_Helpers):
def test_option_conf(self):
""" Run parser: platform option replaces conf """
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.environ['XDG_CONFIG_HOME'] = tdir
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write(self._CONF)
@@ -223,7 +223,7 @@ class TestPlatform(_Helpers):
self._unset_config()
self._move_piglit_conf()
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.environ['XDG_CONFIG_HOME'] = tdir
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write(self._CONF)
@@ -237,7 +237,7 @@ class TestPlatform(_Helpers):
self._move_piglit_conf()
self.__set_env()
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
os.environ['XDG_CONFIG_HOME'] = tdir
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write(self._CONF)
@@ -256,7 +256,7 @@ class TestPlatform(_Helpers):
# from this test.
sys.stderr = open(os.devnull, 'w')
- with utils.tempdir() as tdir:
+ with utils.nose.tempdir() as tdir:
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write('[core]\nplatform=foobar')
diff --git a/unittests/shader_test_tests.py b/unittests/shader_test_tests.py
index b91cde6..d2ddd5a 100644
--- a/unittests/shader_test_tests.py
+++ b/unittests/shader_test_tests.py
@@ -69,7 +69,7 @@ def test_parse_gl_test_no_decimal():
"""test.shader_test.ShaderTest: raises if version lacks decminal"""
data = ('[require]\n'
'GL = 2\n')
- with utils.tempfile(data) as temp:
+ with utils.nose.tempfile(data) as temp:
with nt.assert_raises(exceptions.PiglitFatalError) as exc:
testm.ShaderTest(temp)
nt.assert_equal(exc.exception, "No GL version set",
@@ -83,7 +83,7 @@ def test_parse_gles2_test():
data = ('[require]\n'
'GL ES >= 2.0\n'
'GLSL ES >= 1.00\n')
- with utils.tempfile(data) as temp:
+ with utils.nose.tempfile(data) as temp:
test = testm.ShaderTest(temp)
nt.assert_equal(
@@ -97,7 +97,7 @@ def test_parse_gles3_test():
data = ('[require]\n'
'GL ES >= 3.0\n'
'GLSL ES >= 3.00\n')
- with utils.tempfile(data) as temp:
+ with utils.nose.tempfile(data) as temp:
test = testm.ShaderTest(temp)
nt.assert_equal(
@@ -119,7 +119,7 @@ def test_find_requirements_gl_requirements():
'GL = 2.0\n'
'GL_ARB_ham_sandwhich\n')
- with utils.tempfile(data) as temp:
+ with utils.nose.tempfile(data) as temp:
test = testm.ShaderTest(temp)
nt.eq_(test.gl_required, set(['GL_ARB_ham_sandwhich']))
@@ -175,7 +175,7 @@ def test_find_requirements_glsl_es_version():
nt.eq_(test.glsl_es_version, 2.0)
- at utils.nose_generator
+ at utils.nose.generator
def test_ignore_shader_runner_directives():
"""test.shader_test.ShaderTest: Doesn't add shader_runner command to gl_required list"""
should_ignore = [
diff --git a/unittests/status_tests.py b/unittests/status_tests.py
index e431804..c2d62f8 100644
--- a/unittests/status_tests.py
+++ b/unittests/status_tests.py
@@ -57,22 +57,22 @@ FIXES = list(itertools.combinations(reversed(STATUSES), 2)) + \
NO_OPS = ('skip', 'notrun')
- at utils.no_error
+ at utils.nose.no_error
def initialize_status():
"""status.Status: class inializes"""
status.Status('test', 1)
- at utils.no_error
+ at utils.nose.no_error
def initialize_nochangestatus():
"""status.NoChangeStatus: class initializes"""
status.NoChangeStatus('test')
- at utils.nose_generator
+ at utils.nose.generator
def test_gen_lookup():
""" Generator that attempts to do a lookup on all statuses """
- @utils.no_error
+ @utils.nose.no_error
def test(status_):
status.status_lookup(status_)
@@ -96,7 +96,7 @@ def test_status_in():
nt.ok_(stat in slist)
- at utils.nose_generator
+ at utils.nose.generator
def test_is_regression():
""" Generate all tests for regressions """
def is_regression(new, old):
@@ -110,7 +110,7 @@ def test_is_regression():
yield is_regression, new, old
- at utils.nose_generator
+ at utils.nose.generator
def test_is_fix():
""" Generates all tests for fixes """
def is_fix(new, old):
@@ -124,7 +124,7 @@ def test_is_fix():
yield is_fix, new, old
- at utils.nose_generator
+ at utils.nose.generator
def test_is_change():
""" Test that status -> !status is a change """
def is_not_equivalent(new, old):
@@ -138,7 +138,7 @@ def test_is_change():
yield is_not_equivalent, new, old
- at utils.nose_generator
+ at utils.nose.generator
def test_not_change():
""" Skip and NotRun should not count as changes """
def check_not_change(new, old):
@@ -163,7 +163,7 @@ def test_not_change():
status.status_lookup(stat))
- at utils.nose_generator
+ at utils.nose.generator
def test_max_statuses():
""" Verify that max() works between skip and non-skip statuses """
def _max_nochange_stat(nochange, stat):
@@ -226,7 +226,7 @@ def check_operator_not_equal(obj, comp, op, result):
nt.assert_not_equal(op(obj, comp), result)
- at utils.nose_generator
+ at utils.nose.generator
def test_nochangestatus_magic():
""" Test that operators unique to NoChangeStatus work """
obj = status.NoChangeStatus('Test')
@@ -247,7 +247,7 @@ def test_nochangestatus_magic():
yield check_operator_not_equal, obj, comp, lambda x, y: x.__ne__(y), True
- at utils.nose_generator
+ at utils.nose.generator
def test_status_magic():
""" Generator for testing magic methods in the Status class """
obj = status.Status('foo', 0, (0, 0))
diff --git a/unittests/summary_common_tests.py b/unittests/summary_common_tests.py
index cfc9beb..50da94d 100644
--- a/unittests/summary_common_tests.py
+++ b/unittests/summary_common_tests.py
@@ -261,7 +261,7 @@ class TestNamesSubtests(object):
nt.ok_(expected in source,
msg='{} not found in {}'.format(expected, source))
- @utils.nose_generator
+ @utils.nose.generator
def test_gen_tests(self):
"""generate a bunch of different tests."""
def test(attr):
@@ -321,7 +321,7 @@ class TestNamesSingle(object):
cls.test = summary.Results([res])
- @utils.nose_generator
+ @utils.nose.generator
def test_compare_status(self):
"""Test statuses that require comparisons.
@@ -335,7 +335,7 @@ class TestNamesSingle(object):
'returns empty set'.format(each))
yield test, each
- @utils.nose_generator
+ @utils.nose.generator
def test_index_zero(self):
"""Test status that return the non-all value in index 0
diff --git a/unittests/summary_console_tests.py b/unittests/summary_console_tests.py
index 2bca7e4..be39f7e 100644
--- a/unittests/summary_console_tests.py
+++ b/unittests/summary_console_tests.py
@@ -122,7 +122,7 @@ class Test_print_summary(object):
cls.actual = get_stdout(
lambda: console_._print_summary(reses)).split('\n')
- @utils.nose_generator
+ @utils.nose.generator
def test_values(self):
"""Generate a bunch of tests."""
def test(value):
diff --git a/unittests/summary_html_tests.py b/unittests/summary_html_tests.py
index d3c28fe..1474ca5 100644
--- a/unittests/summary_html_tests.py
+++ b/unittests/summary_html_tests.py
@@ -43,7 +43,7 @@ from framework.summary import html_
from . import utils
- at utils.test_in_tempdir
+ at utils.nose.test_in_tempdir
def test_copy_static():
"""summary.html_._copy_static: puts status content in correct locations"""
html_._copy_static_files(getcwd())
diff --git a/unittests/test_lists.py b/unittests/test_lists.py
index cf5bdda..7707e64 100644
--- a/unittests/test_lists.py
+++ b/unittests/test_lists.py
@@ -37,7 +37,7 @@ from nose.plugins.skip import SkipTest
from . import utils
- at utils.nose_generator
+ at utils.nose.generator
def gen_test_import():
""" Generates a bunch of tests to import the various test modules """
def check_import(module):
diff --git a/unittests/utils/__init__.py b/unittests/utils/__init__.py
new file mode 100644
index 0000000..1ad988f
--- /dev/null
+++ b/unittests/utils/__init__.py
@@ -0,0 +1 @@
+from . import nose, piglit
diff --git a/unittests/utils.py b/unittests/utils/nose.py
similarity index 70%
rename from unittests/utils.py
rename to unittests/utils/nose.py
index 99cf482..573b573 100644
--- a/unittests/utils.py
+++ b/unittests/utils/nose.py
@@ -1,4 +1,5 @@
-# Copyright (c) 2014 Intel Coporation
+# encoding=utf-8
+# Copyright (c) 2014-2016 Intel Coporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -18,31 +19,27 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-""" Common helpers for framework tests
+"""Nose extenders for framework tests.
-This module collects common tools that are needed in more than one test module
-in a single place.
+This module collects useful tools that extend the functionality ro fix issues
+in the nose suite. None of these features are piglit specific, they're all
+generic.
"""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
+import errno
+import functools
+import importlib
import os
-import sys
-import copy
import shutil
-import tempfile as tempfile_
-import functools
import subprocess
-import errno
-import importlib
+import sys
+import tempfile as tempfile_
from contextlib import contextmanager
-try:
- import simplejson as json
-except ImportError:
- import json
from nose.plugins.skip import SkipTest
import six
try:
@@ -55,52 +52,12 @@ except ImportError:
getcwd = os.getcwd
# pylint: enable=no-member
-from framework import test, backends, core, results, compat
-
-__all__ = [
- 'tempfile',
- 'resultfile',
- 'tempdir',
- 'JSON_DATA'
-]
-
-core.get_config()
+from framework import compat
_WRITE_MODE = 'w'
_READ_MODE = 'r'
-class _Tree(dict):
- """Private helper to make JSON_DATA easier to work with."""
- def __getitem__(self, key):
- try:
- return super(_Tree, self).__getitem__(key)
- except KeyError:
- ret = self[key] = _Tree()
- return ret
-
-
-JSON_DATA = {
- "options": {
- "profile": "tests/fake.py",
- "filter": [],
- "exclude_filter": []
- },
- "results_version": backends.json.CURRENT_JSON_VERSION,
- "name": "fake-tests",
- "lspci": "fake",
- "glxinfo": "fake",
- "tests": _Tree({
- "sometest": {
- 'result': 'pass',
- 'time': 1.2,
- }
- })
-}
-
-_SAVED_COMPRESSION = os.environ.get('PIGLIT_COMPRESSION')
-
-
@compat.python_2_unicode_compatible
class TestFailure(AssertionError):
"""An exception to be raised when a test fails.
@@ -196,21 +153,6 @@ class DocFormatter(object):
return func
-class Test(test.Test):
- """A basic dmmmy Test class that can be used in places a test is required.
-
- This provides dummy version of abstract methods in
- framework.test.base.Test, which allows it to be initialized and run, but is
- unlikely to be useful for running.
-
- This is mainly intended for testing where a Test class is required, but
- doesn't need to be run.
-
- """
- def interpret_result(self):
- pass
-
-
class GeneratedTestWrapper(object):
""" An object proxy for nose test instances
@@ -251,22 +193,6 @@ class GeneratedTestWrapper(object):
@contextmanager
-def resultfile():
- """ Create a stringio with some json in it and pass that as results """
- data = copy.deepcopy(JSON_DATA)
- data['tests']['sometest'] = results.TestResult('pass')
- data['tests']['sometest'].time = 1.2
- data = results.TestrunResult.from_dict(data)
- with tempfile_.NamedTemporaryFile(mode=_WRITE_MODE, delete=False) as f:
- json.dump(data, f, default=backends.json.piglit_encoder)
-
- try:
- yield f
- finally:
- os.remove(f.name)
-
-
- at contextmanager
def tempfile(contents):
""" Provides a context manager for a named tempfile
@@ -300,7 +226,7 @@ def tempdir():
shutil.rmtree(tdir)
-def nose_generator(func):
+def generator(func):
""" Decorator for nose test generators to us GeneratedTestWrapper
This decorator replaces each function yeilded by a test generator with a
@@ -463,86 +389,6 @@ def set_env(**envargs):
return _decorator
-def set_piglit_conf(*values):
- """Decorator that sets and then usets values from core.PIGLIT_CONF.
-
- This decorator takes arguments for sections and options to overwrite in
- piglit.conf. It will first backup any options to be overwritten, and store
- any options that don't exist. Then it will set those options, run the test,
- and finally restore any options overwritten, and delete any new options
- added. If value is set to NoneType the option will be removed.
-
- Arguments:
- Values -- tuples containing a section, option, and value in the form:
- (<section>, <option>, <value>)
-
- """
- def _decorator(func):
- """The actual decorator."""
-
- @functools.wraps(func)
- def _inner(*args, **kwargs):
- """The function returned by the decorator."""
- backup = set()
- remove = set()
-
- for section, key, value in values:
- get = core.PIGLIT_CONFIG.safe_get(section, key)
- # If there is a value, save that value to restore it, if there
- # is not a value AND if there is a value to set (IE: we're not
- # clearing a value if it exsists), the add it to remove
- if get is not None:
- backup.add((section, key, get))
- elif value is not None:
- remove.add((section, key))
-
- # set any new values, and remove any values that are set to
- # None
- if value is not None:
- if not core.PIGLIT_CONFIG.has_section(section):
- core.PIGLIT_CONFIG.add_section(section)
- core.PIGLIT_CONFIG.set(section, key, value)
- elif (core.PIGLIT_CONFIG.has_section(section) and
- core.PIGLIT_CONFIG.has_option(section, key)):
- core.PIGLIT_CONFIG.remove_option(section, key)
-
- try:
- func(*args, **kwargs)
- finally:
- # Restore all values
- for section, key, value in backup:
- core.PIGLIT_CONFIG.set(section, key, value)
- for section, key in remove:
- core.PIGLIT_CONFIG.remove_option(section, key)
-
- return _inner
- return _decorator
-
-
-def set_compression(mode):
- """lock piglit compression mode to specifed value.
-
- Meant to be called from setup_module function.
-
- """
- # The implimentation details of this is that the environment value is the
- # first value looked at for setting compression, so if it's set all other
- # values will be ignored.
- os.environ['PIGLIT_COMPRESSION'] = mode
-
-
-def unset_compression():
- """Restore compression to the origonal value.
-
- Counterpart to set_compression. Should be called from teardown_module.
-
- """
- if _SAVED_COMPRESSION is not None:
- os.environ['PIGLIT_COMPRESSION'] = _SAVED_COMPRESSION
- else:
- del os.environ['PIGLIT_COMPRESSION']
-
-
def skip(condition, description):
"""Skip a test if the condition is met.
diff --git a/unittests/utils/piglit.py b/unittests/utils/piglit.py
new file mode 100644
index 0000000..34edc6e
--- /dev/null
+++ b/unittests/utils/piglit.py
@@ -0,0 +1,189 @@
+#encoding=utf-8
+# Copyright (c) 2014-2016 Intel Coporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""Piglit specific helpers
+
+These helpers are all piglit specific tools.
+
+"""
+
+from __future__ import (
+ absolute_import, division, print_function, unicode_literals
+)
+from contextlib import contextmanager
+import copy
+import functools
+import os
+import tempfile as tempfile_
+
+try:
+ import simplejson as json
+except ImportError:
+ import json
+
+from framework import test, backends, core, results
+
+core.get_config()
+
+_WRITE_MODE = 'w'
+_READ_MODE = 'r'
+
+
+class _Tree(dict):
+ """Private helper to make JSON_DATA easier to work with."""
+ def __getitem__(self, key):
+ try:
+ return super(_Tree, self).__getitem__(key)
+ except KeyError:
+ ret = self[key] = _Tree()
+ return ret
+
+
+JSON_DATA = {
+ "options": {
+ "profile": "tests/fake.py",
+ "filter": [],
+ "exclude_filter": []
+ },
+ "results_version": backends.json.CURRENT_JSON_VERSION,
+ "name": "fake-tests",
+ "lspci": "fake",
+ "glxinfo": "fake",
+ "tests": _Tree({
+ "sometest": {
+ 'result': 'pass',
+ 'time': 1.2,
+ }
+ })
+}
+
+_SAVED_COMPRESSION = os.environ.get('PIGLIT_COMPRESSION')
+
+
+class Test(test.Test):
+ """A basic dmmmy Test class that can be used in places a test is required.
+
+ This provides dummy version of abstract methods in
+ framework.test.base.Test, which allows it to be initialized and run, but is
+ unlikely to be useful for running.
+
+ This is mainly intended for testing where a Test class is required, but
+ doesn't need to be run.
+
+ """
+ def interpret_result(self):
+ pass
+
+
+ at contextmanager
+def resultfile():
+ """ Create a stringio with some json in it and pass that as results """
+ data = copy.deepcopy(JSON_DATA)
+ data['tests']['sometest'] = results.TestResult('pass')
+ data['tests']['sometest'].time = 1.2
+ data = results.TestrunResult.from_dict(data)
+ with tempfile_.NamedTemporaryFile(mode=_WRITE_MODE, delete=False) as f:
+ json.dump(data, f, default=backends.json.piglit_encoder)
+
+ try:
+ yield f
+ finally:
+ os.remove(f.name)
+
+
+def set_piglit_conf(*values):
+ """Decorator that sets and then usets values from core.PIGLIT_CONF.
+
+ This decorator takes arguments for sections and options to overwrite in
+ piglit.conf. It will first backup any options to be overwritten, and store
+ any options that don't exist. Then it will set those options, run the test,
+ and finally restore any options overwritten, and delete any new options
+ added. If value is set to NoneType the option will be removed.
+
+ Arguments:
+ Values -- tuples containing a section, option, and value in the form:
+ (<section>, <option>, <value>)
+
+ """
+ def _decorator(func):
+ """The actual decorator."""
+
+ @functools.wraps(func)
+ def _inner(*args, **kwargs):
+ """The function returned by the decorator."""
+ backup = set()
+ remove = set()
+
+ for section, key, value in values:
+ get = core.PIGLIT_CONFIG.safe_get(section, key)
+ # If there is a value, save that value to restore it, if there
+ # is not a value AND if there is a value to set (IE: we're not
+ # clearing a value if it exsists), the add it to remove
+ if get is not None:
+ backup.add((section, key, get))
+ elif value is not None:
+ remove.add((section, key))
+
+ # set any new values, and remove any values that are set to
+ # None
+ if value is not None:
+ if not core.PIGLIT_CONFIG.has_section(section):
+ core.PIGLIT_CONFIG.add_section(section)
+ core.PIGLIT_CONFIG.set(section, key, value)
+ elif (core.PIGLIT_CONFIG.has_section(section) and
+ core.PIGLIT_CONFIG.has_option(section, key)):
+ core.PIGLIT_CONFIG.remove_option(section, key)
+
+ try:
+ func(*args, **kwargs)
+ finally:
+ # Restore all values
+ for section, key, value in backup:
+ core.PIGLIT_CONFIG.set(section, key, value)
+ for section, key in remove:
+ core.PIGLIT_CONFIG.remove_option(section, key)
+
+ return _inner
+ return _decorator
+
+
+def set_compression(mode):
+ """lock piglit compression mode to specifed value.
+
+ Meant to be called from setup_module function.
+
+ """
+ # The implimentation details of this is that the environment value is the
+ # first value looked at for setting compression, so if it's set all other
+ # values will be ignored.
+ os.environ['PIGLIT_COMPRESSION'] = mode
+
+
+def unset_compression():
+ """Restore compression to the origonal value.
+
+ Counterpart to set_compression. Should be called from teardown_module.
+
+ """
+ if _SAVED_COMPRESSION is not None:
+ os.environ['PIGLIT_COMPRESSION'] = _SAVED_COMPRESSION
+ else:
+ del os.environ['PIGLIT_COMPRESSION']
--
2.8.3
More information about the Piglit
mailing list