kiwi-el8/test/unit/iso_tools/init_test.py
Marcus Schäfer 9c9250ebc4
Support nose and xunit style tests
The modifications in this commit allows the unit tests
to run on both, pytest 6.x (nose test layout) and the new
pytest 7.x (xunit test layout). This Fixes #2072 in a
much nicer way. Thanks much to @smarlowucf
2022-02-26 20:26:18 +01:00

33 lines
1.1 KiB
Python

from pytest import raises
from mock import patch
import mock
from kiwi.iso_tools import IsoTools
from kiwi.exceptions import KiwiIsoToolError
class TestIsoTools:
def setup(self):
self.runtime_config = mock.Mock()
self.runtime_config.get_iso_tool_category = mock.Mock()
def setup_method(self, cls):
self.setup()
@patch('kiwi.iso_tools.xorriso.IsoToolsXorrIso')
@patch('kiwi.iso_tools.RuntimeConfig')
def test_iso_tools_xorriso(
self, mock_RuntimeConfig, mock_IsoToolsXorrIso
):
self.runtime_config.get_iso_tool_category.return_value = 'xorriso'
mock_RuntimeConfig.return_value = self.runtime_config
IsoTools.new('root-dir')
mock_IsoToolsXorrIso.assert_called_once_with('root-dir')
@patch('kiwi.iso_tools.RuntimeConfig')
def test_iso_tools_unsupported(self, mock_RuntimeConfig):
self.runtime_config.get_iso_tool_category.return_value = 'foo'
mock_RuntimeConfig.return_value = self.runtime_config
with raises(KiwiIsoToolError):
IsoTools.new('root_dir')