[Piglit] [PATCH 12/18] programs_tests.py: Put private methods that are always used in setup
Dylan Baker
baker.dylan.c at gmail.com
Tue Aug 19 13:25:06 PDT 2014
This moves calls to __move_local and __unset_config into setup(), which
is called before each method. This reduces the code duplication even
further.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/tests/programs_tests.py | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/framework/tests/programs_tests.py b/framework/tests/programs_tests.py
index 2c114b4..3f32b8b 100644
--- a/framework/tests/programs_tests.py
+++ b/framework/tests/programs_tests.py
@@ -57,11 +57,12 @@ class TestGetConfig(utils.TestWithEnvClean):
shutil.move('piglit.conf', 'piglit.conf.restore')
self.defer(shutil.move, 'piglit.conf.restore', 'piglit.conf')
- def test_xdg_config_home(self):
- """ get_config() finds $XDG_CONFIG_HOME/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:
@@ -73,9 +74,6 @@ class TestGetConfig(utils.TestWithEnvClean):
def test_config_home_fallback(self):
""" get_config() finds $HOME/.config/piglit.conf """
- self.__unset_config()
- self.__move_local()
-
with utils.tempdir() as tdir:
os.environ['HOME'] = tdir
os.mkdir(os.path.join(tdir, '.config'))
@@ -88,9 +86,6 @@ class TestGetConfig(utils.TestWithEnvClean):
def test_local(self):
""" get_config() finds ./piglit.conf """
- self.__unset_config()
- self.__move_local()
-
with utils.tempdir() as tdir:
self.defer(os.chdir, os.getcwd())
os.chdir(tdir)
@@ -105,9 +100,6 @@ class TestGetConfig(utils.TestWithEnvClean):
def test_piglit_root(self):
""" get_config() finds "piglit root"/piglit.conf """
- self.__unset_config()
- self.__move_local()
-
with open('piglit.conf', 'w') as f:
f.write(CONF_FILE)
self.defer(os.unlink, 'piglit.conf')
--
2.0.4
More information about the Piglit
mailing list