-
Notifications
You must be signed in to change notification settings - Fork 763
/
test_sequence.py
41 lines (26 loc) · 1.09 KB
/
test_sequence.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pytest
import platform
from pyo3_pytests import sequence
def test_vec_from_list_i32():
assert sequence.vec_to_vec_i32([1, 2, 3]) == [1, 2, 3]
def test_vec_from_list_pystring():
assert sequence.vec_to_vec_pystring(["1", "2", "3"]) == ["1", "2", "3"]
def test_vec_from_bytes():
assert sequence.vec_to_vec_i32(b"123") == [49, 50, 51]
def test_vec_from_str():
with pytest.raises(TypeError):
sequence.vec_to_vec_pystring("123")
@pytest.mark.skipif(
platform.system() != "Linux" or platform.python_implementation() != "CPython",
reason="Binary NumPy wheels are not available for all platforms and Python implementations",
)
def test_vec_from_array():
import numpy
assert sequence.vec_to_vec_i32(numpy.array([1, 2, 3])) == [1, 2, 3]
@pytest.mark.skipif(
platform.system() != "Linux" or platform.python_implementation() != "CPython",
reason="Binary NumPy wheels are not available for all platforms and Python implementations",
)
def test_rust_array_from_array():
import numpy
assert sequence.array_to_array_i32(numpy.array([1, 2, 3])) == [1, 2, 3]