Is there any way to test the appearance of a string inside one of the variables being printed from @info
? In the example below, I want to test the string world
appearing in the info log. I don’t really care where it appears but if we can also test that it comes from variable s
then it would perfect.
julia> function foo()
s = "world"
@info "hello" s
end
julia> foo()
┌ Info: hello
└ s = "world"
julia> @test_logs (:info, "hello") foo()
julia> @test_logs (:info, r"world") foo()
Log Test Failed at REPL[40]:1
Expression: foo()
Log Pattern: (:info, r"world")
Captured Logs:
Test.LogRecord(Info, "hello", Main, Symbol("REPL[36]"), :Main_1f7f3d29, "REPL[36]", 3, Base.Iterators.Pairs(:s => "world"))
ERROR: There was an error during testing