[elbe-devel] [PATCH 3/5] test: callable params example
Olivier Dion
dion at linutronix.de
Thu Jul 23 04:51:17 CEST 2020
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
+ @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)
--
2.27.0
More information about the elbe-devel
mailing list