[Piglit] [PATCH 13/18] programs_tests.py: move CONF_FILE into the TestGetConfig class

Dylan Baker baker.dylan.c at gmail.com
Tue Aug 19 13:25:07 PDT 2014


This constant is only used for these tests, and this will make the next
patch cleaner.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/tests/programs_tests.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/framework/tests/programs_tests.py b/framework/tests/programs_tests.py
index 3f32b8b..e1346cb 100644
--- a/framework/tests/programs_tests.py
+++ b/framework/tests/programs_tests.py
@@ -29,16 +29,11 @@ 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
 
-CONF_FILE = """
-[nose-test]
-; a section for testing behavior
-dir = foo
-"""
-
 
 def _reset_piglit_config():
     """ Set core.PIGLIT_CONFIG back to pristine """
@@ -46,6 +41,12 @@ def _reset_piglit_config():
 
 
 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')
@@ -66,7 +67,7 @@ class TestGetConfig(utils.TestWithEnvClean):
         with utils.tempdir() as tdir:
             os.environ['XDG_CONFIG_HOME'] = tdir
             with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
-                f.write(CONF_FILE)
+                f.write(TestGetConfig.CONF_FILE)
             core.get_config()
 
         nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
@@ -78,7 +79,7 @@ class TestGetConfig(utils.TestWithEnvClean):
             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(CONF_FILE)
+                f.write(TestGetConfig.CONF_FILE)
             core.get_config()
 
         nt.ok_(core.PIGLIT_CONFIG.has_section('nose-test'),
@@ -91,7 +92,7 @@ class TestGetConfig(utils.TestWithEnvClean):
             os.chdir(tdir)
 
             with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
-                f.write(CONF_FILE)
+                f.write(TestGetConfig.CONF_FILE)
 
             core.get_config()
 
@@ -101,7 +102,7 @@ class TestGetConfig(utils.TestWithEnvClean):
     def test_piglit_root(self):
         """ get_config() finds "piglit root"/piglit.conf """
         with open('piglit.conf', 'w') as f:
-            f.write(CONF_FILE)
+            f.write(TestGetConfig.CONF_FILE)
         self.defer(os.unlink, 'piglit.conf')
         self.defer(os.chdir, os.getcwd())
         os.chdir('..')
-- 
2.0.4



More information about the Piglit mailing list