Make sure we can actually use the modules we lazy load. While not exported as part of the public API, it was accessible. With the use of __getattr__ and __dir__, this isn't always true It can happen that an infinite recursion may happen. This is the only way I found that would for
(name)
| 65 | @pytest.mark.skipif(IS_WASM, reason="can't start subprocess") |
| 66 | @pytest.mark.parametrize('name', ['testing']) |
| 67 | def test_import_lazy_import(name): |
| 68 | """Make sure we can actually use the modules we lazy load. |
| 69 | |
| 70 | While not exported as part of the public API, it was accessible. With the |
| 71 | use of __getattr__ and __dir__, this isn't always true It can happen that |
| 72 | an infinite recursion may happen. |
| 73 | |
| 74 | This is the only way I found that would force the failure to appear on the |
| 75 | badly implemented code. |
| 76 | |
| 77 | We also test for the presence of the lazily imported modules in dir |
| 78 | |
| 79 | """ |
| 80 | exe = (sys.executable, '-c', "import numpy; numpy." + name) |
| 81 | result = subprocess.check_output(exe) |
| 82 | assert not result |
| 83 | |
| 84 | # Make sure they are still in the __dir__ |
| 85 | assert name in dir(np) |
| 86 | |
| 87 | |
| 88 | def test_dir_testing(): |
nothing calls this directly
no test coverage detected