mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 16:37:13 +00:00
Use pytest fixtures in numpy dtypes test module
This commit is contained in:
parent
2184f6d4d6
commit
c546655dc2
@ -1,11 +1,20 @@
|
|||||||
|
import re
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
with pytest.suppress(ImportError):
|
with pytest.suppress(ImportError):
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
simple_dtype = np.dtype({'names': ['x', 'y', 'z'],
|
|
||||||
|
@pytest.fixture(scope='module')
|
||||||
|
def simple_dtype():
|
||||||
|
return np.dtype({'names': ['x', 'y', 'z'],
|
||||||
'formats': ['?', 'u4', 'f4'],
|
'formats': ['?', 'u4', 'f4'],
|
||||||
'offsets': [0, 4, 8]})
|
'offsets': [0, 4, 8]})
|
||||||
packed_dtype = np.dtype([('x', '?'), ('y', 'u4'), ('z', 'f4')])
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='module')
|
||||||
|
def packed_dtype():
|
||||||
|
return np.dtype([('x', '?'), ('y', 'u4'), ('z', 'f4')])
|
||||||
|
|
||||||
|
|
||||||
def assert_equal(actual, expected_data, expected_dtype):
|
def assert_equal(actual, expected_data, expected_dtype):
|
||||||
@ -32,7 +41,7 @@ def test_format_descriptors():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.requires_numpy
|
@pytest.requires_numpy
|
||||||
def test_dtype():
|
def test_dtype(simple_dtype):
|
||||||
from pybind11_tests import print_dtypes, test_dtype_ctors, test_dtype_methods
|
from pybind11_tests import print_dtypes, test_dtype_ctors, test_dtype_methods
|
||||||
|
|
||||||
assert print_dtypes() == [
|
assert print_dtypes() == [
|
||||||
@ -57,7 +66,7 @@ def test_dtype():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.requires_numpy
|
@pytest.requires_numpy
|
||||||
def test_recarray():
|
def test_recarray(simple_dtype, packed_dtype):
|
||||||
from pybind11_tests import (create_rec_simple, create_rec_packed, create_rec_nested,
|
from pybind11_tests import (create_rec_simple, create_rec_packed, create_rec_nested,
|
||||||
print_rec_simple, print_rec_packed, print_rec_nested,
|
print_rec_simple, print_rec_packed, print_rec_nested,
|
||||||
create_rec_partial, create_rec_partial_nested)
|
create_rec_partial, create_rec_partial_nested)
|
||||||
|
Loading…
Reference in New Issue
Block a user