[elbe-devel] [PATCH 3/5] test: callable params example

Bastian Germann bage at linutronix.de
Wed Jul 29 15:13:40 CEST 2020


Am 23.07.20 um 04:51 schrieb Olivier Dion:
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
>  elbepack/tests/test_doctest.py | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/elbepack/tests/test_doctest.py b/elbepack/tests/test_doctest.py
> index a19a5745..74739147 100644
> --- a/elbepack/tests/test_doctest.py
> +++ b/elbepack/tests/test_doctest.py
> @@ -4,7 +4,6 @@
>  # SPDX-License-Identifier: GPL-3.0-or-later
>  
>  import doctest
> -import unittest
>  
>  import elbepack.shellhelper as shellhelper
>  import elbepack.filesystem as filesystem
> @@ -13,20 +12,23 @@ from elbepack.commands.test import ElbeTestCase
>  
>  class ElbeDocTest(ElbeTestCase):
>  
> -    params = [shellhelper, filesystem]
> +    # This is an example of a callable paramametization

typo: parametrization

> +    @staticmethod
> +    def params():
> +        return [shellhelper, filesystem]
>  
>      def setUp(self):
>  
>          self.kwargs = {}
>  
> -        if self.params is filesystem:
> +        if self.param is filesystem:
>              self.kwargs["extraglobs"] = {"this":filesystem.TmpdirFilesystem()}
>  
>      def tearDown(self):
>  
> -        if self.params is filesystem:
> +        if self.param is filesystem:
>              self.kwargs["extraglobs"]["this"].delete()
>  
>      def test_doctest(self):
> -        fail, _ = doctest.testmod(self.params, **self.kwargs)
> +        fail, _ = doctest.testmod(self.param, **self.kwargs)
>          self.assertEqual(fail, 0)
> 

With the typo fixed:
Reviewed-by: Bastian Germann <bage at linutronix.de>


More information about the elbe-devel mailing list