Check if 'import unittest' is already present in the file.
(tree: ast.Module)
| 319 | |
| 320 | |
| 321 | def _has_unittest_import(tree: ast.Module) -> bool: |
| 322 | """Check if 'import unittest' is already present in the file.""" |
| 323 | for node in tree.body: |
| 324 | if isinstance(node, ast.Import): |
| 325 | for alias in node.names: |
| 326 | if alias.name == UT and alias.asname is None: |
| 327 | return True |
| 328 | return False |
| 329 | |
| 330 | |
| 331 | def _find_import_insert_line(tree: ast.Module) -> int: |
no test coverage detected