Skip to content

remove nose-style test classes #24148

Closed

Description

@tacaswell

With the development version of pytest

✘ 17:37:16 $ pip list | grep pytest
pytest                         7.2.0.dev320+g196f01965
pytest-benchmark               3.4.1
pytest-cov                     4.0.0
pytest-forked                  1.4.0
pytest-instafail               0.4.2
pytest-rerunfailures           10.2
pytest-timeout                 2.1.0
pytest-tornasync               0.6.0.post2
pytest-xdist                   2.5.0
pytest-xvfb                    2.0.0

I'm seeing the following errors locally

ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_form_main_list - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_form_each_dict - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_form_dict_keys - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_results_baseline - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_results_bootstrapped - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_results_whiskers_float - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_results_whiskers_range - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_results_whiskers_percentiles - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_results_withlabels - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_label_error - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_bad_dims - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_boxplot_stats::test_boxplot_stats_autorange_false - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_callback_registry::test_callback_complete[True] - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_callback_registry::test_callback_complete[False] - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_callback_registry::test_callback_disconnect[True] - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_callback_registry::test_callback_disconnect[False] - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_callback_registry::test_callback_wrong_disconnect[True] - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_callback_registry::test_callback_wrong_disconnect[False] - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_callback_registry::test_registration_on_non_empty_registry[True] - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_callback_registry::test_registration_on_non_empty_registry[False] - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_cbook.py::Test_callback_registry::test_pickling - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_mlab.py::TestDetrend::test_detrend_none - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_mlab.py::TestDetrend::test_detrend_mean - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_mlab.py::TestDetrend::test_detrend_mean_1d_base_slope_off_list_andor_axis0 - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_mlab.py::TestDetrend::test_detrend_mean_2d - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_mlab.py::TestDetrend::test_detrend_ValueError - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_mlab.py::TestDetrend::test_detrend_mean_ValueError - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_mlab.py::TestDetrend::test_detrend_linear - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_mlab.py::TestDetrend::test_detrend_str_linear_1d - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
ERROR lib/matplotlib/tests/test_mlab.py::TestDetrend::test_detrend_linear_2d - pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.

We are still using nose-stil test classes that we apparently need to migrate away from.

I'm labeling this "good first issue" because you do not need to understand anything about Matplotlib to do this work, but medium difficulty because it involves changing the tests which is a high-risk activity (as you do not have tests on your tests) so this is not a good issue for someone new to Python or testing frameworks.

Activity

  1. added
    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Oct 12, 2022
  2. added this to the v3.7.0 milestone on Oct 12, 2022
  3. elrorvik commented on Oct 13, 2022

    @elrorvik

    Hi! I'm trying to find the nose-settings in the pytest-config, but I could not find anything about nose-library except in the docs...
    image
    Could you point me in the direction of the nose-configs? (From what I could find it was supposed to be in this contest: https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/testing/conftest.py)

  4. tacaswell commented on Oct 13, 2022

    @tacaswell
    MemberAuthor

    I think the issue is that we are implicitly using nose-style classes that pytest has in the past happily discovered and ran them, but on the current development branch of pytest is starting to warn that this will be removed in the future.

    We have our tests set to fail on warning so this is causing test failures for us now (or well as soon as the next version of pytest is released). Hopefully we can get this addressed before then (by fixing it on main and pinning on the bug-fix branch) so we never see these failures on our CI and do not have to deal with this when it becomes a crisis.

  5. oscargus commented on Oct 14, 2022

    @oscargus
    Member

    I think that only test classes with a setup method count as a Nose test?

    For e.g. the Test_boxplot_stats class

    class Test_boxplot_stats:
    def setup(self):
    np.random.seed(937)
    self.nrows = 37
    self.ncols = 4
    self.data = np.random.lognormal(size=(self.nrows, self.ncols),
    mean=1.5, sigma=1.75)
    self.known_keys = sorted([
    'mean', 'med', 'q1', 'q3', 'iqr',
    'cilo', 'cihi', 'whislo', 'whishi',
    'fliers', 'label'
    ])
    self.std_results = cbook.boxplot_stats(self.data)
    self.known_nonbootstrapped_res = {
    'cihi': 6.8161283264444847,
    'cilo': -0.1489815330368689,
    'iqr': 13.492709959447094,
    'mean': 13.00447442387868,
    'med': 3.3335733967038079,
    'fliers': np.array([
    92.55467075, 87.03819018, 42.23204914, 39.29390996
    ]),
    'q1': 1.3597529879465153,
    'q3': 14.85246294739361,
    'whishi': 27.899688243699629,
    'whislo': 0.042143774965502923
    }
    self.known_bootstrapped_ci = {
    'cihi': 8.939577523357828,
    'cilo': 1.8692703958676578,
    }
    self.known_whis3_res = {
    'whishi': 42.232049135969874,
    'whislo': 0.042143774965502923,
    'fliers': np.array([92.55467075, 87.03819018]),
    }
    self.known_res_percentiles = {
    'whislo': 0.1933685896907924,
    'whishi': 42.232049135969874
    }
    self.known_res_range = {
    'whislo': 0.042143774965502923,
    'whishi': 92.554670752188699
    }
    def test_form_main_list(self):
    assert isinstance(self.std_results, list)
    def test_form_each_dict(self):
    for res in self.std_results:
    assert isinstance(res, dict)
    def test_form_dict_keys(self):
    for res in self.std_results:
    assert set(res) <= set(self.known_keys)
    def test_results_baseline(self):
    res = self.std_results[0]
    for key, value in self.known_nonbootstrapped_res.items():
    assert_array_almost_equal(res[key], value)
    def test_results_bootstrapped(self):
    results = cbook.boxplot_stats(self.data, bootstrap=10000)
    res = results[0]
    for key, value in self.known_bootstrapped_ci.items():
    assert_approx_equal(res[key], value)
    def test_results_whiskers_float(self):
    results = cbook.boxplot_stats(self.data, whis=3)
    res = results[0]
    for key, value in self.known_whis3_res.items():
    assert_array_almost_equal(res[key], value)
    def test_results_whiskers_range(self):
    results = cbook.boxplot_stats(self.data, whis=[0, 100])
    res = results[0]
    for key, value in self.known_res_range.items():
    assert_array_almost_equal(res[key], value)
    def test_results_whiskers_percentiles(self):
    results = cbook.boxplot_stats(self.data, whis=[5, 95])
    res = results[0]
    for key, value in self.known_res_percentiles.items():
    assert_array_almost_equal(res[key], value)
    def test_results_withlabels(self):
    labels = ['Test1', 2, 'Aardvark', 4]
    results = cbook.boxplot_stats(self.data, labels=labels)
    for lab, res in zip(labels, results):
    assert res['label'] == lab
    results = cbook.boxplot_stats(self.data)
    for res in results:
    assert 'label' not in res
    def test_label_error(self):
    labels = [1, 2]
    with pytest.raises(ValueError):
    cbook.boxplot_stats(self.data, labels=labels)
    def test_bad_dims(self):
    data = np.random.normal(size=(34, 34, 34))
    with pytest.raises(ValueError):
    cbook.boxplot_stats(data)
    def test_boxplot_stats_autorange_false(self):
    x = np.zeros(shape=140)
    x = np.hstack([-25, x, 25])
    bstats_false = cbook.boxplot_stats(x, autorange=False)
    bstats_true = cbook.boxplot_stats(x, autorange=True)
    assert bstats_false[0]['whislo'] == 0
    assert bstats_false[0]['whishi'] == 0
    assert_array_almost_equal(bstats_false[0]['fliers'], [-25, 25])
    assert bstats_true[0]['whislo'] == -25
    assert bstats_true[0]['whishi'] == 25
    assert_array_almost_equal(bstats_true[0]['fliers'], [])

    one can either just create the data in every method (now a function) or, the more advanced way, create a pytest fixture with the data.

    For Test_callback_registry it seems to make sense to create a fixture.

    For TestDetrend either create data or fixture. (Some of the tests seems viable for parameterization as well).

    I guess the thing to closely look for is coverage changes. If there are any, something went wrong. If the coverage it still the same, there is a chance it is correct.

  6. rcomer commented on Oct 14, 2022

    @rcomer
    Member
  7. modified the milestones: v3.7.0, v3.6.2 on Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues🌱 Good first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions