def test_local_context_inherited_shared_props(tmp_path): "The only thing that should differ between the 2 squares is their opacity" pdf = FPDF() pdf.add_page() pdf.set_font("Helvetica", "", 12) pdf.set_draw_color(0, 128, 255) pdf.set_fill_color(255, 128, 0) pdf.set_line_width(2) pdf.set_dash_pattern(dash=0.5, gap=9.5, phase=3.25) with pdf.local_context( fill_opacity=0.5): # => triggers creation of a local GraphicsStyle pdf.rect(x=60, y=60, w=60, h=60, style="DF") pdf.rect(x=60, y=150, w=60, h=60, style="DF") assert_pdf_equal(pdf, HERE / "local_context_inherited_shared_props.pdf", tmp_path)