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)
| 49 | @pytest.mark.skipif(IS_WASM, reason="can't start subprocess") |
| 50 | @pytest.mark.parametrize('name', ['testing']) |
| 51 | def test_import_lazy_import(name): |
| 52 | """Make sure we can actually use the modules we lazy load. |
| 53 | |
| 54 | While not exported as part of the public API, it was accessible. With the |
| 55 | use of __getattr__ and __dir__, this isn't always true It can happen that |
| 56 | an infinite recursion may happen. |
| 57 | |
| 58 | This is the only way I found that would force the failure to appear on the |
| 59 | badly implemented code. |
| 60 | |
| 61 | We also test for the presence of the lazily imported modules in dir |
| 62 | |
| 63 | """ |
| 64 | exe = (sys.executable, '-c', "import numpy; numpy." + name) |
| 65 | result = run_subprocess(exe) |
| 66 | assert not result.stdout |
| 67 | |
| 68 | # Make sure they are still in the __dir__ |
| 69 | assert name in dir(np) |
| 70 | |
| 71 | |
| 72 | def test_dir_testing(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…