Skip to content

Commit

Permalink
fixed formatting for flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
a-dubs committed Jul 27, 2023
1 parent e859a45 commit a865e0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
6 changes: 3 additions & 3 deletions cloudinit/cmd/devel/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def _write_command_output_to_file(cmd, filename, msg, verbosity):
# f.write(output)
write_file(filename, output)
except ProcessExecutionError as e:
write_file(filename, output := str(e))
write_file(filename, str(e))
_debug("collecting %s failed.\n" % msg, 1, verbosity)
return output
return str(e)
else:
_debug("collected %s\n" % msg, 1, verbosity)
return output
Expand All @@ -167,7 +167,7 @@ def _stream_command_output_to_file(cmd, filename, msg, verbosity):
with open(filename, "w") as f:
subprocess.call(cmd, stdout=f, stderr=f)
except ProcessExecutionError as e:
# write_file(filename, str(e))
write_file(filename, str(e))
_debug("collecting %s failed.\n" % msg, 1, verbosity)
else:
_debug("collected %s\n" % msg, 1, verbosity)
Expand Down
33 changes: 2 additions & 31 deletions tests/unittests/cmd/devel/test_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def fake_subprocess_call(cmd, stdout=None, stderr=None):
cmd_tuple = tuple(cmd)
if cmd_tuple not in expected_subp:
raise AssertionError(
"Unexpected command provided to fake subprocess.call(): {0}".format(
"Unexpected command provided to subprocess: {0}".format(
cmd
)
)
Expand Down Expand Up @@ -216,7 +216,7 @@ def test_write_command_output_to_file(self, m_getuid, tmpdir):
m_getuid.return_value = 100
output_file1 = tmpdir.join("test-output-file-1.txt")
output_file2 = tmpdir.join("test-output-file-2.txt")
output_file3 = tmpdir.join("test-output-file-3.txt")
# output_file3 = tmpdir.join("test-output-file-3.txt")
return_output1 = logs._write_command_output_to_file(
filename=output_file1,
cmd=["echo", test_str_1],
Expand Down Expand Up @@ -252,35 +252,6 @@ def test_write_command_output_to_file(self, m_getuid, tmpdir):
# assert expected_err_msg == return_output3
# assert expected_err_msg == load_file(output_file3)

# def test_write_command_output_to_file_with_return_output(self, m_getuid, tmpdir):
# # what does this do???
# m_getuid.return_value = 100
# output_file = tmpdir.join("test-output-file.txt")
# return_output = logs._write_command_output_to_file(
# filename=output_file,
# cmd=["echo", "test"],
# msg="",
# verbosity=0,
# return_output=True,
# )

# assert "test\n" == return_output
# assert "test\n" == load_file(output_file)

# def test_write_command_output_to_file_without_return_output(self, m_getuid, tmpdir):
# # what does this do???
# m_getuid.return_value = 100
# output_file = tmpdir.join("test-output-file.txt")
# return_output = logs._write_command_output_to_file(
# filename=output_file,
# cmd=["echo", "test"],
# msg="",
# verbosity=0,
# return_output=False,
# )
# assert "test\n" == load_file(output_file)
# assert None == return_output


class TestCollectInstallerLogs:
@pytest.mark.parametrize(
Expand Down

0 comments on commit a865e0f

Please sign in to comment.