diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2015-10-15 15:13:24 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2016-01-21 14:13:33 -0800 |
commit | e0114dc63ace991e6d91177456cd60c78bee9c45 (patch) | |
tree | dde59c3dded3f5ad16c0e7272cf90dab5f3e5797 | |
parent | 5d2830bdcc591b9b86f0525e12cc25c73d812733 (diff) |
framework/tests/base_tests.py: use utils helper to simplify test
This just saves some code duplication.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r-- | unittests/base_tests.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/unittests/base_tests.py b/unittests/base_tests.py index 762c6e5e6..9fcf8eb61 100644 --- a/unittests/base_tests.py +++ b/unittests/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') -@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') |