Opened 4 years ago

Closed 4 years ago

#6380 enhancement closed fixed (fixed)

Add optional expected exception types to failureResultOf

Reported by: Ying Li Owned by: Ying Li
Priority: normal Milestone:
Component: core Keywords: easy
Cc: Branch: branches/failureResultOf-optional-types-6380
branch-diff, diff-cov, branch-cov, buildbot
Author: cyli


It would be nice to be able to pass optional errors to twisted.trial.unittest.TestCase.failureResultOf to check which errors are supposed to have been raised similar to (like assertRaises)

Split from #6377

Change History (9)

comment:1 Changed 4 years ago by Ying Li

(In [37627]) Add optional expected failures to failureResultOf. refs #6380

comment:2 Changed 4 years ago by Ying Li

(In [37629]) Fix bug - Failure.check([]) also returns None. refs #6380

comment:3 Changed 4 years ago by Ying Li

Keywords: easy review added
Owner: Ying Li deleted

comment:4 Changed 4 years ago by Tom Prince

Author: cyli
Branch: branches/failureResultOf-optional-types-6380

comment:5 Changed 4 years ago by Tom Prince

Keywords: review removed
Owner: set to Ying Li
  1. There is one twistedchecker error.
  2. The names of test_withFailureResult and test_withExpectedFailureResult seem reversed.
  3. It would be good to test that the that the initial message is what is expected, in the case where no type, one type and multiple types are passed.
  4. I guess that it is more complicate than it is worth, to list things as "ex1, ex2 or ex3". That might be worth a follow up ticket, to implement a utility function somewhere in twisted.python.

Please merge after addressing 1+2+3.

comment:6 Changed 4 years ago by Ying Li

(In [37830]) Address review comments with regards to variable and method names and extra tests on the error message. refs #6380

comment:7 Changed 4 years ago by Ying Li

(In [37832]) Fix tests for python 3. refs #6380

comment:8 Changed 4 years ago by Ying Li

1+2+3 have been addressed in r37830

Filed #6393 to address (4)

buildbot results look good.

Going to merge.

comment:9 Changed 4 years ago by Ying Li

Resolution: fixed
Status: newclosed

(In [37834]) Merge failureResultOf-optional-types-6380: expected types of failureResultOf

Author: cyli Reviewer: tom.prince Fixes: #6380

Allow failureResultOf to take optional expected failure types, so that if an unexpected failure occurs, the failureResultOf assertion will fail.

Note: See TracTickets for help on using tickets.