Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
c546655d
Commit
c546655d
authored
Oct 31, 2016
by
Ivan Smirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use pytest fixtures in numpy dtypes test module
parent
2184f6d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
tests/test_numpy_dtypes.py
+15
-6
No files found.
tests/test_numpy_dtypes.py
View file @
c546655d
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'
],
'formats'
:
[
'?'
,
'u4'
,
'f4'
],
@pytest.fixture
(
scope
=
'module'
)
'offsets'
:
[
0
,
4
,
8
]})
def
simple_dtype
():
packed_dtype
=
np
.
dtype
([(
'x'
,
'?'
),
(
'y'
,
'u4'
),
(
'z'
,
'f4'
)])
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
):
def
assert_equal
(
actual
,
expected_data
,
expected_dtype
):
...
@@ -32,7 +41,7 @@ def test_format_descriptors():
...
@@ -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():
...
@@ -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
)
...
...
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