diff --git a/lib/matplotlib/spines.py b/lib/matplotlib/spines.py index b07514d324d8..7e7a423c787b 100644 --- a/lib/matplotlib/spines.py +++ b/lib/matplotlib/spines.py @@ -550,7 +550,7 @@ def __getattr__(self, name): try: return self._dict[name] except KeyError: - raise ValueError( + raise AttributeError( f"'Spines' object does not contain a '{name}' spine") def __getitem__(self, key): diff --git a/lib/matplotlib/tests/test_spines.py b/lib/matplotlib/tests/test_spines.py index 589badc310d9..b8891aec411e 100644 --- a/lib/matplotlib/tests/test_spines.py +++ b/lib/matplotlib/tests/test_spines.py @@ -35,6 +35,8 @@ def set_val(self, val): spines[:].set_val('y') assert all(spine.val == 'y' for spine in spines.values()) + with pytest.raises(AttributeError, match='foo'): + spines.foo with pytest.raises(KeyError, match='foo'): spines['foo'] with pytest.raises(KeyError, match='foo, bar'): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy