rougail/tests/test_others.py
2021-02-22 19:28:51 +01:00

44 lines
1.5 KiB
Python

from pytest import raises
from rougail import RougailConvert, RougailConfig
from rougail.error import DictConsistencyError
def test_no_dtd():
cfg = RougailConfig.copy()
cfg['dtdfilename'] = 'notexists.dtd'
with raises(IOError):
eolobj = RougailConvert(cfg)
def test_mode_invalid_default():
RougailConfig['dictionaries_dir'] = ['tests/personalize_mode/dictionary']
RougailConfig['modes_level'] = ('level1', 'level2')
with raises(DictConsistencyError):
eolobj = RougailConvert()
def test_mode_invalid_default_family():
RougailConfig['dictionaries_dir'] = ['tests/personalize_mode/dictionary']
RougailConfig['modes_level'] = ('level1', 'level2')
RougailConfig['default_variable_mode'] = 'level1'
with raises(DictConsistencyError):
eolobj = RougailConvert()
def test_personalize_mode():
RougailConfig['dictionaries_dir'] = ['tests/personalize_mode/dictionary']
RougailConfig['modes_level'] = ('level1', 'level2')
RougailConfig['default_variable_mode'] = 'level1'
RougailConfig['default_family_mode'] = 'level1'
eolobj = RougailConvert()
eolobj.save(None)
def test_personalize_mode_unknown():
RougailConfig['dictionaries_dir'] = ['tests/personalize_mode/dictionary']
RougailConfig['modes_level'] = ('level1',)
RougailConfig['default_variable_mode'] = 'level1'
RougailConfig['default_family_mode'] = 'level1'
with raises(DictConsistencyError):
eolobj = RougailConvert()