How can I test 3-arg `show` methods? `@test sprint(?, x) == "expected"`

how can I test 3-arg show methods?
@test sprint(????, x) == "expected"

Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or pinging the poster here on Discourse so they can follow this thread.
(Original message :slack:) (More Info)

@fredrikekre
You can just pass the mime to sprint:

julia> sprint(show, MIME("text/plain"), [1, 2, 3])
"3-element Vector{Int64}:\n 1\n 2\n 3"
julia> sprint(show, [1, 2, 3])
"[1, 2, 3]"
1 Like

@giordano
I usually use repr
the first argument to repr is the MIME

julia> repr("text/plain", [1, 2, 3])
"3-element Vector{Int64}:\n 1\n 2\n 3"
julia> repr([1, 2, 3])
"[1, 2, 3]"
1 Like