Skip to content

Commit aed32a0

Browse files
committed
Simplify TestProgram._get_runner further
This try-except was only needed if we provide a test runner (via the testRunner parameter) that was not an instance of TestToolsTestRunner. While upstream might need to support this [1], we do not. Remove the fallback. [1] https://github.com/python/cpython/blob/v3.10.0/Lib/unittest/main.py#L251-L270 Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent 375c236 commit aed32a0

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

testtools/run.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -266,23 +266,13 @@ def _get_runner(self) -> TestToolsTestRunner:
266266
return runner_or_factory
267267

268268
runner_factory: Callable[..., TestToolsTestRunner] = runner_or_factory
269-
try:
270-
testRunner = runner_factory(
271-
verbosity=self.verbosity,
272-
failfast=self.failfast,
273-
buffer=self.buffer,
274-
stdout=self.stdout,
275-
tb_locals=self.tb_locals,
276-
)
277-
except TypeError:
278-
# didn't accept the verbosity, buffer, failfast or stdout arguments
279-
try:
280-
testRunner = runner_factory(
281-
verbosity=self.verbosity, failfast=self.failfast, buffer=self.buffer
282-
)
283-
except TypeError:
284-
testRunner = runner_factory()
285-
return testRunner
269+
return runner_factory(
270+
verbosity=self.verbosity,
271+
failfast=self.failfast,
272+
buffer=self.buffer,
273+
stdout=self.stdout,
274+
tb_locals=self.tb_locals,
275+
)
286276

287277

288278
def main(argv: list[str], stdout: IO[str]) -> None:

0 commit comments

Comments
 (0)