Skip to content

Commit

Permalink
TST: revert changed options after running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Apr 29, 2018
1 parent b0325cf commit ce68eb5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ def configure():
"""Configure NumPy so that it raises all warnings as exceptions, and, if a DTYPE environment variable is set in this
testing environment that is different from the default data type, use it for all numeric calculations.
"""
np.seterr(all='raise')
old_error = np.seterr(all='raise')
old_dtype = options.dtype
dtype_string = os.environ.get('DTYPE')
if dtype_string:
dtype = np.dtype(dtype_string)
if np.finfo(dtype).dtype == options.dtype:
options.dtype = np.dtype(dtype_string)
if np.finfo(options.dtype).dtype == old_dtype:
pytest.skip(f"The {dtype_string} data type is the same as the default one in this environment.")
options.dtype = dtype
yield
options.dtype = old_dtype
np.seterr(**old_error)


@pytest.fixture
Expand Down

0 comments on commit ce68eb5

Please sign in to comment.