Fix setUp/tearDown scope

failure
Marek Ventur 2018-07-22 11:20:56 +01:00
parent af162a7134
commit c0364e333f
1 changed files with 10 additions and 2 deletions

View File

@ -15,7 +15,7 @@ class FailTest(Exception):
class TestCase(object):
def run(self):
test_class = type(self).__name__
self.setUp()
self.setUpClass()
self.count_pass = 0
self.count_fail = 0
self.count_skip = 0
@ -23,7 +23,9 @@ class TestCase(object):
if not method.startswith("test"):
continue
try:
self.setUp()
getattr(self, method)()
self.tearDown()
print("%s.%s [PASS]" % (test_class, method))
self.count_pass += 1
except SkipTest as e:
@ -38,7 +40,7 @@ class TestCase(object):
sys.print_exception(e)
print("")
self.count_fail += 1
self.tearDown()
self.tearDownClass()
return self.count_fail == 0
def run_standalone(self):
@ -54,6 +56,12 @@ class TestCase(object):
def tearDown(self):
pass
def setUpClass(self):
pass
def tearDownClass(self):
pass
def assertEqual(self, actual, expected):
if not actual == expected:
raise FailTest("Expected %s to equal %s" % (actual, expected))