Debian Codegraph @

testenv/conf/expected_ret_code.py

raw
1 from exc.test_failed import TestFailed
2 from conf import hook
3
4 """ Post-Test Hook: ExpectedRetCode
5 This is a post-test hook which checks if the exit code of the Wget instance
6 under test is the same as that expected. As a result, this is a very important
7 post test hook which is checked in all the tests.
8 Returns a TestFailed exception if the return code does not match the expected
9 value. Else returns gracefully.
10 """
11
12
13 @hook(alias='ExpectedRetcode')
14 class ExpectedRetCode:
15 def __init__(self, expected_ret_code):
16 self.expected_ret_code = expected_ret_code
17
18 def __call__(self, test_obj):
19 if test_obj.ret_code != self.expected_ret_code:
20 if test_obj.ret_code == 45:
21 failure = "Memory Leak Found by Valgrind"
22 else:
23 failure = "Return codes do not match.\n" \
24 "Expected: %s\n" \
25 "Actual: %s" % (self.expected_ret_code,
26 test_obj.ret_code)
27 raise TestFailed(failure)