Skip to content

Commit

Permalink
Test for empty path warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jatoben committed Nov 23, 2024
1 parent 1b36890 commit 9822a51
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/library_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,3 +561,35 @@ def test_write_min_length_path(
source.cells[0].paths[0].spine(),
rw.cells[0].paths[0].spine(),
)


@pytest.mark.parametrize(
"simple_path", (True, False),
)
@pytest.mark.parametrize(
"write_f",
(gdstk.Library.write_oas, gdstk.Library.write_gds),
)
def test_empty_path_warning(
simple_path: bool,
write_f: Callable[[gdstk.Library, Union[str, pathlib.Path]], None],
tmp_path: pathlib.Path
):
lib = gdstk.Library("test")
tol = lib.precision / lib.unit

# Simple paths are written to GDS & OASIS with PATH records; non-simple
# paths are serialized as polygons.
path = gdstk.FlexPath(
((0, 0), (tol / 2, 0)),
width=0.01,
tolerance=tol,
simple_path=simple_path
)

cell = gdstk.Cell("top")
cell.add(path)
lib.add(cell)

with pytest.warns(RuntimeWarning, match="Empty path"):
write_f(lib, tmp_path / "out")

0 comments on commit 9822a51

Please sign in to comment.