Skip to content

Commit

Permalink
Changed stack level and added test for code coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Sokolowski committed Jan 5, 2025
1 parent 9841df9 commit 3a10788
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/build123d/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ def _circle_segments(self, edge: Edge, reverse: bool) -> list[PathSegment]:
if edge.length < 1e-6:
warnings.warn(
"Skipping arc that is too small to export safely (length < 1e-6).",
stacklevel=2,
stacklevel=7,
)
return []
curve = edge._geom_adaptor()
Expand Down Expand Up @@ -1243,7 +1243,7 @@ def _ellipse_segments(self, edge: Edge, reverse: bool) -> list[PathSegment]:
if edge.length < 1e-6:
warnings.warn(
"Skipping arc that is too small to export safely (length < 1e-6).",
stacklevel=2,
stacklevel=7,
)
return []
curve = edge._geom_adaptor()
Expand Down
10 changes: 8 additions & 2 deletions tests/test_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,19 @@ def test_svg_small_arc(self):
pnts = ((0, 0), (0, 0.000001), (0.000001, 0))
small_arc = ThreePointArc(pnts).scale(0.01)
with self.assertWarns(UserWarning):
self.basic_svg_export(small_arc, "test_svg_small_arc.svg")
svg_exporter = ExportSVG()
segments = svg_exporter._circle_segments(small_arc.edges()[0], False)
self.assertEqual(len(segments), 0, "Small arc should produce no segments")

def test_svg_small_ellipse(self):
pnts = ((0, 0), (0, 0.000001), (0.000002, 0))
small_ellipse = ThreePointArc(pnts).scale(0.01)
with self.assertWarns(UserWarning):
self.basic_svg_export(small_ellipse, "test_svg_small_ellipse.svg")
svg_exporter = ExportSVG()
segments = svg_exporter._ellipse_segments(small_ellipse.edges()[0], False)
self.assertEqual(
len(segments), 0, "Small ellipse should produce no segments"
)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 3a10788

Please sign in to comment.