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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
import pyximport;
pyximport.install(setup_args = {"script_args" : ["--force"]},
language_level=3)
from unittestmock import UnitTestMock
import tests.unit_tests.cyinterfacetester as cyt
from cykhash import Int64Set, Int32Set, Float64Set, Float32Set, PyObjectSet
#just making sure the interface can be accessed:
class TestCyIntegerface(UnitTestMock):
def test_cimport_works_i64(self):
received=cyt.py_isin_int64([1,2,3,4], [2,4])
expected=[False, True, False, True]
self.assertEqual(received, expected)
def test_iter_interface_works_i64(self):
cy_set = Int64Set()
py_set = set()
for i in range(10):
cy_set.add(i)
py_set.add(i)
clone = cyt.as_py_set_int64(cy_set)
self.assertEqual(py_set, clone)
### -------------------------------
def test_cimport_works_i32(self):
received=cyt.py_isin_int32([1,2,3,4], [2,4])
expected=[False, True, False, True]
self.assertEqual(received, expected)
def test_iter_interface_works_i32(self):
cy_set = Int32Set()
py_set = set()
for i in range(10):
cy_set.add(i)
py_set.add(i)
clone = cyt.as_py_set_int32(cy_set)
self.assertEqual(py_set, clone)
### -------------------------------
def test_cimport_works_f64(self):
received=cyt.py_isin_float64([1,2,3,4], [2,4])
expected=[False, True, False, True]
self.assertEqual(received, expected)
def test_iter_interface_works_f64(self):
cy_set = Float64Set()
py_set = set()
for i in range(10):
cy_set.add(i)
py_set.add(i)
clone = cyt.as_py_set_float64(cy_set)
self.assertEqual(py_set, clone)
### -------------------------------
def test_cimport_works_f32(self):
received=cyt.py_isin_float32([1,2,3,4], [2,4])
expected=[False, True, False, True]
self.assertEqual(received, expected)
def test_iter_interface_works_f32(self):
cy_set = Float32Set()
py_set = set()
for i in range(10):
cy_set.add(i)
py_set.add(i)
clone = cyt.as_py_set_float32(cy_set)
self.assertEqual(py_set, clone)
### -------------------------------
def test_cimport_works_pyobject(self):
received=cyt.py_isin_pyobject([1,2,3,4], [2,4])
expected=[False, True, False, True]
self.assertEqual(received, expected)
def test_iter_interface_works_pyobject(self):
cy_set = PyObjectSet()
py_set = set()
for i in range(10):
cy_set.add(i)
py_set.add(i)
clone = cyt.as_py_set_pyobject(cy_set)
self.assertEqual(py_set, clone)
|