Esempio n. 1
0
        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())
        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())
Esempio n. 3
0
def check_fpu_mode(request):
    """
    Check FPU precision mode was not changed during the test.
    """
    old_mode = get_fpu_mode()
    yield
    new_mode = get_fpu_mode()

    if old_mode != new_mode:
        raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}"
                             " during the test".format(old_mode, new_mode))

    collect_result = _collect_results.get(request.node)
    if collect_result is not None:
        old_mode, new_mode = collect_result
        raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}"
                             " when collecting the test".format(old_mode, 
                                                                new_mode))
Esempio n. 4
0
def check_fpu_mode(request):
    """
    Check FPU precision mode was not changed during the test.
    """
    old_mode = get_fpu_mode()
    yield
    new_mode = get_fpu_mode()

    if old_mode != new_mode:
        raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}"
                             " during the test".format(old_mode, new_mode))

    collect_result = _collect_results.get(request.node)
    if collect_result is not None:
        old_mode, new_mode = collect_result
        raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}"
                             " when collecting the test".format(
                                 old_mode, new_mode))
Esempio n. 5
0
def pytest_itemcollected(item):
    """
    Check FPU precision mode was not changed during test collection.

    The clumsy way we do it here is mainly necessary because numpy
    still uses yield tests, which can execute code at test collection 
    time.
    """
    global _old_fpu_mode

    mode = get_fpu_mode()

    if _old_fpu_mode is None:
        _old_fpu_mode = mode
    elif mode != _old_fpu_mode:
        _collect_results[item] = (_old_fpu_mode, mode)
        _old_fpu_mode = mode
Esempio n. 6
0
def pytest_itemcollected(item):
    """
    Check FPU precision mode was not changed during test collection.

    The clumsy way we do it here is mainly necessary because numpy
    still uses yield tests, which can execute code at test collection 
    time.
    """
    global _old_fpu_mode

    mode = get_fpu_mode()

    if _old_fpu_mode is None:
        _old_fpu_mode = mode
    elif mode != _old_fpu_mode:
        _collect_results[item] = (_old_fpu_mode, mode)
        _old_fpu_mode = mode