Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_file_contents():
(
in_lines,
out_lines,
import_index,
place_imports,
import_placements,
as_map,
imports,
categorized_comments,
change_count,
original_line_count,
line_separator,
sections,
section_comments,
) = parse.file_contents(TEST_CONTENTS, config=Config())
assert "\n".join(in_lines) == TEST_CONTENTS
assert "import" not in "\n".join(out_lines)
assert import_index == 1
assert change_count == -2
assert original_line_count == len(in_lines)
import_section += line
if not contains_imports:
output_stream.write(import_section)
else:
if first_import_section and not import_section.lstrip(
line_separator
).startswith(COMMENT_INDICATORS):
import_section = import_section.lstrip(line_separator)
first_import_section = False
if indent:
import_section = line_separator.join(
line.lstrip() for line in import_section.split(line_separator)
)
sorted_import_section = output.sorted_imports(
parse.file_contents(import_section, config=config), config, extension
)
if indent:
sorted_import_section = (
textwrap.indent(sorted_import_section, indent) + line_separator
)
output_stream.write(sorted_import_section)
if indent:
output_stream.write(line)
indent = ""
contains_imports = False
import_section = ""
else:
output_stream.write(line)