[Piglit] [PATCH v4 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
Tue Dec 1 14:52:12 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 a825e3d..2017a57 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.2



More information about the Piglit mailing list