You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
999 B

4 years ago
  1. # Pytest customization
  2. from __future__ import division, absolute_import, print_function
  3. import os
  4. import pytest
  5. import warnings
  6. from scipy._lib._fpumode import get_fpu_mode
  7. from scipy._lib._testutils import FPUModeChangeWarning
  8. def pytest_runtest_setup(item):
  9. mark = item.get_marker("xslow")
  10. if mark is not None:
  11. try:
  12. v = int(os.environ.get('SCIPY_XSLOW', '0'))
  13. except ValueError:
  14. v = False
  15. if not v:
  16. pytest.skip("very slow test; set environment variable SCIPY_XSLOW=1 to run it")
  17. @pytest.fixture(scope="function", autouse=True)
  18. def check_fpu_mode(request):
  19. """
  20. Check FPU mode was not changed during the test.
  21. """
  22. old_mode = get_fpu_mode()
  23. yield
  24. new_mode = get_fpu_mode()
  25. if old_mode != new_mode:
  26. warnings.warn("FPU mode changed from {0:#x} to {1:#x} during "
  27. "the test".format(old_mode, new_mode),
  28. category=FPUModeChangeWarning, stacklevel=0)