@@ -7,7 +7,7 @@ xseries(pl, idx = length(pl.series_list)) = pl.series_list[idx].plotattributes[:
77yseries (pl, idx = length (pl. series_list)) = pl. series_list[idx]. plotattributes[:y ]
88zseries (pl, idx = length (pl. series_list)) = pl. series_list[idx]. plotattributes[:z ]
99
10- testfile = tempname () * " .png"
10+ forcedraw (pl) = savefig (pl, tempname () * " .png" )
1111
1212macro isplot (ex) # @isplot macro to streamline tests
1313 :(@test $ (esc (ex)) isa Plot)
4141 @testset " yunit" begin
4242 @test yguide (plot (y, yunit = cm)) == " cm"
4343 @test yseries (plot (y, yunit = cm)) ≈ ustrip .(cm, y)
44+ @test getaxisunit (plot (y, yunit = cm). subplots[1 ][:yaxis ]) == cm
4445 end
4546
4647 @testset " ylims" begin # Using all(lims .≈ lims) because of uncontrolled type conversions?
5253 @test_throws DimensionError begin
5354 pl = plot (y)
5455 plot! (pl; ylims = (- 1 s, 5 s))
55- savefig (pl, testfile )
56+ forcedraw (pl)
5657 end
5758 end
5859
6263 pl = plot (y; ylims = encompassing_ylims, yticks = (1 : 5 )m)
6364 @test compare_yticks (pl, 1 : 5 )
6465 pl = plot (y; ylims = encompassing_ylims, yticks = [1 cm, 3 cm])
65- savefig (pl, testfile )
66+ forcedraw (pl)
6667 @test compare_yticks (pl, [0.01 , 0.03 ])
6768 pl = plot! (; ylims = encompassing_ylims, yticks = [- 1 cm, 4 cm])
68- savefig (pl, testfile )
69+ forcedraw (pl)
6970 @test compare_yticks (pl, [- 0.01 , 0.04 ])
7071 @test_throws DimensionError begin
7172 pl = plot (y)
7273 plot! (pl; yticks = (1 : 5 )s)
73- savefig (pl, testfile )
74+ forcedraw (pl)
7475 end
7576 end
7677
@@ -337,19 +338,18 @@ end
337338
338339@testset " Aspect ratio" begin
339340 pl = plot ((1 : 10 )u " m" , (1 : 10 )u " dm" ; aspect_ratio = :equal )
340- savefig (pl, testfile) # Force a render, to make it evaluate aspect ratio
341+ forcedraw (pl)
341342 @test abs (- (ylims (pl)... )) > 50
342343 plot! (pl, (3 : 4 )u " m" , (4 : 5 )u " m" )
343344 @test first (pl. subplots)[:aspect_ratio ] == 1 // 10 # This is what "equal" means when yunit==xunit/10
344345 pl = plot ((1 : 10 )u " m" , (1 : 10 )u " dm" ; aspect_ratio = 2 )
345- savefig (pl, testfile )
346+ forcedraw (pl)
346347 @test 25 < abs (- (ylims (pl)... )) < 50
347348 pl = plot ((1 : 10 )u " m" , (1 : 10 )u " s" ; aspect_ratio = 1 u " m/s" )
348- savefig (pl, testfile )
349+ forcedraw (pl)
349350 @test 7.5 < abs (- (ylims (pl)... )) < 12.5
350- @test_throws DimensionError savefig (
351+ @test_throws DimensionError forcedraw (
351352 plot ((1 : 10 )u " m" , (1 : 10 )u " s" ; aspect_ratio = :equal ),
352- testfile,
353353 )
354354end
355355
0 commit comments