[Piglit] [PATCH 14/18] framework: Merge programs_tests.py into core_tests.py
Dylan Baker
baker.dylan.c at gmail.com
Tue Aug 19 13:25:08 PDT 2014
Commit 9e0c3ee1 moved get_config() out of the programs/run.py into
core.py, since the only tests in programs_tests.py are for get_config
once they are moved into the more appropriate core module the
programs_tests module is empty and can be deleted.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/tests/core_tests.py | 82 +++++++++++++++++++++++++++
framework/tests/programs_tests.py | 113 --------------------------------------
2 files changed, 82 insertions(+), 113 deletions(-)
delete mode 100644 framework/tests/programs_tests.py
diff --git a/framework/tests/core_tests.py b/framework/tests/core_tests.py
index cd01f22..7ed3eb1 100644
--- a/framework/tests/core_tests.py
+++ b/framework/tests/core_tests.py
@@ -23,10 +23,19 @@
import os
import collections
+import shutil
+import ConfigParser
+import textwrap
+import nose.tools as nt
import framework.tests.utils as utils
import framework.core as core
+def _reset_piglit_config():
+ """ Set core.PIGLIT_CONFIG back to pristine """
+ core.PIGLIT_CONFIG = ConfigParser.SafeConfigParser()
+
+
def check_initialize(target):
""" Check that a class initializes without error """
func = target()
@@ -111,3 +120,76 @@ def test_parse_listfile_tilde():
results = core.parse_listfile(tfile)
assert results[0] == os.path.expandvars("$HOME/foo")
+
+
+class TestGetConfig(utils.TestWithEnvClean):
+ CONF_FILE = textwrap.dedent("""
+ [nose-test]
+ ; a section for testing behavior
+ dir = foo
+ """)
+
+ def __unset_config(self):
+ self.defer(_reset_piglit_config)
+ self.add_teardown('XDG_CONFIG_HOME')
+ self.add_teardown('HOME')
+
+ def __move_local(self):
+ """ Move a local piglit.conf so it isn't overwritten """
+ if os.path.exists('piglit.conf'):
+ shutil.move('piglit.conf', 'piglit.conf.restore')
+ self.defer(shutil.move, 'piglit.conf.restore', 'piglit.conf')
+
+ def setup(self):
+ self.__unset_config()
+ self.__move_local()
+
+ def test_xdg_config_home(self):
+ """ get_config() finds $XDG_CONFIG_HOME/piglit.conf """
+ with utils.tempdir() as tdir:
+ os.environ['XDG_CONFIG_HOME'] = tdir
+ with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
+ f.write(TestGetConfig.CONF_FILE)
+ core.get_config()
+
+ nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
+ msg='$XDG_CONFIG_HOME not found')
+
+ def test_config_home_fallback(self):
+ """ get_config() finds $HOME/.config/piglit.conf """
+ with utils.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:
+ f.write(TestGetConfig.CONF_FILE)
+ core.get_config()
+
+ nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
+ msg='$HOME/.config/piglit.conf not found')
+
+ def test_local(self):
+ """ get_config() finds ./piglit.conf """
+ with utils.tempdir() as tdir:
+ self.defer(os.chdir, os.getcwd())
+ os.chdir(tdir)
+
+ with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
+ f.write(TestGetConfig.CONF_FILE)
+
+ core.get_config()
+
+ nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
+ msg='./piglit.conf not found')
+
+ def test_piglit_root(self):
+ """ get_config() finds "piglit root"/piglit.conf """
+ with open('piglit.conf', 'w') as f:
+ f.write(TestGetConfig.CONF_FILE)
+ self.defer(os.unlink, 'piglit.conf')
+ self.defer(os.chdir, os.getcwd())
+ os.chdir('..')
+
+ core.get_config()
+
+ nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
+ msg='$PIGLIT_ROOT not found')
diff --git a/framework/tests/programs_tests.py b/framework/tests/programs_tests.py
deleted file mode 100644
index e1346cb..0000000
--- a/framework/tests/programs_tests.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright (c) 2014 Intel Corporation
-
-# 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.
-
-
-""" Tests for the programs package
-
-Currently there aren't very many tests for the modules in this package, so just
-having a single test module seems appropriate
-
-"""
-
-import os
-import shutil
-import ConfigParser
-import textwrap
-import framework.core as core
-import framework.tests.utils as utils
-import nose.tools as nt
-
-
-def _reset_piglit_config():
- """ Set core.PIGLIT_CONFIG back to pristine """
- core.PIGLIT_CONFIG = ConfigParser.SafeConfigParser()
-
-
-class TestGetConfig(utils.TestWithEnvClean):
- CONF_FILE = textwrap.dedent("""
- [nose-test]
- ; a section for testing behavior
- dir = foo
- """)
-
- def __unset_config(self):
- self.defer(_reset_piglit_config)
- self.add_teardown('XDG_CONFIG_HOME')
- self.add_teardown('HOME')
-
- def __move_local(self):
- """ Move a local piglit.conf so it isn't overwritten """
- if os.path.exists('piglit.conf'):
- shutil.move('piglit.conf', 'piglit.conf.restore')
- self.defer(shutil.move, 'piglit.conf.restore', 'piglit.conf')
-
- def setup(self):
- self.__unset_config()
- self.__move_local()
-
- def test_xdg_config_home(self):
- """ get_config() finds $XDG_CONFIG_HOME/piglit.conf """
- with utils.tempdir() as tdir:
- os.environ['XDG_CONFIG_HOME'] = tdir
- with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
- f.write(TestGetConfig.CONF_FILE)
- core.get_config()
-
- nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
- msg='$XDG_CONFIG_HOME not found')
-
- def test_config_home_fallback(self):
- """ get_config() finds $HOME/.config/piglit.conf """
- with utils.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:
- f.write(TestGetConfig.CONF_FILE)
- core.get_config()
-
- nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
- msg='$HOME/.config/piglit.conf not found')
-
- def test_local(self):
- """ get_config() finds ./piglit.conf """
- with utils.tempdir() as tdir:
- self.defer(os.chdir, os.getcwd())
- os.chdir(tdir)
-
- with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
- f.write(TestGetConfig.CONF_FILE)
-
- core.get_config()
-
- nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
- msg='./piglit.conf not found')
-
- def test_piglit_root(self):
- """ get_config() finds "piglit root"/piglit.conf """
- with open('piglit.conf', 'w') as f:
- f.write(TestGetConfig.CONF_FILE)
- self.defer(os.unlink, 'piglit.conf')
- self.defer(os.chdir, os.getcwd())
- os.chdir('..')
-
- core.get_config()
-
- nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
- msg='$PIGLIT_ROOT not found')
--
2.0.4
More information about the Piglit
mailing list