(self)
| 98 | yield path, modpath + modname |
| 99 | |
| 100 | def test_all(self): |
| 101 | # List of denied modules and packages |
| 102 | denylist = set([ |
| 103 | # Will raise a SyntaxError when compiling the exec statement |
| 104 | '__future__', |
| 105 | ]) |
| 106 | |
| 107 | # In case _socket fails to build, make this test fail more gracefully |
| 108 | # than an AttributeError somewhere deep in concurrent.futures, email |
| 109 | # or unittest. |
| 110 | import _socket # noqa: F401 |
| 111 | |
| 112 | ignored = [] |
| 113 | failed_imports = [] |
| 114 | lib_dir = os.path.dirname(os.path.dirname(__file__)) |
| 115 | for path, modname in self.walk_modules(lib_dir, ""): |
| 116 | m = modname |
| 117 | denied = False |
| 118 | while m: |
| 119 | if m in denylist: |
| 120 | denied = True |
| 121 | break |
| 122 | m = m.rpartition('.')[0] |
| 123 | if denied: |
| 124 | continue |
| 125 | if support.verbose: |
| 126 | print(f"Check {modname}", flush=True) |
| 127 | try: |
| 128 | # This heuristic speeds up the process by removing, de facto, |
| 129 | # most test modules (and avoiding the auto-executing ones). |
| 130 | with open(path, "rb") as f: |
| 131 | if b"__all__" not in f.read(): |
| 132 | raise NoAll(modname) |
| 133 | self.check_all(modname) |
| 134 | except NoAll: |
| 135 | ignored.append(modname) |
| 136 | except FailedImport: |
| 137 | failed_imports.append(modname) |
| 138 | |
| 139 | if support.verbose: |
| 140 | print('Following modules have no __all__ and have been ignored:', |
| 141 | ignored) |
| 142 | print('Following modules failed to be imported:', failed_imports) |
| 143 | |
| 144 | |
| 145 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected