-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestcase.py
37 lines (30 loc) · 982 Bytes
/
testcase.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# ======================================================================
#
# Copyright (C) 2016 Kay Schluehr (kay@fiber-space.de)
#
# t3testcase.py, v B.0 2016/03/03
#
# ======================================================================
__all__ = ["T3TestCase", "ExpectFailure"]
import abc
import sys
import os
import traceback
import time
from t3.pattern import MatchingFailure
class ExpectFailure(Exception): pass
class T3TestCase(object):
def __enter__(self):
settings["testcnt"]+=1
return self
def __exit__(self, typ, value, tb):
if typ:
if typ in (AssertionError, MatchingFailure, ExpectFailure):
settings["failcnt"]+=1
self._status = "FAIL"
sys.stderr.write("\n<< TEST FAILED >>\n")
else:
settings["errcnt"]+=1
self._status = "ERROR"
traceback.print_exc()
return True