|
223 | 223 | end |
224 | 224 |
|
225 | 225 | @testitem "iter" begin |
226 | | - @test_throws PyException pyiter(pybuiltins.None) |
227 | | - @test_throws PyException pyiter(pybuiltins.True) |
228 | | - # unsafe_pynext |
229 | | - it = pyiter(pyrange(2)) |
230 | | - x = PythonCall.unsafe_pynext(it) |
231 | | - @test !PythonCall.pyisnull(x) |
232 | | - @test pyeq(Bool, x, 0) |
233 | | - x = PythonCall.unsafe_pynext(it) |
234 | | - @test !PythonCall.pyisnull(x) |
235 | | - @test pyeq(Bool, x, 1) |
236 | | - x = PythonCall.unsafe_pynext(it) |
237 | | - @test PythonCall.pyisnull(x) |
238 | | - # pynext |
239 | | - it = pyiter(pyrange(2)) |
240 | | - x = pynext(it) |
241 | | - @test pyeq(Bool, x, 0) |
242 | | - x = pynext(it) |
243 | | - @test pyeq(Bool, x, 1) |
244 | | - @test_throws PyException pynext(it) |
| 226 | + @testset "non-iterables" begin |
| 227 | + @test_throws PyException pyiter(pybuiltins.None) |
| 228 | + @test_throws PyException pyiter(pybuiltins.True) |
| 229 | + end |
| 230 | + @testset "unsafe_pynext" begin |
| 231 | + it = pyiter(pyrange(2)) |
| 232 | + x = PythonCall.unsafe_pynext(it) |
| 233 | + @test x isa Py |
| 234 | + @test !PythonCall.pyisnull(x) |
| 235 | + @test pyeq(Bool, x, 0) |
| 236 | + x = PythonCall.unsafe_pynext(it) |
| 237 | + @test x isa Py |
| 238 | + @test !PythonCall.pyisnull(x) |
| 239 | + @test pyeq(Bool, x, 1) |
| 240 | + x = PythonCall.unsafe_pynext(it) |
| 241 | + @test x isa Py |
| 242 | + @test PythonCall.pyisnull(x) |
| 243 | + end |
| 244 | + @testset "pynext" begin |
| 245 | + it = pyiter(pyrange(2)) |
| 246 | + x = pynext(it) |
| 247 | + @test x isa Py |
| 248 | + @test pyeq(Bool, x, 0) |
| 249 | + x = pynext(it) |
| 250 | + @test x isa Py |
| 251 | + @test pyeq(Bool, x, 1) |
| 252 | + @test_throws PyException pynext(it) |
| 253 | + end |
| 254 | + @testset "pynext with default" begin |
| 255 | + it = pyiter(pyrange(2)) |
| 256 | + x = pynext(it, nothing) |
| 257 | + @test x isa Py |
| 258 | + @test pyeq(Bool, x, 0) |
| 259 | + x = pynext(it, nothing) |
| 260 | + @test x isa Py |
| 261 | + @test pyeq(Bool, x, 1) |
| 262 | + x = pynext(it, nothing) |
| 263 | + @test x === nothing |
| 264 | + end |
245 | 265 | end |
246 | 266 |
|
247 | 267 | @testitem "number" begin |
|
0 commit comments