@@ -743,12 +743,21 @@ end
743
743
@test pyeq (Bool, l[" x" ], 4 )
744
744
# check global code runs in global scope
745
745
pyexec (" global y; y=x+1" , g, l)
746
- @test_throws PythonCall. PyException PythonCall. @pyexec (err = PythonCall. Core. pybuiltins. ValueError) => ` raise err`
747
746
@test pyeq (Bool, g[" y" ], 5 )
748
747
@test ! pycontains (l, " y" )
749
748
# check pyeval converts types correctly
750
749
@test pyeval (Int, " 1+1" , g) === 2
751
750
@test pyeval (Nothing, " None" , g) === nothing
751
+ # @pyexec
752
+ @test_throws PyException @pyexec (` raise ValueError` )
753
+ @test @pyexec (` 1 + 2` ) === nothing
754
+ @test @pyexec (` ans = 1 + 2` => (ans:: Int ,)) === (ans= 3 ,)
755
+ @test @pyexec ((x= 1 , y= 2 ) => ` ans = x + y` => (ans:: Int ,)) === (ans= 3 ,)
756
+ # @pyeval
757
+ @test_throws PyException @pyeval (` import sys` ) # not an expression
758
+ @test_throws PyException @pyeval (` None + None` )
759
+ @test @pyeval (` 1 + 2` => Int) === 3
760
+ @test @pyeval ((x= 1 , y= 2 ) => ` x + y` => Int) === 3
752
761
end
753
762
754
763
@testitem " @pyconst" begin
0 commit comments