Fix test bug causing wrong print order
Print test info in the constructor of TestInfo rather than when the
test is attached. This ensures that test info is printed to
standard out in the correct order.
@@ -37,12 +37,14 @@ class TestInfo(object):
FAILURE: "Failure: %s",
}
- def __init__(self, name):
+ def __init__(self, name, init_print=True):
self._all = []
self.failures = 0
self.warnings = 0
self.infos = 0
self.name = name
+ if init_print:
+ self._print_msg("SubTest: " + name)
def failure(self, msg):
assert isinstance(msg, six.string_types)
@@ -159,7 +161,7 @@ class TestInfo(object):
def _add_entry(self, entry_type, msg):
if entry_type is self.SUBTEST:
assert isinstance(msg, TestInfo)
- self._print_msg("SubTest: " + msg.get_name())
+ # Test name printed in constructor
else:
assert isinstance(msg, six.string_types)
self._print_msg(msg)
@@ -173,7 +175,7 @@ class TestInfo(object):
class TestInfoStub(TestInfo):
def __init__(self):
- super(TestInfoStub, self).__init__('stub test')
+ super(TestInfoStub, self).__init__('stub test', False)
def create_subtest(self, name):
assert isinstance(name, six.string_types)
