From 3f111a429195c3b892240bb22a67e39cf2230bdd Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Thu, 6 Sep 2018 13:17:12 -0600 Subject: BUG: Fix matrix PendingDeprecationWarning suppression for pytest 3.8+. Pytest < 3.8 ignored warnings issued during test collection, but that changed in pytest 3.8 and the method NumPy used to suppress the PendingDeprecationWarning for matrices no longer worked, or rather, was exposed as not working. The fix here is to suppress the warning in pytest.ini and pytesttester.py , which should work as long as the tests are the only places left where NumPy uses matrices. An alternate fix is to delay the construction of matrices in the tests until they are actually run, which has the virtue of test localization but is a bit more complicated. See https://github.com/pytest-dev/pytest/issues/3945 for discussion. --- numpy/matrixlib/tests/test_defmatrix.py | 8 +------- numpy/matrixlib/tests/test_interaction.py | 8 +------- numpy/matrixlib/tests/test_masked_matrix.py | 9 +-------- numpy/matrixlib/tests/test_matrix_linalg.py | 8 +------- numpy/matrixlib/tests/test_multiarray.py | 8 +------- numpy/matrixlib/tests/test_numeric.py | 8 +------- numpy/matrixlib/tests/test_regression.py | 8 +------- 7 files changed, 7 insertions(+), 50 deletions(-) (limited to 'numpy/matrixlib/tests') diff --git a/numpy/matrixlib/tests/test_defmatrix.py b/numpy/matrixlib/tests/test_defmatrix.py index 272cd8d52..4cff5ee9b 100644 --- a/numpy/matrixlib/tests/test_defmatrix.py +++ b/numpy/matrixlib/tests/test_defmatrix.py @@ -1,12 +1,6 @@ from __future__ import division, absolute_import, print_function -# As we are testing matrices, we ignore its PendingDeprecationWarnings -try: - import pytest - pytestmark = pytest.mark.filterwarnings( - 'ignore:the matrix subclass is not:PendingDeprecationWarning') -except ImportError: - pass +import pytest try: # Accessing collections abstract classes from collections diff --git a/numpy/matrixlib/tests/test_interaction.py b/numpy/matrixlib/tests/test_interaction.py index fb4d8f98c..088ae3c6a 100644 --- a/numpy/matrixlib/tests/test_interaction.py +++ b/numpy/matrixlib/tests/test_interaction.py @@ -4,13 +4,7 @@ Note that tests with MaskedArray and linalg are done in separate files. """ from __future__ import division, absolute_import, print_function -# As we are testing matrices, we ignore its PendingDeprecationWarnings -try: - import pytest - pytestmark = pytest.mark.filterwarnings( - 'ignore:the matrix subclass is not:PendingDeprecationWarning') -except ImportError: - pass +import pytest import textwrap import warnings diff --git a/numpy/matrixlib/tests/test_masked_matrix.py b/numpy/matrixlib/tests/test_masked_matrix.py index adc2e5419..5ed8044aa 100644 --- a/numpy/matrixlib/tests/test_masked_matrix.py +++ b/numpy/matrixlib/tests/test_masked_matrix.py @@ -1,14 +1,7 @@ from __future__ import division, absolute_import, print_function -# As we are testing matrices, we ignore its PendingDeprecationWarnings -try: - import pytest - pytestmark = pytest.mark.filterwarnings( - 'ignore:the matrix subclass is not:PendingDeprecationWarning') -except ImportError: - pass - import pickle +import pytest import numpy as np from numpy.ma.testutils import (assert_, assert_equal, assert_raises, diff --git a/numpy/matrixlib/tests/test_matrix_linalg.py b/numpy/matrixlib/tests/test_matrix_linalg.py index 85c7693b4..8d31ec5b0 100644 --- a/numpy/matrixlib/tests/test_matrix_linalg.py +++ b/numpy/matrixlib/tests/test_matrix_linalg.py @@ -1,13 +1,7 @@ """ Test functions for linalg module using the matrix class.""" from __future__ import division, absolute_import, print_function -# As we are testing matrices, we ignore its PendingDeprecationWarnings -try: - import pytest - pytestmark = pytest.mark.filterwarnings( - 'ignore:the matrix subclass is not:PendingDeprecationWarning') -except ImportError: - pass +import pytest import numpy as np diff --git a/numpy/matrixlib/tests/test_multiarray.py b/numpy/matrixlib/tests/test_multiarray.py index 2f04b49d6..8de0a7c6a 100644 --- a/numpy/matrixlib/tests/test_multiarray.py +++ b/numpy/matrixlib/tests/test_multiarray.py @@ -1,12 +1,6 @@ from __future__ import division, absolute_import, print_function -# As we are testing matrices, we ignore its PendingDeprecationWarnings -try: - import pytest - pytestmark = pytest.mark.filterwarnings( - 'ignore:the matrix subclass is not:PendingDeprecationWarning') -except ImportError: - pass +import pytest import numpy as np from numpy.testing import assert_, assert_equal, assert_array_equal diff --git a/numpy/matrixlib/tests/test_numeric.py b/numpy/matrixlib/tests/test_numeric.py index cfdada126..e9f44e747 100644 --- a/numpy/matrixlib/tests/test_numeric.py +++ b/numpy/matrixlib/tests/test_numeric.py @@ -1,12 +1,6 @@ from __future__ import division, absolute_import, print_function -# As we are testing matrices, we ignore its PendingDeprecationWarnings -try: - import pytest - pytestmark = pytest.mark.filterwarnings( - 'ignore:the matrix subclass is not:PendingDeprecationWarning') -except ImportError: - pass +import pytest import numpy as np from numpy.testing import assert_equal diff --git a/numpy/matrixlib/tests/test_regression.py b/numpy/matrixlib/tests/test_regression.py index 439704ccf..88654c76a 100644 --- a/numpy/matrixlib/tests/test_regression.py +++ b/numpy/matrixlib/tests/test_regression.py @@ -1,12 +1,6 @@ from __future__ import division, absolute_import, print_function -# As we are testing matrices, we ignore its PendingDeprecationWarnings -try: - import pytest - pytestmark = pytest.mark.filterwarnings( - 'ignore:the matrix subclass is not:PendingDeprecationWarning') -except ImportError: - pass +import pytest import numpy as np from numpy.testing import assert_, assert_equal, assert_raises -- cgit v1.2.1