[elbe-devel] [PATCH v2 2/4] tests: Create test case for pbuilder
Olivier Dion
dion at linutronix.de
Tue Aug 4 14:44:11 CEST 2020
On Tue, 04 Aug 2020, Bastian Germann <bage at linutronix.de> wrote:
>>> elbepack/tests/test_xml.py | 30 ++++++++++++++++++++++++++++++
>>> 1 file changed, 30 insertions(+)
>>>
>>> diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
>>> index f397a90b..17cc21cf 100644
>>> --- a/elbepack/tests/test_xml.py
>>> +++ b/elbepack/tests/test_xml.py
>>> @@ -52,3 +52,33 @@ class TestSimpleXML(ElbeTestCase):
>>> system('%s control del_project %s' % (elbe_exe, uuid),
>>> allow_fail=True)
>>>
>>> + at unittest.skipIf(ElbeTestCase.level < ElbeTestLevel.INITVM,
>>> + "Test level not set to INITVM")
>>> +class TestPbuilder(ElbeTestCase):
>>> +
>>> + params = [os.path.join(elbe_dir, "tests", fname)
>>> + for fname
>>> + in os.listdir(os.path.join(elbe_dir, "tests"))
>>> + if fname.startswith("pbuilder") and fname.endswith(".xml")]
>>> +
>>> + def test_pbuilder_build(self):
>>> +
>>> + with tempfile.TemporaryDirectory(prefix="elbe-test-pbuilder-xml-") as build_dir:
>>> +
>>> + prj = os.path.join(build_dir, "uuid.prj")
>>> + uuid = None
>>> +
>>> + try:
>>> + system('%s pbuilder create --xmlfile "%s" --writeproject "%s"' %
>>> + (elbe_exe, self.param, prj))
>>> +
>>> + with open(prj, "r") as f:
>>> + uuid = f.read()
>>> + os.chdir(build_dir)
>>> + system('%s pbuilder build --project %s' % (elbe_exe, uuid))
>>> + # pylint: disable=try-except-raise
>>> + except:
>>> + raise
>>
>> Why do we need this? Can't you just leave out the try-except?
>> This goes also for the previous patch.
>
> Oh, I see. You want a tear down.
Yes. It would be possible to do the same with 'setUp()' and
'tearDown()' methods I guess. I just find it more readable this way.
Let me add a comment that explain that this is a teardown.
--
Olivier Dion
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
More information about the elbe-devel
mailing list