@@ -155,7 +155,7 @@ const PyInt = pyversion < v"3" ? Int : Clonglong
155
155
156
156
# issue #92:
157
157
let x = PyVector (PyAny[])
158
- py " lambda x: x.append(\ " bar\" ) " (x)
158
+ py ` lambda x: x.append("bar") ` (x)
159
159
@test x == [" bar" ]
160
160
end
161
161
@@ -267,21 +267,21 @@ const PyInt = pyversion < v"3" ? Int : Clonglong
267
267
@test convert (BigInt, PyObject (1234 )) == 1234
268
268
269
269
# hasproperty, getproperty, and propertynames
270
- py """
270
+ py ```
271
271
class A:
272
272
class B:
273
273
C = 1
274
- """
275
- A = py " A "
274
+ ```
275
+ A = py ` A `
276
276
@test hasproperty (A, " B" )
277
- @test getproperty (A, " B" ) == py " A.B"
277
+ @test getproperty (A, " B" ) == py ` A.B`
278
278
@test :B in propertynames (A)
279
279
@static if VERSION >= v " 0.7-"
280
280
@test A. B. C == 1
281
281
@test_throws KeyError A. X
282
282
end
283
- setproperty! (py " A.B" , " C" , 2 )
284
- @test py " A.B.C" == 2
283
+ setproperty! (py ` A.B` , " C" , 2 )
284
+ @test py ` A.B.C` == 2
285
285
286
286
# buffers
287
287
let b = PyCall. PyBuffer (pyutf8 (" test string" ))
@@ -373,23 +373,23 @@ const PyInt = pyversion < v"3" ? Int : Clonglong
373
373
end
374
374
375
375
let x = 7
376
- py """
376
+ py ```
377
377
def myfun(x):
378
378
return x + $x
379
- """
380
- @test py " 1 + 2" == 3
381
- @test py " 1 + $x" == 8
382
- @test py " 1 + $(x^2)" == 50
383
- @test py " myfun" (10 ) == 17
379
+ ```
380
+ @test py ` 1 + 2` == 3
381
+ @test py ` 1 + $x ` == 8
382
+ @test py ` 1 + $(x^ 2 ) ` == 50
383
+ @test py ` myfun` (10 ) == 17
384
384
end
385
385
386
386
# issue #352
387
387
let x = " 1+1"
388
- @test py " $x " == " 1+1"
389
- @test py " $$x" == py " $$(x)" == 2
390
- @test py " 7 - $$x - 7" == 0 # evaluates "7 - 1 + 1 - 7"
391
- @test py " 7 - ($$x) - 7" == - 2 # evaluates "7 - (1 + 1) - 7"
392
- @test py " 1 + $$(x[1:2]) 3" == 5 # evals 1 + 1+ 3
388
+ @test py ` $x ` == " 1+1"
389
+ @test py ` $$x ` == py ` $$(x) ` == 2
390
+ @test py ` 7 - $$x - 7` == 0 # evaluates "7 - 1 + 1 - 7"
391
+ @test py ` 7 - ($$x ) - 7` == - 2 # evaluates "7 - (1 + 1) - 7"
392
+ @test py ` 1 + $$(x[1 : 2 ]) 3` == 5 # evals 1 + 1+ 3
393
393
end
394
394
395
395
# Float16 support:
@@ -429,15 +429,15 @@ const PyInt = pyversion < v"3" ? Int : Clonglong
429
429
end
430
430
431
431
# Expose python docs to Julia doc system
432
- py """
432
+ py ```
433
433
def foo():
434
434
"foo docstring"
435
435
return 0
436
436
class bar:
437
437
foo = foo
438
- """
439
- global foo354 = py " foo"
440
- global barclass = py " bar"
438
+ ```
439
+ global foo354 = py ` foo`
440
+ global barclass = py ` bar`
441
441
# use 'content' since `Text` objects test equality by object identity
442
442
@test @doc (foo354). content == " foo docstring"
443
443
@test @doc (barclass. foo). content == " foo docstring"
@@ -518,7 +518,7 @@ const PyInt = pyversion < v"3" ? Int : Clonglong
518
518
end
519
519
520
520
@test occursin (" integer" , Base. Docs. doc (PyObject (1 )). content)
521
- @test occursin (" no docstring" , Base. Docs. doc (PyObject (py " lambda x: x+1" )). content)
521
+ @test occursin (" no docstring" , Base. Docs. doc (PyObject (py ` lambda x: x+1` )). content)
522
522
523
523
let b = rand (UInt8, 1000 )
524
524
@test (convert (Vector{UInt8}, pybytes (b)) == b
@@ -555,9 +555,9 @@ const PyInt = pyversion < v"3" ? Int : Clonglong
555
555
@test_throws KeyError PyObject (TestConstruct (1 )). y
556
556
557
557
# iterating over Julia objects in Python:
558
- @test py " [x**2 for x in $(PyCall.pyjlwrap_new(1:4))]" ==
559
- py " [x**2 for x in $(x for x in 1:4)]" ==
560
- py " [x**2 for x in $(PyCall.jlwrap_iterator(1:4))]" ==
558
+ @test py ` [x**2 for x in $(PyCall. pyjlwrap_new (1 : 4 )) ]` ==
559
+ py ` [x**2 for x in $(x for x in 1 : 4 ) ]` ==
560
+ py ` [x**2 for x in $(PyCall. jlwrap_iterator (1 : 4 )) ]` ==
561
561
[1 ,4 ,9 ,16 ]
562
562
563
563
let o = PyObject (" foo" )
@@ -580,7 +580,7 @@ const PyInt = pyversion < v"3" ? Int : Clonglong
580
580
end
581
581
582
582
# issue #533
583
- @test py " lambda x,y,z: (x,y,z)" (3 : 6 ,4 : 10 ,5 : 11 ) === (PyInt (3 ): PyInt (6 ), PyInt (4 ): PyInt (10 ), PyInt (5 ): PyInt (11 ))
583
+ @test py ` lambda x,y,z: (x,y,z)` (3 : 6 ,4 : 10 ,5 : 11 ) === (PyInt (3 ): PyInt (6 ), PyInt (4 ): PyInt (10 ), PyInt (5 ): PyInt (11 ))
584
584
585
585
@test float (PyObject (1 )) === 1.0
586
586
@test float (PyObject (1 + 2im )) === 1.0 + 2.0im
@@ -650,12 +650,12 @@ end
650
650
using PyCall
651
651
obj = pyimport (" sys" ) # get some PyObject
652
652
end )
653
- py """
653
+ py ```
654
654
ns = {}
655
655
def set(name):
656
656
ns[name] = $include_string ($anonymous , name)
657
- """
658
- py " set" (" obj" )
657
+ ```
658
+ py ` set` (" obj" )
659
659
@test anonymous. obj != PyNULL ()
660
660
661
661
# Test above for pyjlwrap_getattr too:
@@ -668,12 +668,12 @@ end
668
668
end
669
669
obj = S (pyimport (" sys" ))
670
670
end )
671
- py """
671
+ py ```
672
672
ns = {}
673
673
def set(name):
674
674
ns[name] = $include_string ($anonymous , name).x
675
- """
676
- py " set" (" obj" )
675
+ ```
676
+ py ` set` (" obj" )
677
677
@test anonymous. obj. x != PyNULL ()
678
678
679
679
# Test above for pyjlwrap_iternext too:
@@ -684,41 +684,41 @@ end
684
684
sys = pyimport (" sys" )
685
685
obj = (sys for _ in 1 : 1 )
686
686
end )
687
- py """
687
+ py ```
688
688
ns = {}
689
689
def set(name):
690
690
ns[name] = list(iter($include_string ($anonymous , name)))
691
- """
692
- py " set" (" obj" )
691
+ ```
692
+ py ` set` (" obj" )
693
693
@test anonymous. sys != PyNULL ()
694
694
end
695
695
696
696
struct Unprintable end
697
697
Base. show (:: IO , :: Unprintable ) = error (" show(::IO, ::Unprintable) called" )
698
698
Base. show (:: IO , :: Type{Unprintable} ) = error (" show(::IO, ::Type{Unprintable}) called" )
699
699
700
- py """
700
+ py ```
701
701
def try_repr(x):
702
702
try:
703
703
return repr(x)
704
704
except Exception as err:
705
705
return err
706
- """
706
+ ```
707
707
708
- py """
708
+ py ```
709
709
def try_call(f):
710
710
try:
711
711
return f()
712
712
except Exception as err:
713
713
return err
714
- """
714
+ ```
715
715
716
716
@testset " throwing show" begin
717
717
unp = Unprintable ()
718
718
@test_throws Exception show (unp)
719
- @test py " try_repr" (" printable" ) isa String
720
- @test pyisinstance (py " try_repr" (unp), pybuiltin (" Exception" ))
721
- @test pyisinstance (py " try_call" (() -> throw (Unprintable ())),
719
+ @test py ` try_repr` (" printable" ) isa String
720
+ @test pyisinstance (py ` try_repr` (unp), pybuiltin (" Exception" ))
721
+ @test pyisinstance (py ` try_call` (() -> throw (Unprintable ())),
722
722
pybuiltin (" Exception" ))
723
723
end
724
724
@@ -749,25 +749,25 @@ end
749
749
@test Base. IteratorSize (PyCall. PyIterator (PyObject ([1 ]))) == Base. HasLength ()
750
750
751
751
# 594
752
- @test collect (zip (py " iter([1, 2, 3])" , 1 : 3 )) ==
752
+ @test collect (zip (py ` iter([1, 2, 3])` , 1 : 3 )) ==
753
753
[(1 , 1 ), (2 , 2 ), (3 , 3 )]
754
- @test collect (zip (PyCall. PyIterator {Int} (py " iter([1, 2, 3])" ), 1 : 3 )) ==
754
+ @test collect (zip (PyCall. PyIterator {Int} (py ` iter([1, 2, 3])` ), 1 : 3 )) ==
755
755
[(1 , 1 ), (2 , 2 ), (3 , 3 )]
756
- @test collect (zip (PyCall. PyIterator (py " [1, 2, 3]" o ), 1 : 3 )) ==
756
+ @test collect (zip (PyCall. PyIterator (py ` [1, 2, 3]` o ), 1 : 3 )) ==
757
757
[(1 , 1 ), (2 , 2 ), (3 , 3 )]
758
758
end
759
759
760
- @test_throws PyCall. PyError py " __testing_pynamespace"
760
+ @test_throws PyCall. PyError py ` __testing_pynamespace`
761
761
762
762
module __isolated_namespace
763
763
using PyCall
764
- py """
764
+ py ```
765
765
__testing_pynamespace = True
766
- """
767
- get_testing_pynamespace () = py " __testing_pynamespace"
766
+ ```
767
+ get_testing_pynamespace () = py ` __testing_pynamespace`
768
768
end
769
769
770
- @test_throws PyCall. PyError py " __testing_pynamespace"
770
+ @test_throws PyCall. PyError py ` __testing_pynamespace`
771
771
@test __isolated_namespace. get_testing_pynamespace ()
772
772
773
773
@testset " atexit" begin
0 commit comments