[elbe-devel] [PATCH 03/10] tests test_pylint: switch from command_out() to testspecific system()

Bastian Germann bage at linutronix.de
Thu Apr 1 18:18:52 CEST 2021


Am 01.04.21 um 13:15 schrieb Torben Hohn:
> Use the test specific system() implementation that stores
> the command output in the Exception thrown.
> 
> Rewrite the skip code, to handle Exceptions, and the

not comma after "code".

> case where no Expception is thrown, when an Exception

Typo: Expception -> exception

> is expected.
> 
> The test should fail, if its expected to fail, but doesn't.

its -> it's

> If the test passes, we want to remove it from the ignore list.
> 
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>

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

> ---
>   elbepack/tests/test_pylint.py | 16 ++++++++++------
>   1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/elbepack/tests/test_pylint.py b/elbepack/tests/test_pylint.py
> index 660070304..8ef40f22f 100644
> --- a/elbepack/tests/test_pylint.py
> +++ b/elbepack/tests/test_pylint.py
> @@ -5,7 +5,7 @@
>   
>   import os
>   
> -from elbepack.commands.test import ElbeTestCase
> +from elbepack.commands.test import ElbeTestCase, system, ElbeTestException
>   from elbepack.shellhelper import command_out, system_out
>   from elbepack.directories import pack_dir, elbe_exe, elbe_dir
>   
> @@ -56,10 +56,14 @@ class TestPylint(ElbeTestCase):
>   
>       def test_lint(self):
>   
> -        ret, out = command_out("pylint3 %s %s" % (' '.join(self.pylint_opts), self.param))
> -
> -        if ret:
> +        try:
> +            system("pylint3 %s %s" % (' '.join(self.pylint_opts), self.param))
> +        except ElbeTestException as e:
>               if self.param in TestPylint.failure_set:
> -                self.skipTest("Pylint test for %s is expected to fail\n%s" % (self.param, out))
> +                self.skipTest("Pylint test for %s is expected to fail" % (self.param))
> +                self.stdout = e.out
>               else:
> -                self.fail(msg=out)
> +                raise
> +        else:
> +            if self.param in TestPylint.failure_set:
> +                raise Exception(f"Pylint test for {self.param} is expected to fail, but did not !")
> 


More information about the elbe-devel mailing list