diff options
Diffstat (limited to 'tests/test_clone.py')
| -rw-r--r-- | tests/test_clone.py | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/tests/test_clone.py b/tests/test_clone.py index f089cb43..4b4cf101 100644 --- a/tests/test_clone.py +++ b/tests/test_clone.py @@ -23,22 +23,22 @@ def element_fill_angle(element: EmbroideryElement) -> Optional[float]: class CloneElementTest(TestCase): # Monkey-patch the cahce to forcibly disable it: We may need to refactor this out for tests. - def setUp(self): + def setUp(self) -> None: from pytest import MonkeyPatch self.monkeypatch = MonkeyPatch() self.monkeypatch.setattr(cache_module, "is_cache_disabled", lambda: True) - def tearDown(self): + def tearDown(self) -> None: self.monkeypatch.undo() return super().tearDown() - def assertAngleAlmostEqual(self, a, b): + def assertAngleAlmostEqual(self, a, b) -> None: # Take the mod 180 of the returned angles, because e.g. -130deg and 50deg produce fills along the same angle. # We have to use a precision of 4 decimal digits because of the precision of the matrices as they are stored in the svg trees # generated by these tests. self.assertAlmostEqual(a % 180, b % 180, 4) - def test_not_embroiderable(self): + def test_not_embroiderable(self) -> None: root: SvgDocumentElement = svg() text = root.add(TextElement()) text.text = "Can't embroider this!" @@ -49,7 +49,7 @@ class CloneElementTest(TestCase): stitch_groups = clone.to_stitch_groups(None) self.assertEqual(len(stitch_groups), 0) - def test_not_clone(self): + def test_not_clone(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -67,7 +67,7 @@ class CloneElementTest(TestCase): # These tests make sure the element cloning works as expected, using the `clone_elements` method. - def test_basic(self): + def test_basic(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -80,9 +80,9 @@ class CloneElementTest(TestCase): clone = Clone(use) with clone.clone_elements() as elements: self.assertEqual(len(elements), element_count()) - self.assertAlmostEqual(element_fill_angle(elements[0]), 30) + self.assertAngleAlmostEqual(element_fill_angle(elements[0]), 30) - def test_hidden_cloned_elements_not_embroidered(self): + def test_hidden_cloned_elements_not_embroidered(self) -> None: root = svg() g = root.add(Group()) g.add(Rectangle(attrib={ @@ -113,7 +113,7 @@ class CloneElementTest(TestCase): self.assertEqual(len(elements), element_count()) self.assertEqual(elements[0].node.get(INKSCAPE_LABEL), "NotHidden") - def test_angle_rotated(self): + def test_angle_rotated(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -129,7 +129,7 @@ class CloneElementTest(TestCase): self.assertEqual(len(elements), element_count()) self.assertAngleAlmostEqual(element_fill_angle(elements[0]), 10) - def test_angle_flipped(self): + def test_angle_flipped(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -145,7 +145,7 @@ class CloneElementTest(TestCase): self.assertEqual(len(elements), element_count()) self.assertAngleAlmostEqual(element_fill_angle(elements[0]), -30) - def test_angle_flipped_rotated(self): + def test_angle_flipped_rotated(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -162,7 +162,7 @@ class CloneElementTest(TestCase): # Fill angle goes from 30 -> -30 after flip -> -50 after rotate self.assertAngleAlmostEqual(element_fill_angle(elements[0]), -50) - def test_angle_non_uniform_scale(self): + def test_angle_non_uniform_scale(self) -> None: """ The angle isn't *as* well-defined for non-rotational scales, but we try to follow how the slope will be altered. """ @@ -183,7 +183,7 @@ class CloneElementTest(TestCase): # then rotated another -10 degrees to -55 self.assertAngleAlmostEqual(element_fill_angle(elements[0]), -55) - def test_angle_inherits_down_tree(self): + def test_angle_inherits_down_tree(self) -> None: """ The stitching angle of a clone is based in part on the relative transforms of the source and clone. """ @@ -207,7 +207,7 @@ class CloneElementTest(TestCase): # Angle goes from 30 -> 40 (g1 -> g2) -> 29 (use) self.assertAngleAlmostEqual(element_fill_angle(elements[0]), 29) - def test_angle_not_applied_twice(self): + def test_angle_not_applied_twice(self) -> None: """Make sure that angle changes are not applied twice to an element with both stroke and fill.""" root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ @@ -226,7 +226,7 @@ class CloneElementTest(TestCase): # Angle goes from 0 -> -30 self.assertAngleAlmostEqual(element_fill_angle(elements[0]), -30) - def test_angle_not_applied_to_non_fills(self): + def test_angle_not_applied_to_non_fills(self) -> None: """Make sure that angle changes are not applied to non-fill elements.""" root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ @@ -243,7 +243,7 @@ class CloneElementTest(TestCase): self.assertEqual(len(elements), element_count()) # One for the stroke, one for the fill, one for the SewStack self.assertIsNone(elements[0].get_param("angle", None)) # Angle as not set, as this isn't a fill - def test_style_inherits(self): + def test_style_inherits(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -262,7 +262,7 @@ class CloneElementTest(TestCase): self.assertEqual(style["stroke"], "skyblue") self.assertEqual(style["stroke-width"], "2") - def test_transform_inherits_from_cloned_element(self): + def test_transform_inherits_from_cloned_element(self) -> None: """ Elements cloned by cloned_elements need to inherit their transform from their href'd element and their use to match what's shown. """ @@ -284,7 +284,7 @@ class CloneElementTest(TestCase): elements[0].node.composed_transform(), Transform().add_translate((5, 10)).add_scale(2, 2)) - def test_transform_inherits_from_tree(self): + def test_transform_inherits_from_tree(self) -> None: root: SvgDocumentElement = svg() g1 = root.add(Group()) g1.set('transform', Transform().add_translate((0, 5)).add_rotate(5)) @@ -308,7 +308,7 @@ class CloneElementTest(TestCase): .add_scale(2, 2), # rect 5) - def test_transform_inherits_from_tree_up_tree(self): + def test_transform_inherits_from_tree_up_tree(self) -> None: root: SvgDocumentElement = svg() g1 = root.add(Group()) g1.set('transform', Transform().add_translate((0, 5)).add_rotate(5)) @@ -343,7 +343,7 @@ class CloneElementTest(TestCase): .add_translate((0, 5)).add_rotate(5), # g1 5) - def test_clone_fill_angle_not_specified(self): + def test_clone_fill_angle_not_specified(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -357,7 +357,7 @@ class CloneElementTest(TestCase): clone = Clone(use) self.assertEqual(clone.clone_fill_angle, None) - def test_clone_fill_angle(self): + def test_clone_fill_angle(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -376,7 +376,7 @@ class CloneElementTest(TestCase): self.assertEqual(len(elements), element_count()) self.assertAngleAlmostEqual(element_fill_angle(elements[0]), 42) - def test_angle_manually_flipped(self): + def test_angle_manually_flipped(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -396,7 +396,7 @@ class CloneElementTest(TestCase): # Recursive use tests - def test_recursive_uses(self): + def test_recursive_uses(self) -> None: root: SvgDocumentElement = svg() g1 = root.add(Group()) rect = g1.add(Rectangle(attrib={ @@ -433,7 +433,7 @@ class CloneElementTest(TestCase): .add_translate((20, 0)) # u1 ) - def test_recursive_uses_angle(self): + def test_recursive_uses_angle(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -482,7 +482,7 @@ class CloneElementTest(TestCase): # Angle goes from -30 -> -37 self.assertAngleAlmostEqual(element_fill_angle(elements[0]), -37) - def test_recursive_uses_angle_with_specified_angle(self): + def test_recursive_uses_angle_with_specified_angle(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -510,7 +510,7 @@ class CloneElementTest(TestCase): # Command clone tests - def test_copies_directly_attached_commands(self): + def test_copies_directly_attached_commands(self) -> None: """ Check that commands attached to the clone target directly are applied to clones. """ @@ -536,7 +536,7 @@ class CloneElementTest(TestCase): self.assertAlmostEqual(cmd_orig.target_point[0]+10, cmd_clone.target_point[0], 4) self.assertAlmostEqual(cmd_orig.target_point[1]+10, cmd_clone.target_point[1], 4) - def test_copies_indirectly_attached_commands(self): + def test_copies_indirectly_attached_commands(self) -> None: """ Check that commands attached to children of the clone target are copied to clones. """ @@ -565,7 +565,7 @@ class CloneElementTest(TestCase): # Checks that trim_after and stop_after commands and settings in cloned elements aren't overridden - def test_trim_after(self): + def test_trim_after(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -582,7 +582,7 @@ class CloneElementTest(TestCase): self.assertGreater(len(stitch_groups), 0) self.assertTrue(stitch_groups[-1].trim_after) - def test_trim_after_command(self): + def test_trim_after_command(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -599,7 +599,7 @@ class CloneElementTest(TestCase): self.assertGreater(len(stitch_groups), 0) self.assertTrue(stitch_groups[-1].trim_after) - def test_trim_after_command_on_clone(self): + def test_trim_after_command_on_clone(self) -> None: """ If the clone element has a trim command, it should apply! """ @@ -619,7 +619,7 @@ class CloneElementTest(TestCase): self.assertGreater(len(stitch_groups), 0) self.assertTrue(stitch_groups[-1].trim_after) - def test_stop_after(self): + def test_stop_after(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -636,7 +636,7 @@ class CloneElementTest(TestCase): self.assertGreater(len(stitch_groups), 0) self.assertTrue(stitch_groups[-1].stop_after) - def test_stop_after_command(self): + def test_stop_after_command(self) -> None: root: SvgDocumentElement = svg() rect = root.add(Rectangle(attrib={ "width": "10", @@ -654,7 +654,7 @@ class CloneElementTest(TestCase): self.assertGreater(len(stitch_groups), 0) self.assertTrue(stitch_groups[-1].stop_after) - def test_stop_after_command_on_clone(self): + def test_stop_after_command_on_clone(self) -> None: """ If the clone element has a stop command, it should still apply! """ |
