88
99from matplotlib import (
1010 collections , path , patheffects , pyplot as plt , transforms as mtransforms ,
11- rcParams )
11+ rcParams , rc_context )
1212from matplotlib .backends .backend_agg import RendererAgg
1313from matplotlib .figure import Figure
1414from matplotlib .image import imread
@@ -275,8 +275,7 @@ def test_draw_path_collection_error_handling():
275275 fig .canvas .draw ()
276276
277277
278- @pytest .fixture
279- def chunk_limit_setup ():
278+ def test_chunksize_fails ():
280279 N = 100_000
281280 dpi = 500
282281 w = 5 * dpi
@@ -300,54 +299,31 @@ def chunk_limit_setup():
300299 # effectively disable path simplification (but leaving it "on")
301300 p .simplify_threshold = 0
302301
303- return ra , gc , p , idt
304-
305-
306- def test_chunksize_hatch_fail (chunk_limit_setup ):
307- ra , gc , p , idt = chunk_limit_setup
308-
309302 gc .set_hatch ('/' )
310-
311303 with pytest .raises (OverflowError , match = 'hatched path' ):
312304 ra .draw_path (gc , p , idt )
313-
314-
315- def test_chunksize_rgbFace_fail (chunk_limit_setup ):
316- ra , gc , p , idt = chunk_limit_setup
305+ gc .set_hatch (None )
317306
318307 with pytest .raises (OverflowError , match = 'filled path' ):
319308 ra .draw_path (gc , p , idt , (1 , 0 , 0 ))
320309
310+ # Set to zero to disable, currently defaults to 0, but let's be sure.
311+ with rc_context ({'agg.path.chunksize' : 0 }):
312+ with pytest .raises (OverflowError , match = 'Please set' ):
313+ ra .draw_path (gc , p , idt )
321314
322- def test_chunksize_no_simplify_fail (chunk_limit_setup ):
323- ra , gc , p , idt = chunk_limit_setup
324- p .should_simplify = False
325- with pytest .raises (OverflowError , match = "should_simplify is False" ):
326- ra .draw_path (gc , p , idt )
315+ # Set big enough that we do not try to chunk.
316+ with rc_context ({'agg.path.chunksize' : 1_000_000 }):
317+ with pytest .raises (OverflowError , match = 'Please reduce' ):
318+ ra .draw_path (gc , p , idt )
327319
320+ # Small enough we will try to chunk, but big enough we will fail to render.
321+ with rc_context ({'agg.path.chunksize' : 90_000 }):
322+ with pytest .raises (OverflowError , match = 'Please reduce' ):
323+ ra .draw_path (gc , p , idt )
328324
329- def test_chunksize_zero (chunk_limit_setup ):
330- ra , gc , p , idt = chunk_limit_setup
331- # set to zero to disable, currently defaults to 0, but lets be sure
332- rcParams ['agg.path.chunksize' ] = 0
333- with pytest .raises (OverflowError , match = 'Please set' ):
334- ra .draw_path (gc , p , idt )
335-
336-
337- def test_chunksize_too_big_to_chunk (chunk_limit_setup ):
338- ra , gc , p , idt = chunk_limit_setup
339- # set big enough that we do not try to chunk
340- rcParams ['agg.path.chunksize' ] = 1_000_000
341- with pytest .raises (OverflowError , match = 'Please reduce' ):
342- ra .draw_path (gc , p , idt )
343-
344-
345- def test_chunksize_toobig_chunks (chunk_limit_setup ):
346- ra , gc , p , idt = chunk_limit_setup
347- # small enough we will try to chunk, but big enough we will fail
348- # to render
349- rcParams ['agg.path.chunksize' ] = 90_000
350- with pytest .raises (OverflowError , match = 'Please reduce' ):
325+ p .should_simplify = False
326+ with pytest .raises (OverflowError , match = "should_simplify is False" ):
351327 ra .draw_path (gc , p , idt )
352328
353329
0 commit comments