Closed AbhimanyuAryan closed 2 years ago
Also Macros are expanded before the code is executed
so tried
test_with.jl
using PyCall
@safetestset "With Macro Test" begin
@pywith pybuiltin("open")("file.txt","w") as f begin
f.write("hello")
end
end
Error:
Got exception outside of a @test
LoadError: LoadError: UndefVarError: @pywith not defined
runtests.jl
cd(@__DIR__)
using Pkg
using Test, TestSetExtensions, SafeTestsets, Logging
Logging.global_logger(NullLogger())
@testset ExtendedTestSet "Pycall tests" begin
@includetests ARGS #[(endswith(t, ".jl") && t[1:end-3]) for t in ARGS]
end
julia> include("runtests.jl")
solved by using separate file for test and including the file in safetestset
Trying to call a macro inside
@safetestset
for testing purposes. Keep getting errors@pywith
,@py_str
,@uitest
(coming from my package which uses pycall) not definedError Stack:
Doesn't work inside
@safetestset
infact nomacro
does. Tested@pywith
as well says definition not found. Maybe I'm doing something wrong. Can anyone point me to right direction?