diff --git a/test/shapes/test_regular_polygon.pdf b/test/shapes/class_regular_polygon.pdf similarity index 98% rename from test/shapes/test_regular_polygon.pdf rename to test/shapes/class_regular_polygon.pdf index 116683a7e..b0830b832 100644 Binary files a/test/shapes/test_regular_polygon.pdf and b/test/shapes/class_regular_polygon.pdf differ diff --git a/test/shapes/test_regular_polygon.py b/test/shapes/test_regular_polygon.py index 87d6a2deb..3eb420f81 100644 --- a/test/shapes/test_regular_polygon.py +++ b/test/shapes/test_regular_polygon.py @@ -1,60 +1,70 @@ -from fpdf import FPDF - -pdf = FPDF() -pdf.add_page() - -# no fill with line -pdf.regular_polygon(10, 35, 3, 25) -pdf.regular_polygon(40, 35, 4, 25) -pdf.regular_polygon(70, 35, 5, 25) -pdf.regular_polygon(100, 35, 6, 25) -pdf.regular_polygon(130, 35, 7, 25) -pdf.regular_polygon(160, 35, 8, 25) - -# fill and color test -pdf.set_fill_color(134, 200, 15) -pdf.regular_polygon(10, 75, 3, 25, style="f") -pdf.regular_polygon(40, 75, 4, 25, style="f") -pdf.regular_polygon(70, 75, 5, 25, style="f") -pdf.regular_polygon(100, 75, 6, 25, style="f") -pdf.regular_polygon(130, 75, 7, 25, style="f") -pdf.regular_polygon(160, 75, 8, 25, style="f") - -# draw color test -pdf.set_fill_color(0, 0, 0) -pdf.set_draw_color(204, 0, 204) -pdf.regular_polygon(10, 115, 3, 25) -pdf.regular_polygon(40, 115, 4, 25) -pdf.regular_polygon(70, 115, 5, 25) -pdf.regular_polygon(100, 115, 6, 25) -pdf.regular_polygon(130, 115, 7, 25) -pdf.regular_polygon(160, 115, 8, 25) - -# line width test -pdf.set_line_width(1) -pdf.regular_polygon(10, 155, 3, 25) -pdf.regular_polygon(40, 155, 4, 25) -pdf.regular_polygon(70, 155, 5, 25) -pdf.regular_polygon(100, 155, 6, 25) -pdf.regular_polygon(130, 155, 7, 25) -pdf.regular_polygon(160, 155, 8, 25) - -# line color and fill color -pdf.set_fill_color(3, 190, 252) -pdf.regular_polygon(10, 195, 3, 25, style="f") -pdf.regular_polygon(40, 195, 4, 25, style="f") -pdf.regular_polygon(70, 195, 5, 25, style="f") -pdf.regular_polygon(100, 195, 6, 25, style="f") -pdf.regular_polygon(130, 195, 7, 25, style="f") -pdf.regular_polygon(160, 195, 8, 25, style="f") - -# rotation test -pdf.set_draw_color(0, 0, 255) -pdf.regular_polygon(10, 235, 3, 25, 30) -pdf.regular_polygon(40, 235, 4, 25, 45) -pdf.regular_polygon(70, 235, 5, 25, 200) -pdf.regular_polygon(100, 235, 6, 25, 0) -pdf.regular_polygon(130, 235, 7, 25, 13) -pdf.regular_polygon(160, 235, 8, 25, 22.5) - -pdf.output("test_regular_polygon.pdf") +from pathlib import Path + +import fpdf +from test.conftest import assert_pdf_equal + + +HERE = Path(__file__).resolve().parent + + +def test_regular_polygon(tmp_path): + + pdf = fpdf.FPDF() + pdf.add_page() + + # no fill with line + pdf.regular_polygon(10, 35, 3, 25) + pdf.regular_polygon(40, 35, 4, 25) + pdf.regular_polygon(70, 35, 5, 25) + pdf.regular_polygon(100, 35, 6, 25) + pdf.regular_polygon(130, 35, 7, 25) + pdf.regular_polygon(160, 35, 8, 25) + + # fill and color test + pdf.set_fill_color(134, 200, 15) + pdf.regular_polygon(10, 75, 3, 25, style="f") + pdf.regular_polygon(40, 75, 4, 25, style="f") + pdf.regular_polygon(70, 75, 5, 25, style="f") + pdf.regular_polygon(100, 75, 6, 25, style="f") + pdf.regular_polygon(130, 75, 7, 25, style="f") + pdf.regular_polygon(160, 75, 8, 25, style="f") + + # draw color test + pdf.set_fill_color(0, 0, 0) + pdf.set_draw_color(204, 0, 204) + pdf.regular_polygon(10, 115, 3, 25) + pdf.regular_polygon(40, 115, 4, 25) + pdf.regular_polygon(70, 115, 5, 25) + pdf.regular_polygon(100, 115, 6, 25) + pdf.regular_polygon(130, 115, 7, 25) + pdf.regular_polygon(160, 115, 8, 25) + + # line width test + pdf.set_line_width(1) + pdf.regular_polygon(10, 155, 3, 25) + pdf.regular_polygon(40, 155, 4, 25) + pdf.regular_polygon(70, 155, 5, 25) + pdf.regular_polygon(100, 155, 6, 25) + pdf.regular_polygon(130, 155, 7, 25) + pdf.regular_polygon(160, 155, 8, 25) + + # line color and fill color + pdf.set_fill_color(3, 190, 252) + pdf.regular_polygon(10, 195, 3, 25, style="f") + pdf.regular_polygon(40, 195, 4, 25, style="f") + pdf.regular_polygon(70, 195, 5, 25, style="f") + pdf.regular_polygon(100, 195, 6, 25, style="f") + pdf.regular_polygon(130, 195, 7, 25, style="f") + pdf.regular_polygon(160, 195, 8, 25, style="f") + + # rotation test + pdf.set_draw_color(0, 0, 255) + pdf.regular_polygon(10, 235, 3, 25, 30) + pdf.regular_polygon(40, 235, 4, 25, 45) + pdf.regular_polygon(70, 235, 5, 25, 200) + pdf.regular_polygon(100, 235, 6, 25, 0) + pdf.regular_polygon(130, 235, 7, 25, 13) + pdf.regular_polygon(160, 235, 8, 25, 22.5) + + # pdf.output("test_regular_polygon.pdf") + assert_pdf_equal(pdf, HERE / "class_regular_polygon.pdf", tmp_path) diff --git a/test_regular_polygon.pdf b/test_regular_polygon.pdf deleted file mode 100644 index b1387d836..000000000 Binary files a/test_regular_polygon.pdf and /dev/null differ