Download omnilmm/lib/python3.10/site-packages/matplotlib/tests/test_getattr.py from ZTWHHH/envs_2: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/ZTWHHH/envs_2/resolve/main/omnilmm/lib/python3.10/site-packages/matplotlib/tests/test_getattr.py
- Command line
-
hf download hf://datasets/ZTWHHH/envs_2/omnilmm/lib/python3.10/site-packages/matplotlib/tests/test_getattr.py
-
curl -L -o test_getattr.py https://huggingface.co/datasets/ZTWHHH/envs_2/resolve/main/omnilmm/lib/python3.10/site-packages/matplotlib/tests/test_getattr.py
1.03 kB
| from importlib import import_module | |
| from pkgutil import walk_packages | |
| import matplotlib | |
| import pytest | |
| # Get the names of all matplotlib submodules, | |
| # except for the unit tests and private modules. | |
| module_names = [ | |
| m.name | |
| for m in walk_packages( | |
| path=matplotlib.__path__, prefix=f'{matplotlib.__name__}.' | |
| ) | |
| if not m.name.startswith(__package__) | |
| and not any(x.startswith('_') for x in m.name.split('.')) | |
| ] | |
| def test_getattr(module_name): | |
| """ | |
| Test that __getattr__ methods raise AttributeError for unknown keys. | |
| See #20822, #20855. | |
| """ | |
| try: | |
| module = import_module(module_name) | |
| except (ImportError, RuntimeError) as e: | |
| # Skip modules that cannot be imported due to missing dependencies | |
| pytest.skip(f'Cannot import {module_name} due to {e}') | |
| key = 'THIS_SYMBOL_SHOULD_NOT_EXIST' | |
| if hasattr(module, key): | |
| delattr(module, key) | |