Skip to content

Commit 375c236

Browse files
committed
Simplify TestProgram._get_runner
This try-except was necessary to support an instance of a runner being passed that did not support the `tb_locals` parameter. This appears to be a compat handler for Python 2.x variants of `TextTestRunner`, which did not accept this parameter [1]. This is not the case of the lowest version of Python we currently support, 3.10 [2], meaning we can remove the wrapper. [1] https://github.com/python/cpython/blob/v2.7.1/Lib/unittest/runner.py#L127-L128 [2] https://github.com/python/cpython/blob/v3.10.0/Lib/unittest/runner.py#L128-L130 Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent c16ef98 commit 375c236

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

testtools/run.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -267,22 +267,13 @@ def _get_runner(self) -> TestToolsTestRunner:
267267

268268
runner_factory: Callable[..., TestToolsTestRunner] = runner_or_factory
269269
try:
270-
try:
271-
testRunner = runner_factory(
272-
verbosity=self.verbosity,
273-
failfast=self.failfast,
274-
buffer=self.buffer,
275-
stdout=self.stdout,
276-
tb_locals=self.tb_locals,
277-
)
278-
except TypeError:
279-
# didn't accept the tb_locals parameter
280-
testRunner = runner_factory(
281-
verbosity=self.verbosity,
282-
failfast=self.failfast,
283-
buffer=self.buffer,
284-
stdout=self.stdout,
285-
)
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+
)
286277
except TypeError:
287278
# didn't accept the verbosity, buffer, failfast or stdout arguments
288279
try:

0 commit comments

Comments
 (0)