Skip to content

Commit

Permalink
remove copypasted code that unnecessarily created a new notebook file…
Browse files Browse the repository at this point in the history
… away from the project
  • Loading branch information
jkrumbiegel committed Oct 14, 2024
1 parent 393b3e3 commit ae3a300
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions test/testsets/random_seed.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ae3a300

Please sign in to comment.