Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
c546655d
Commit
c546655d
authored
Oct 31, 2016
by
Ivan Smirnov
Browse files
Use pytest fixtures in numpy dtypes test module
parent
2184f6d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
tests/test_numpy_dtypes.py
tests/test_numpy_dtypes.py
+15
-6
No files found.
tests/test_numpy_dtypes.py
View file @
c546655d
import
re
import
pytest
with
pytest
.
suppress
(
ImportError
):
import
numpy
as
np
simple_dtype
=
np
.
dtype
({
'names'
:
[
'x'
,
'y'
,
'z'
],
'formats'
:
[
'?'
,
'u4'
,
'f4'
],
'offsets'
:
[
0
,
4
,
8
]})
packed_dtype
=
np
.
dtype
([(
'x'
,
'?'
),
(
'y'
,
'u4'
),
(
'z'
,
'f4'
)])
@
pytest
.
fixture
(
scope
=
'module'
)
def
simple_dtype
():
return
np
.
dtype
({
'names'
:
[
'x'
,
'y'
,
'z'
],
'formats'
:
[
'?'
,
'u4'
,
'f4'
],
'offsets'
:
[
0
,
4
,
8
]})
@
pytest
.
fixture
(
scope
=
'module'
)
def
packed_dtype
():
return
np
.
dtype
([(
'x'
,
'?'
),
(
'y'
,
'u4'
),
(
'z'
,
'f4'
)])
def
assert_equal
(
actual
,
expected_data
,
expected_dtype
):
...
...
@@ -32,7 +41,7 @@ def test_format_descriptors():
@
pytest
.
requires_numpy
def
test_dtype
():
def
test_dtype
(
simple_dtype
):
from
pybind11_tests
import
print_dtypes
,
test_dtype_ctors
,
test_dtype_methods
assert
print_dtypes
()
==
[
...
...
@@ -57,7 +66,7 @@ def test_dtype():
@
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
,
print_rec_simple
,
print_rec_packed
,
print_rec_nested
,
create_rec_partial
,
create_rec_partial_nested
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment