refactoring the mixin system
Python CI / test (push) Successful in 6m46s

This commit is contained in:
2025-11-08 08:08:02 +01:00
parent 49d4e551f8
commit ea93681aaf
13 changed files with 676 additions and 350 deletions
+58
View File
@@ -0,0 +1,58 @@
"""
Simplified unit tests for abstract document elements using test mixins.
This demonstrates how test mixins can eliminate duplication and simplify tests.
"""
import unittest
from pyWebLayout.abstract.document import Document, Chapter
from tests.mixins.font_registry_tests import FontRegistryTestMixin, FontRegistryParentDelegationTestMixin
from tests.mixins.metadata_tests import MetadataContainerTestMixin
class TestDocumentFontRegistry(FontRegistryTestMixin, unittest.TestCase):
"""Test FontRegistry behavior for Document - simplified with mixin."""
def create_test_object(self):
"""Create a Document instance for testing."""
return Document("Test Document", "en-US")
class TestDocumentMetadata(MetadataContainerTestMixin, unittest.TestCase):
"""Test MetadataContainer behavior for Document - simplified with mixin."""
def create_test_object(self):
"""Create a Document instance for testing."""
return Document("Test Document", "en-US")
class TestChapterFontRegistry(FontRegistryTestMixin, unittest.TestCase):
"""Test FontRegistry behavior for Chapter - simplified with mixin."""
def create_test_object(self):
"""Create a Chapter instance for testing."""
return Chapter("Test Chapter", level=1)
class TestChapterFontRegistryParentDelegation(FontRegistryParentDelegationTestMixin, unittest.TestCase):
"""Test FontRegistry parent delegation for Chapter - simplified with mixin."""
def create_parent(self):
"""Create a Document as parent."""
return Document("Parent Document", "en-US")
def create_child(self, parent):
"""Create a Chapter with parent reference."""
return Chapter("Child Chapter", level=1, parent=parent)
class TestChapterMetadata(MetadataContainerTestMixin, unittest.TestCase):
"""Test MetadataContainer behavior for Chapter - simplified with mixin."""
def create_test_object(self):
"""Create a Chapter instance for testing."""
return Chapter("Test Chapter", level=1)
if __name__ == '__main__':
unittest.main()