8
8
9
9
from matplotlib import (
10
10
collections , path , patheffects , pyplot as plt , transforms as mtransforms ,
11
- rcParams )
11
+ rcParams , rc_context )
12
12
from matplotlib .backends .backend_agg import RendererAgg
13
13
from matplotlib .figure import Figure
14
14
from matplotlib .image import imread
@@ -275,8 +275,7 @@ def test_draw_path_collection_error_handling():
275
275
fig .canvas .draw ()
276
276
277
277
278
- @pytest .fixture
279
- def chunk_limit_setup ():
278
+ def test_chunksize_fails ():
280
279
N = 100_000
281
280
dpi = 500
282
281
w = 5 * dpi
@@ -300,54 +299,31 @@ def chunk_limit_setup():
300
299
# effectively disable path simplification (but leaving it "on")
301
300
p .simplify_threshold = 0
302
301
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
-
309
302
gc .set_hatch ('/' )
310
-
311
303
with pytest .raises (OverflowError , match = 'hatched path' ):
312
304
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 )
317
306
318
307
with pytest .raises (OverflowError , match = 'filled path' ):
319
308
ra .draw_path (gc , p , idt , (1 , 0 , 0 ))
320
309
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 )
321
314
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 )
327
319
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 )
328
324
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" ):
351
327
ra .draw_path (gc , p , idt )
352
328
353
329
0 commit comments