[Piglit] [PATCH v5 3/4] framework/tests/base_tests.py: use utils helper to simplify test

baker.dylan.c at gmail.com baker.dylan.c at gmail.com
Wed Dec 16 16:52:51 PST 2015


From: Dylan Baker <baker.dylan.c at gmail.com>

This just saves some code duplication.

v3: - fix tests to actually work.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/tests/base_tests.py | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/framework/tests/base_tests.py b/framework/tests/base_tests.py
index 31143b6..453ee50 100644
--- a/framework/tests/base_tests.py
+++ b/framework/tests/base_tests.py
@@ -52,6 +52,11 @@ class TestTest(Test):
         self.test_interpret_result()
 
 
+class TimeoutTest(Test):
+    def interpret_result(self):
+        super(TimeoutTest, self).interpret_result()
+
+
 # Tests
 def test_run_return_early():
     """ Test.run() exits early when Test._run_command() has exception """
@@ -70,29 +75,20 @@ def test_timeout():
     """test.base.Test.run(): Sets status to 'timeout' when timeout exceeded"""
     utils.binary_check('sleep', 1)
 
-    class _Test(Test):
-        def interpret_result(self):
-            super(_Test, self).interpret_result()
-
-    test = _Test(['sleep', '60'])
+    test = TimeoutTest(['sleep', '60'])
     test.timeout = 1
     test.run()
     nt.eq_(test.result.result, 'timeout')
 
 
- at attr('slow')
 def test_timeout_pass():
     """test.base.Test.run(): Doesn't change status when timeout not exceeded
     """
     utils.binary_check('true')
 
-    def helper():
-        if (test.result.returncode == 0):
-            test.result.result = "pass"
-
-    test = TestTest(['true'])
-    test.test_interpret_result = helper
+    test = TimeoutTest(['true'])
     test.timeout = 1
+    test.result.result = 'pass'
     test.run()
     nt.eq_(test.result.result, 'pass')
 
-- 
2.6.4



More information about the Piglit mailing list