Skip to content

Commit

Permalink
#11610 Switch disttrial AMP responders to use decorator syntax (#11611)
Browse files Browse the repository at this point in the history
  • Loading branch information
exarkun authored Aug 26, 2022
2 parents d468700 + d36716a commit 53fc46f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Empty file.
21 changes: 7 additions & 14 deletions src/twisted/trial/_dist/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,14 @@ class LocalWorkerAMP(AMP):
Local implementation of the manager commands.
"""

@managercommands.AddSuccess.responder
def addSuccess(self, testName):
"""
Add a success to the reporter.
"""
self._result.addSuccess(self._testCase)
return {"success": True}

managercommands.AddSuccess.responder(addSuccess)

def _buildFailure(
self,
error: WorkerException,
Expand Down Expand Up @@ -134,6 +133,7 @@ def _buildFailure(
)
return failure

@managercommands.AddError.responder
def addError(
self,
testName: str,
Expand All @@ -154,8 +154,7 @@ def addError(
self._result.addError(self._testCase, failure)
return {"success": True}

managercommands.AddError.responder(addError)

@managercommands.AddFailure.responder
def addFailure(
self,
testName: str,
Expand All @@ -171,17 +170,15 @@ def addFailure(
self._result.addFailure(self._testCase, failure)
return {"success": True}

managercommands.AddFailure.responder(addFailure)

@managercommands.AddSkip.responder
def addSkip(self, testName, reason):
"""
Add a skip to the reporter.
"""
self._result.addSkip(self._testCase, reason)
return {"success": True}

managercommands.AddSkip.responder(addSkip)

@managercommands.AddExpectedFailure.responder
def addExpectedFailure(
self, testName: str, error: str, todo: Optional[None]
) -> Dict[str, bool]:
Expand All @@ -192,17 +189,15 @@ def addExpectedFailure(
self._result.addExpectedFailure(self._testCase, error, _todo)
return {"success": True}

managercommands.AddExpectedFailure.responder(addExpectedFailure)

@managercommands.AddUnexpectedSuccess.responder
def addUnexpectedSuccess(self, testName, todo):
"""
Add an unexpected success to the reporter.
"""
self._result.addUnexpectedSuccess(self._testCase, todo)
return {"success": True}

managercommands.AddUnexpectedSuccess.responder(addUnexpectedSuccess)

@managercommands.TestWrite.responder
def testWrite(self, out):
"""
Print test output from the worker.
Expand All @@ -211,8 +206,6 @@ def testWrite(self, out):
self._testStream.flush()
return {"success": True}

managercommands.TestWrite.responder(testWrite)

def _stopTest(self, result):
"""
Stop the current running test case, forwarding the result.
Expand Down

0 comments on commit 53fc46f

Please sign in to comment.