MCPcopy Index your code
hub / github.com/RustPython/RustPython / _has_unittest_import

Function _has_unittest_import

scripts/update_lib/patch_spec.py:321–328  ·  view source on GitHub ↗

Check if 'import unittest' is already present in the file.

(tree: ast.Module)

Source from the content-addressed store, hash-verified

319
320
321def _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
331def _find_import_insert_line(tree: ast.Module) -> int:

Callers 1

apply_patchesFunction · 0.85

Calls 1

isinstanceFunction · 0.85

Tested by

no test coverage detected