diff --git a/src/calibre/ebooks/css_transform_rules.py b/src/calibre/ebooks/css_transform_rules.py index 8b129a5cb2..712e1253ed 100644 --- a/src/calibre/ebooks/css_transform_rules.py +++ b/src/calibre/ebooks/css_transform_rules.py @@ -378,7 +378,7 @@ def test(return_tests=False): # {{{ r = Rule(**rule) decl = StyleDeclaration(safe_parser().parseStyle(style)) r.process_declaration(decl) - return str(decl) + return str(decl).rstrip(';') class TestTransforms(unittest.TestCase): longMessage = True diff --git a/src/calibre/ebooks/oeb/normalize_css.py b/src/calibre/ebooks/oeb/normalize_css.py index d5cb2eb9b2..941d000b6c 100644 --- a/src/calibre/ebooks/oeb/normalize_css.py +++ b/src/calibre/ebooks/oeb/normalize_css.py @@ -416,7 +416,7 @@ def test_normalization(return_tests=False): # {{{ css = '; '.join(f'border-{edge}-{p}: {v}' for edge in ('top',) for p, v in zip(BORDER_PROPS, vals.split())) style = parseStyle(css) condense_rule(style) - self.assertEqual(css_text(style), 'border-top: %s' % vals) + self.assertEqual(css_text(style).rstrip(';'), 'border-top: %s' % vals) css += ';' + '; '.join(f'border-{edge}-{p}: {v}' for edge in ('right', 'left', 'bottom') for p, v in zip(BORDER_PROPS, vals.replace('red', 'green').split())) style = parseStyle(css) diff --git a/src/calibre/ebooks/oeb/polish/tests/cascade.py b/src/calibre/ebooks/oeb/polish/tests/cascade.py index aa7ca98cfa..5372bd9c79 100644 --- a/src/calibre/ebooks/oeb/polish/tests/cascade.py +++ b/src/calibre/ebooks/oeb/polish/tests/cascade.py @@ -212,7 +212,7 @@ class CascadeTest(BaseTest): style = parseStyle('background-image: url(b.png); background: black url(a.png) fixed') for prop in style.getProperties(all=True): remove_property_value(prop, lambda val:'png' in val.cssText) - self.assertEqual('background: black fixed', style.cssText) + self.assertEqual('background: black fixed', style.cssText.rstrip(';')) def test_fallback_font_matching(self): def cf(id, weight='normal', style='normal', stretch='normal'): diff --git a/src/calibre/utils/run_tests.py b/src/calibre/utils/run_tests.py index 27145d91e3..9468453029 100644 --- a/src/calibre/utils/run_tests.py +++ b/src/calibre/utils/run_tests.py @@ -84,8 +84,10 @@ def itertests(suite): def init_env(): from calibre.utils.config_base import reset_tweaks_to_default from calibre.ebooks.metadata.book.base import reset_field_metadata + from calibre.ebooks.oeb.polish.utils import setup_css_parser_serialization reset_tweaks_to_default() reset_field_metadata() + setup_css_parser_serialization() def filter_tests(suite, test_ok):