Skip to content

Commit

Permalink
output dict in warnings (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorSheehan1 authored Apr 8, 2021
1 parent cbd4c04 commit 0a48a45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ def _valid_extension(self, screenshot: str) -> bool:
if src_ext == dst_ext:
return True

extensions = {"src": src_ext, "dst": dst_ext}
self.console.print(
f"Warning: src and dst extensions don't match. src: {src_ext}, dst: {dst_ext}",
f"Warning: src and dst extensions don't match. {extensions}",
style="yellow",
)

Expand Down Expand Up @@ -131,8 +132,9 @@ def _valid_screenshots_to_copy(self):
self.console.print(f"No files found in {self.screenshot_dir_parsed}", style="red")
return False
if len(self.screenshots_to_copy) < self.num:
copy_args = {"start": self.start, "num": self.num}
self.console.print(
f"Warning: there are not enough files to copy with start:{self.start}, num:{self.num}",
f"Warning: there are not enough files to copy with {copy_args}",
style="yellow",
)
return self.yes or self._confirm()
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/test_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ def test_not_enough_files_yes(self, check_output_mock, copy_mock, glob_mock):
check_output_calls = [call(["defaults", "read", "com.apple.screencapture", "location"])]
copy_mock_calls = [call("/tmp/tests/1", ".")]
print_mock_calls = [
call("Warning: there are not enough files to copy with start:1, num:2", style="yellow"),
call(
"Warning: there are not enough files to copy with {'start': 1, 'num': 2}",
style="yellow",
),
call(
"Copied the following files from /tmp/tests to . successfully!\n['1']",
style="green",
Expand Down Expand Up @@ -191,7 +194,8 @@ def test_changing_extension_yes(self, check_output_mock, copy_mock, glob_mock):
glob_mock.side_effect = [["/tmp/tests/first.txt"]]
print_mock_calls = [
call(
"Warning: src and dst extensions don't match. src: .txt, dst: .md", style="yellow"
"Warning: src and dst extensions don't match. {'src': '.txt', 'dst': '.md'}",
style="yellow",
),
call(
"Copied the following files from /tmp/tests to ./first.md successfully!\n['first.txt']",
Expand Down

0 comments on commit 0a48a45

Please sign in to comment.