diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2018-09-06 04:14:34 -0400 |
---|---|---|
committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2018-09-06 04:14:34 -0400 |
commit | cb7dca7c3c963ff14c4f58507d3672536c441921 (patch) | |
tree | f6e229beefeeab572d4867a287af61eb11986529 /numpy/f2py/tests | |
parent | 9c585ad6a97258335edca6913b8df628b6f68289 (diff) | |
download | numpy-cb7dca7c3c963ff14c4f58507d3672536c441921.tar.gz |
TST: Use fixture around f2py shared memory tests.
This allows to parametrize the entire class without having to do any
trickery with eval.
Diffstat (limited to 'numpy/f2py/tests')
-rw-r--r-- | numpy/f2py/tests/test_array_from_pyobj.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/numpy/f2py/tests/test_array_from_pyobj.py b/numpy/f2py/tests/test_array_from_pyobj.py index 8b021491f..1ab2eaf33 100644 --- a/numpy/f2py/tests/test_array_from_pyobj.py +++ b/numpy/f2py/tests/test_array_from_pyobj.py @@ -1,10 +1,11 @@ from __future__ import division, absolute_import, print_function -import unittest import os import sys import copy +import pytest + from numpy import ( array, alltrue, ndarray, zeros, dtype, intp, clongdouble ) @@ -304,10 +305,16 @@ class TestIntent(object): assert_(not intent.in_.is_intent('c')) -class _test_shared_memory(object): +class TestSharedMemory(object): num2seq = [1, 2] num23seq = [[1, 2, 3], [4, 5, 6]] + @pytest.fixture(autouse=True, scope='class', params=_type_names) + def setup_type(self, request): + request.cls.type = Type(request.param) + request.cls.array = lambda self, dims, intent, obj: \ + Array(Type(request.param), dims, intent, obj) + def test_in_from_2seq(self): a = self.array([2], intent.in_, self.num2seq) assert_(not a.has_shared_memory()) @@ -573,12 +580,3 @@ class _test_shared_memory(object): assert_(obj.flags['FORTRAN']) # obj attributes changed inplace! assert_(not obj.flags['CONTIGUOUS']) assert_(obj.dtype.type is self.type.dtype) # obj changed inplace! - - -for t in _type_names: - exec('''\ -class TestGen_%s(_test_shared_memory): - def setup(self): - self.type = Type(%r) - array = lambda self,dims,intent,obj: Array(Type(%r),dims,intent,obj) -''' % (t, t, t)) |