diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2017-08-16 14:19:17 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-16 14:19:17 -0500 |
commit | 26c79664d2edd48e1777cc4b31ecb952e2ec30d5 (patch) | |
tree | 0dfe2a03d716fbd8116d3d02150dc453bf741a26 /numpy/testing/nose_tools | |
parent | 663094532de48e131793faaa0ba06eb7c051ab47 (diff) | |
parent | 3deb8fa4f4d25e434c86188593f95dfc2fed041c (diff) | |
download | numpy-26c79664d2edd48e1777cc4b31ecb952e2ec30d5.tar.gz |
Merge pull request #9574 from pv/fpflag
BUG: deal with broken hypot() for MSVC on win32
Diffstat (limited to 'numpy/testing/nose_tools')
-rw-r--r-- | numpy/testing/nose_tools/noseclasses.py | 26 | ||||
-rw-r--r-- | numpy/testing/nose_tools/nosetester.py | 15 |
2 files changed, 38 insertions, 3 deletions
diff --git a/numpy/testing/nose_tools/noseclasses.py b/numpy/testing/nose_tools/noseclasses.py index 2f5d05004..9756b9b45 100644 --- a/numpy/testing/nose_tools/noseclasses.py +++ b/numpy/testing/nose_tools/noseclasses.py @@ -7,6 +7,7 @@ from __future__ import division, absolute_import, print_function import os +import sys import doctest import inspect @@ -317,6 +318,31 @@ class KnownFailurePlugin(ErrorClassPlugin): KnownFailure = KnownFailurePlugin # backwards compat +class FPUModeCheckPlugin(Plugin): + """ + Plugin that checks the FPU mode before and after each test, + raising failures if the test changed the mode. + """ + + def prepareTestCase(self, test): + from numpy.core.multiarray_tests import get_fpu_mode + + def run(result): + old_mode = get_fpu_mode() + test.test(result) + new_mode = get_fpu_mode() + + if old_mode != new_mode: + try: + raise AssertionError( + "FPU mode changed from {0:#x} to {1:#x} during the " + "test".format(old_mode, new_mode)) + except AssertionError: + result.addFailure(test, sys.exc_info()) + + return run + + # Class allows us to save the results of the tests in runTests - see runTests # method docstring for details class NumpyTestProgram(nose.core.TestProgram): diff --git a/numpy/testing/nose_tools/nosetester.py b/numpy/testing/nose_tools/nosetester.py index 407653fc3..c2cf58377 100644 --- a/numpy/testing/nose_tools/nosetester.py +++ b/numpy/testing/nose_tools/nosetester.py @@ -154,7 +154,8 @@ class NoseTester(object): want to initialize `NoseTester` objects on behalf of other code. """ - def __init__(self, package=None, raise_warnings="release", depth=0): + def __init__(self, package=None, raise_warnings="release", depth=0, + check_fpu_mode=False): # Back-compat: 'None' used to mean either "release" or "develop" # depending on whether this was a release or develop version of # numpy. Those semantics were fine for testing numpy, but not so @@ -191,6 +192,9 @@ class NoseTester(object): # Set to "release" in constructor in maintenance branches. self.raise_warnings = raise_warnings + # Whether to check for FPU mode changes + self.check_fpu_mode = check_fpu_mode + def _test_argv(self, label, verbose, extra_argv): ''' Generate argv for nosetest command @@ -289,9 +293,13 @@ class NoseTester(object): # construct list of plugins import nose.plugins.builtin from nose.plugins import EntryPointPluginManager - from .noseclasses import KnownFailurePlugin, Unplugger + from .noseclasses import (KnownFailurePlugin, Unplugger, + FPUModeCheckPlugin) plugins = [KnownFailurePlugin()] plugins += [p() for p in nose.plugins.builtin.plugins] + if self.check_fpu_mode: + plugins += [FPUModeCheckPlugin()] + argv += ["--with-fpumodecheckplugin"] try: # External plugins (like nose-timer) entrypoint_manager = EntryPointPluginManager() @@ -548,4 +556,5 @@ def _numpy_tester(): mode = "develop" else: mode = "release" - return NoseTester(raise_warnings=mode, depth=1) + return NoseTester(raise_warnings=mode, depth=1, + check_fpu_mode=True) |