Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix running contour's test_internal_cpp_api directly. #17797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2020

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jun 29, 2020

PR Summary

The matplotlib._contour module is lazily loaded, so using it directly (as done in this test) may fail if something else doesn't load it. This test would fail if it was the first contour-related test run in a process (if testing in parallel), or if just called as the only test, i.e., this commit fixes:

$ pytest -k test_internal_cpp_api lib/matplotlib/tests/test_contour.py
__________ test_internal_cpp_api[args0-TypeError-function takes exactly 6 arguments (0 given)] __________

args = (), cls = <class 'TypeError'>, message = 'function takes exactly 6 arguments (0 given)'

    @pytest.mark.parametrize("args, cls, message", [
        ((), TypeError,
         'function takes exactly 6 arguments (0 given)'),
        ((1, 2, 3, 4, 5, 6), ValueError,
         'Expected 2-dimensional array, got 0'),
        (([[0]], [[0]], [[]], None, True, 0), ValueError,
         'x, y and z must all be 2D arrays with the same dimensions'),
        (([[0]], [[0]], [[0]], None, True, 0), ValueError,
         'x, y and z must all be at least 2x2 arrays'),
        ((*[np.arange(4).reshape((2, 2))] * 3, [[0]], True, 0), ValueError,
         'If mask is set it must be a 2D array with the same dimensions as x.'),
    ])
    def test_internal_cpp_api(args, cls, message):  # Github issue 8197.
        with pytest.raises(cls, match=re.escape(message)):
>           mpl._contour.QuadContourGenerator(*args)
E           AttributeError: module 'matplotlib' has no attribute '_contour'

lib/matplotlib/tests/test_contour.py:269: AttributeError

This is a corollary to b672f68 for tri.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • [N/A] New features are documented, with examples if plot related
  • [N/A] Documentation is sphinx and numpydoc compliant
  • [N/A] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • [N/A] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

The `matplotlib._contour` module is lazily loaded, so using it directly
(as done in this test) may fail if something else doesn't load it. This
test would fail if it was the first contour-related test run in a
process (if testing in parallel), or if just called as the only test,
i.e., this commit fixes:
```
$ pytest -k test_internal_cpp_api lib/matplotlib/tests/test_contour.py
__________ test_internal_cpp_api[args0-TypeError-function takes exactly 6 arguments (0 given)] __________

args = (), cls = <class 'TypeError'>, message = 'function takes exactly 6 arguments (0 given)'

    @pytest.mark.parametrize("args, cls, message", [
        ((), TypeError,
         'function takes exactly 6 arguments (0 given)'),
        ((1, 2, 3, 4, 5, 6), ValueError,
         'Expected 2-dimensional array, got 0'),
        (([[0]], [[0]], [[]], None, True, 0), ValueError,
         'x, y and z must all be 2D arrays with the same dimensions'),
        (([[0]], [[0]], [[0]], None, True, 0), ValueError,
         'x, y and z must all be at least 2x2 arrays'),
        ((*[np.arange(4).reshape((2, 2))] * 3, [[0]], True, 0), ValueError,
         'If mask is set it must be a 2D array with the same dimensions as x.'),
    ])
    def test_internal_cpp_api(args, cls, message):  # Github issue 8197.
        with pytest.raises(cls, match=re.escape(message)):
>           mpl._contour.QuadContourGenerator(*args)
E           AttributeError: module 'matplotlib' has no attribute '_contour'

lib/matplotlib/tests/test_contour.py:269: AttributeError

This is a corollary to b672f68 for tri.
@QuLogic QuLogic added this to the v3.3.0 milestone Jun 29, 2020
@tacaswell tacaswell merged commit 87c28e3 into matplotlib:master Jul 1, 2020
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jul 1, 2020
@QuLogic QuLogic deleted the internal-test branch July 1, 2020 04:47
timhoffm added a commit that referenced this pull request Jul 1, 2020
…797-on-v3.3.x

Backport PR #17797 on branch v3.3.x (Fix running contour's test_internal_cpp_api directly.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants