[Piglit] [PATCH 10/18] programs_tests.py: Move more code into a shared method
Dylan Baker
baker.dylan.c at gmail.com
Tue Aug 19 13:25:04 PDT 2014
This adds a private method to TestGetConfig to allow more code sharing
between the tests.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/tests/programs_tests.py | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/framework/tests/programs_tests.py b/framework/tests/programs_tests.py
index fbd9f20..a395b76 100644
--- a/framework/tests/programs_tests.py
+++ b/framework/tests/programs_tests.py
@@ -46,10 +46,14 @@ def _reset_piglit_config():
class TestGetConfig(utils.TestWithEnvClean):
- def test_xdg_config_home(self):
- """ get_config() finds $XDG_CONFIG_HOME/piglit.conf """
+ def __unset_config(self):
self.defer(_reset_piglit_config)
self.add_teardown('XDG_CONFIG_HOME')
+ self.add_teardown('HOME')
+
+ def test_xdg_config_home(self):
+ """ get_config() finds $XDG_CONFIG_HOME/piglit.conf """
+ self.__unset_config()
if os.path.exists('piglit.conf'):
shutil.move('piglit.conf', 'piglit.conf.restore')
self.defer(shutil.move, 'piglit.conf.restore', 'piglit.conf')
@@ -65,9 +69,7 @@ class TestGetConfig(utils.TestWithEnvClean):
def test_config_home_fallback(self):
""" get_config() finds $HOME/.config/piglit.conf """
- self.defer(_reset_piglit_config)
- self.add_teardown('XDG_CONFIG_HOME')
- self.add_teardown('HOME')
+ self.__unset_config()
if os.path.exists('piglit.conf'):
shutil.move('piglit.conf', 'piglit.conf.restore')
self.defer(shutil.move, 'piglit.conf.restore', 'piglit.conf')
@@ -84,9 +86,7 @@ class TestGetConfig(utils.TestWithEnvClean):
def test_local(self):
""" get_config() finds ./piglit.conf """
- self.defer(_reset_piglit_config)
- self.add_teardown('HOME')
- self.add_teardown('XDG_CONFIG_HOME')
+ self.__unset_config()
if os.path.exists('piglit.conf'):
shutil.move('piglit.conf', 'piglit.conf.restore')
self.defer(shutil.move, 'piglit.conf.restore', 'piglit.conf')
@@ -105,10 +105,7 @@ class TestGetConfig(utils.TestWithEnvClean):
def test_piglit_root(self):
""" get_config() finds "piglit root"/piglit.conf """
- self.defer(_reset_piglit_config)
- self.add_teardown('HOME')
- self.add_teardown('XDG_CONFIG_HOME')
-
+ self.__unset_config()
if os.path.exists('piglit.conf'):
shutil.move('piglit.conf', 'piglit.conf.restore')
self.defer(shutil.move, 'piglit.conf.restore', 'piglit.conf')
--
2.0.4
More information about the Piglit
mailing list