[elbe-devel] [PATCH 01/10] test: fix problem, when subtest succeeds

Bastian Germann bage at linutronix.de
Fri May 7 10:14:18 CEST 2021


Am 06.05.21 um 14:55 schrieb Torben Hohn:
> addSubTest can be called with err = None.
> 
> This makes "message = str(err[1])" fail.
> 
> ---------------------------------------------------------------------------------------------
> Traceback (most recent call last):
>    File "./elbe", line 60, in <module>
>      cmdmod.run_command(sys.argv[2:])
>    File "/home/torbenh/elbe/elbe/elbepack/commands/test.py", line 266, in run_command
>      test.run(result)
>    File "/usr/lib/python3.7/unittest/case.py", line 623, in run
>      self._feedErrorsToResult(result, outcome.errors)
>    File "/usr/lib/python3.7/unittest/case.py", line 548, in _feedErrorsToResult
>      result.addSubTest(test.test_case, test, exc_info)
>    File "/home/torbenh/elbe/elbe/elbepack/commands/test.py", line 175, in addSubTest
>      message = str(err[1])
> TypeError: 'NoneType' object is not subscriptable
> ---------------------------------------------------------------------------------------------
> 
> move the assignments of message and output into the block protected by
> "if err is not None:".
> 
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>

Reviewed-by: Bastian Germann <bage at linutronix.de>

> ---
>   elbepack/commands/test.py | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/elbepack/commands/test.py b/elbepack/commands/test.py
> index 8f19733ae..c01176537 100644
> --- a/elbepack/commands/test.py
> +++ b/elbepack/commands/test.py
> @@ -172,10 +172,10 @@ class ElbeTestResult(unittest.TestResult):
>           self.current_case = junit.TestCase(name=str(subtest))
>           self.cases.append(self.current_case)
>   
> -        message = str(err[1])
> -        output = self._exc_info_to_string(err, test)
> -
>           if err is not None:
> +            message = str(err[1])
> +            output = self._exc_info_to_string(err, test)
> +
>               if issubclass(err[0], ElbeTestException):
>                   self.current_case.stdout = err[1].out
>   
> 


More information about the elbe-devel mailing list