From ae3a3008d900bcf55c13ef32ccd749165ce919b6 Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 14 Oct 2024 16:34:39 +0200 Subject: [PATCH] remove copypasted code that unnecessarily created a new notebook file away from the project --- test/testsets/random_seed.jl | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/test/testsets/random_seed.jl b/test/testsets/random_seed.jl index 0f264e1..01853a4 100644 --- a/test/testsets/random_seed.jl +++ b/test/testsets/random_seed.jl @@ -1,30 +1,25 @@ include("../utilities/prelude.jl") @testset "seeded random numbers are consistent across runs" begin - mktempdir() do dir - content = - read(joinpath(@__DIR__, "../examples/random_seed/random_seed.qmd"), String) - cd(dir) do - server = QuartoNotebookRunner.Server() - write("notebook.qmd", content) + notebook = joinpath(@__DIR__, "../examples/random_seed/random_seed.qmd") - jsons = map(1:2) do _ - QuartoNotebookRunner.run!(server, "notebook.qmd"; showprogress = false) - end + server = QuartoNotebookRunner.Server() - _output(cell) = only(cell.outputs).data["text/plain"] + jsons = map(1:2) do _ + QuartoNotebookRunner.run!(server, notebook; showprogress = false) + end - @test tryparse(Float64, _output(jsons[1].cells[2])) !== nothing - @test tryparse(Float64, _output(jsons[1].cells[4])) !== nothing - @test tryparse(Float64, _output(jsons[1].cells[6])) !== nothing + _output(cell) = only(cell.outputs).data["text/plain"] - @test length(unique([_output(jsons[1].cells[i]) for i in [2, 4, 6]])) == 3 + @test tryparse(Float64, _output(jsons[1].cells[2])) !== nothing + @test tryparse(Float64, _output(jsons[1].cells[4])) !== nothing + @test tryparse(Float64, _output(jsons[1].cells[6])) !== nothing - @test _output(jsons[1].cells[2]) == _output(jsons[2].cells[2]) - @test _output(jsons[1].cells[4]) == _output(jsons[2].cells[4]) - @test _output(jsons[1].cells[6]) == _output(jsons[2].cells[6]) + @test length(unique([_output(jsons[1].cells[i]) for i in [2, 4, 6]])) == 3 - close!(server) - end - end + @test _output(jsons[1].cells[2]) == _output(jsons[2].cells[2]) + @test _output(jsons[1].cells[4]) == _output(jsons[2].cells[4]) + @test _output(jsons[1].cells[6]) == _output(jsons[2].cells[6]) + + close!(server) end