| 783 | |
| 784 | @needs_cffi |
| 785 | def test_import_device_no_cuda(): |
| 786 | try: |
| 787 | import pyarrow.cuda # noqa |
| 788 | except ImportError: |
| 789 | pass |
| 790 | else: |
| 791 | pytest.skip("pyarrow.cuda is available") |
| 792 | |
| 793 | c_array = ffi.new("struct ArrowDeviceArray*") |
| 794 | ptr_array = int(ffi.cast("uintptr_t", c_array)) |
| 795 | arr = pa.array([1, 2, 3], type=pa.int64()) |
| 796 | arr._export_to_c_device(ptr_array) |
| 797 | |
| 798 | # patch the device type of the struct, this results in an invalid ArrowDeviceArray |
| 799 | # but this is just to test we raise am error before actually importing buffers |
| 800 | c_array.device_type = 2 # ARROW_DEVICE_CUDA |
| 801 | |
| 802 | with pytest.raises(ImportError, match="Trying to import data on a CUDA device"): |
| 803 | pa.Array._import_from_c_device(ptr_array, arr.type) |