kiwi-el8/test/unit/markup/any_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

36 lines
1.0 KiB
Python

from mock import patch
from pytest import raises
from kiwi.markup.any import MarkupAny
from kiwi.exceptions import (
KiwiDescriptionInvalid,
KiwiAnyMarkupPluginError
)
class TestMarkupXML:
def setup(self):
self.markup = MarkupAny('../data/example_config.xml')
def setup_method(self, cls):
self.setup()
@patch('anymarkup.parse_file')
def test_raises_markup_conversion_error(self, mock_anymarkup_parse_file):
mock_anymarkup_parse_file.side_effect = Exception
with raises(KiwiDescriptionInvalid):
MarkupAny('../data/example_config.xml')
@patch('importlib.import_module')
def test_raises_anymarkup_not_available(self, mock_importlib):
mock_importlib.side_effect = Exception
with raises(KiwiAnyMarkupPluginError):
MarkupAny('../data/example_config.xml')
def test_get_xml_description(self):
assert 'xslt-' in self.markup.get_xml_description()
def test_get_yaml_description(self):
assert 'xslt-' in self.markup.get_yaml_description()