Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subtest support (https://github.com/CleanCut/green/issues/111) #167

Merged
merged 1 commit into from
Aug 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion green/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ class ProtoTest():
"""
def __init__(self, test=None):
if test:
method_parts = str(test).split(None, 2)
if hasattr(test, 'test_case'):
test = test.test_case
self.module = test.__module__
self.class_name = test.__class__.__name__
self.method_name = str(test).split()[0]
self.method_name = method_parts[0] if len(method_parts) < 3 \
else ' '.join((method_parts[0], method_parts[2]))
# docstr_part strips initial whitespace, then combines all lines
# into one string until the first completely blank line in the
# docstring
Expand Down Expand Up @@ -182,6 +186,7 @@ def __init__(self, start_callback=None, finalize_callback=None):
'stdout_output',
'unexpectedSuccesses',
]
self.failfast = False
self.reinitialize()

def reinitialize(self):
Expand Down Expand Up @@ -281,6 +286,13 @@ def addUnexpectedSuccess(self, test):
"""
self.unexpectedSuccesses.append(proto_test(test))

def addSubTest(self, test, subtest, err):
if err is not None:
if issubclass(err[0], test.failureException):
self.addFailure(subtest, err)
else:
self.addError(subtest, err)


class GreenTestResult(BaseTestResult):
"""
Expand Down