Cause the test to fail. By default, the fail_test() method reports that the test FAILED and exits with a status of 1. If a condition argument is supplied, the test fails only if the condition is true.
(self=None, condition=True, function=None, skip=0)
| 101 | |
| 102 | |
| 103 | def fail_test(self=None, condition=True, function=None, skip=0): |
| 104 | """Cause the test to fail. |
| 105 | |
| 106 | By default, the fail_test() method reports that the test FAILED and exits |
| 107 | with a status of 1. If a condition argument is supplied, the test fails |
| 108 | only if the condition is true. |
| 109 | |
| 110 | """ |
| 111 | if not condition: |
| 112 | return |
| 113 | if not function is None: |
| 114 | function() |
| 115 | of = "" |
| 116 | desc = "" |
| 117 | sep = " " |
| 118 | if not self is None: |
| 119 | if self.program: |
| 120 | of = " of " + join(self.program, " ") |
| 121 | sep = "\n\t" |
| 122 | if self.description: |
| 123 | desc = " [" + self.description + "]" |
| 124 | sep = "\n\t" |
| 125 | |
| 126 | at = caller(traceback.extract_stack(), skip) |
| 127 | |
| 128 | sys.stderr.write("FAILED test" + of + desc + sep + at + """ |
| 129 | in directory: """ + os.getcwd() ) |
| 130 | sys.exit(1) |
| 131 | |
| 132 | |
| 133 | def no_result(self=None, condition=True, function=None, skip=0): |