(top_level)
| 1163 | |
| 1164 | |
| 1165 | def find_top_level(top_level): |
| 1166 | # Try to be a bit smarter than unittest about finding the default top-level |
| 1167 | # for a given directory path, to avoid breaking relative imports. |
| 1168 | # (Unittest's default is to set top-level equal to the path, which means |
| 1169 | # relative imports will result in "Attempted relative import in |
| 1170 | # non-package."). |
| 1171 | |
| 1172 | # We'd be happy to skip this and require dotted module paths (which don't |
| 1173 | # cause this problem) instead of file paths (which do), but in the case of |
| 1174 | # a directory in the cwd, which would be equally valid if considered as a |
| 1175 | # top-level module or as a directory path, unittest unfortunately prefers |
| 1176 | # the latter. |
| 1177 | while True: |
| 1178 | init_py = os.path.join(top_level, "__init__.py") |
| 1179 | if not os.path.exists(init_py): |
| 1180 | break |
| 1181 | try_next = os.path.dirname(top_level) |
| 1182 | if try_next == top_level: |
| 1183 | # __init__.py all the way down? give up. |
| 1184 | break |
| 1185 | top_level = try_next |
| 1186 | return top_level |
| 1187 | |
| 1188 | |
| 1189 | def _class_shuffle_key(cls): |
no test coverage detected
searching dependent graphs…