1- @testset " bool -> Bool" begin
1+ @testitem " bool → Bool" begin
22 @test pyconvert (Bool, true ) === true
33 @test pyconvert (Bool, false ) === false
44 @test_throws Exception pyconvert (Bool, " hello" )
55end
66
7- @testset " bool -> Integer" begin
7+ @testitem " bool → Integer" begin
88 @test pyconvert (Int, true ) === 1
99 @test pyconvert (Int, false ) === 0
1010end
1111
12- @testset " bytes -> Vector" begin
12+ @testitem " bytes → Vector" begin
1313 x1 = pyconvert (Vector{UInt8}, pybytes (pylist ([1 , 2 , 3 ])))
1414 @test x1 isa Vector{UInt8}
1515 @test x1 == [0x01 , 0x02 , 0x03 ]
1818 @test x2 == b " foo"
1919end
2020
21- @testset " complex -> Complex" begin
21+ @testitem " complex → Complex" begin
2222 x1 = pyconvert (ComplexF32, pycomplex (1 , 2 ))
2323 @test x1 === ComplexF32 (1 , 2 )
2424 x2 = pyconvert (Complex, pycomplex (3 , 4 ))
2525 @test x2 === ComplexF64 (3 , 4 )
2626end
2727
28- @testset " float -> Float" begin
28+ @testitem " float → Float" begin
2929 x1 = pyconvert (Float32, 12 )
3030 @test x1 === Float32 (12 )
3131 x2 = pyconvert (Float64, 3.5 )
3232 @test x2 === 3.5
3333end
3434
35- @testset " float -> Nothing" begin
35+ @testitem " float → Nothing" begin
3636 @test_throws Exception pyconvert (Nothing, pyfloat (1.2 ))
3737 x1 = pyconvert (Nothing, pyfloat (NaN ))
3838 @test x1 === nothing
3939end
4040
41- @testset " float -> Missing" begin
41+ @testitem " float → Missing" begin
4242 @test_throws Exception pyconvert (Missing, pyfloat (1.2 ))
4343 x1 = pyconvert (Missing, pyfloat (NaN ))
4444 @test x1 === missing
4545end
4646
47- @testset " int -> Integer" begin
47+ @testitem " int → Integer" begin
4848 @test_throws Exception pyconvert (Int8, 300 )
4949 @test_throws Exception pyconvert (UInt, - 3 )
5050 x1 = pyconvert (Int, 34 )
5858 @test x4 == big (3 )^ 1000
5959end
6060
61- @testset " None -> Nothing" begin
61+ @testitem " None → Nothing" begin
6262 x1 = pyconvert (Nothing, pybuiltins. None)
6363 @test x1 === nothing
6464end
6565
66- @testset " None -> Missing" begin
66+ @testitem " None → Missing" begin
6767 x1 = pyconvert (Missing, pybuiltins. None)
6868 @test x1 === missing
6969end
7070
71- @testset " range -> StepRange" begin
71+ @testitem " range → StepRange" begin
7272 x1 = pyconvert (StepRange, pyrange (10 ))
7373 @test x1 === (0 : 1 : 9 )
7474 x2 = pyconvert (StepRange, pyrange (3 , 9 , 2 ))
7979 @test x4 === (30 : - 3 : - 9 )
8080end
8181
82- @testset " range -> UnitRange" begin
82+ @testitem " range → UnitRange" begin
8383 x1 = pyconvert (UnitRange, pyrange (10 ))
8484 @test x1 === (0 : 9 )
8585 x2 = pyconvert (UnitRange, pyrange (3 , 9 , 1 ))
8686 @test x2 === (3 : 8 )
8787end
8888
89- @testset " str -> String" begin
89+ @testitem " str → String" begin
9090 x1 = pyconvert (String, pystr (" foo" ))
9191 @test x1 === " foo"
9292 x2 = pyconvert (String, pystr (" αβγℵ√" ))
9393 @test x2 === " αβγℵ√"
9494end
9595
96- @testset " str -> Symbol" begin
96+ @testitem " str → Symbol" begin
9797 x1 = pyconvert (Symbol, pystr (" hello" ))
9898 @test x1 === :hello
9999end
100100
101- @testset " str -> Char" begin
101+ @testitem " str → Char" begin
102102 @test_throws Exception pyconvert (Char, pystr (" " ))
103103 @test_throws Exception pyconvert (Char, pystr (" ab" ))
104104 @test_throws Exception pyconvert (Char, pystr (" abc" ))
108108 @test x2 === ' Ψ'
109109end
110110
111- @testset " iterable -> Tuple" begin
111+ @testitem " iterable → Tuple" begin
112112 t1 = pyconvert (Tuple, (1 , 2 ))
113113 @test t1 === (1 , 2 )
114114 t2 = pyconvert (Tuple{Vararg{Int}}, (3 , 4 , 5 ))
120120 @test t4 === ntuple (i-> i, 30 )
121121end
122122
123- @testset " iterable -> Vector" begin
123+ @testitem " iterable → Vector" begin
124124 x1 = pyconvert (Vector, pylist ([1 , 2 ]))
125125 @test x1 isa Vector{Int}
126126 @test x1 == [1 , 2 ]
132132 @test x3 == [4.0 , 5.0 , 6.0 ]
133133end
134134
135- @testset " iterable -> Set" begin
135+ @testitem " iterable → Set" begin
136136 x1 = pyconvert (Set, pyset ([1 , 2 ]))
137137 @test x1 isa Set{Int}
138138 @test x1 == Set ([1 , 2 ])
144144 @test x3 == Set ([4.0 , 5.0 , 6.0 ])
145145end
146146
147- @testset " iterable -> Pair" begin
147+ @testitem " iterable → Pair" begin
148148 @test_throws Exception pyconvert (Pair, ())
149149 @test_throws Exception pyconvert (Pair, (1 ,))
150150 @test_throws Exception pyconvert (Pair, (1 , 2 , 3 ))
154154 @test x2 === (" foo" => missing )
155155end
156156
157- @testset " mapping -> Dict" begin
157+ @testitem " mapping → Dict" begin
158158 x1 = pyconvert (Dict, pydict ([" a" => 1 , " b" => 2 ]))
159159 @test x1 isa Dict{String, Int}
160160 @test x1 == Dict (" a" => 1 , " b" => 2 )
@@ -163,17 +163,20 @@ end
163163 @test x2 == Dict (' c' => 3.0 , ' d' => 4.0 )
164164end
165165
166- @testset " date -> Date" begin
166+ @testitem " date → Date" begin
167+ using Dates
167168 x1 = pyconvert (Date, pydate (2001 , 2 , 3 ))
168169 @test x1 === Date (2001 , 2 , 3 )
169170end
170171
171- @testset " time -> Time" begin
172+ @testitem " time → Time" begin
173+ using Dates
172174 x1 = pyconvert (Time, pytime (12 , 3 , 4 , 5 ))
173175 @test x1 === Time (12 , 3 , 4 , 0 , 5 )
174176end
175177
176- @testset " datetime -> DateTime" begin
178+ @testitem " datetime → DateTime" begin
179+ using Dates
177180 x1 = pyconvert (DateTime, pydatetime (2001 , 2 , 3 , 4 , 5 , 6 , 7000 ))
178181 @test x1 === DateTime (2001 , 2 , 3 , 4 , 5 , 6 , 7 )
179182end
0 commit comments