Skip to content

Commit

Permalink
Revert "add q and debug flags."
Browse files Browse the repository at this point in the history
This reverts commit 48829a9.
Even if it passes locally, always use a feature branch -_-
  • Loading branch information
ConorSheehan1 committed Jan 4, 2021
1 parent 48829a9 commit 40366e6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 94 deletions.
33 changes: 12 additions & 21 deletions shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,23 @@ def shot(
s: int = 1,
n: int = 1,
color: bool = True,
q: bool = False,
dry_run: bool = False,
debug: bool = False,
encoding: str = "utf-8",
version: bool = False,
):
) -> str:
"""
Screenshot Helper for OSX Terminal
Args:
src: source directory. If None provided, find using apple defaults. Default: None
dst: destination directory. Default: .
mv: move the file instead of copying it. Default: False
s: start at sth latest file, 1-indexed. Default: 1
n: number of files to copy/move: Default: 1
color: toggle color output. Default: True
q: quiet mode, print less things to the console. Default: False
dry_run: if True show an equivalent command that would be run. Default: False
debug: raise error with full stack trace. otherwise print warning. Default: False
encoding: encoding to use for shell. Default: utf-8
version: if True show version, else run shot. Default: False
src: source directory. If None provided, find using apple defaults. Default: None
dst: destination directory. Default: .
mv: move the file instead of copying it. Default: False
s: start at sth latest file, 1-indexed. Default: 1
n: number of files to copy/move: Default: 1
color: toggle color output. Default: True
dry_run: if True show an equivalent command that would be run. Default: False
encoding: encoding to use for shell. Default: utf-8
version: if True show version, else run shot. Default: False
"""
if version:
return __version__
Expand Down Expand Up @@ -117,14 +113,9 @@ def shot(
elif cmd == "mv":
shutil.move(screenshot_to_copy, dst)
# no need for else, should be handled above by `if cmd not in accepted_cmds:`
if not q:
return success_msg
return success_msg
except Exception as e:
print(err_msg)
if debug:
raise e
else:
raise SystemExit(1)
return err_msg


def main():
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/src/foo.txt

This file was deleted.

51 changes: 0 additions & 51 deletions tests/integration/test_shot_integation.py

This file was deleted.

21 changes: 0 additions & 21 deletions tests/unit/test_shot.py → tests/test_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@


class TestShot(unittest.TestCase):
"""
Unit tests that don't hit file system at all. Calls are stubbed.
"""

def setUp(self):
self.isdir_patcher = patch("os.path.isdir")
self.mock_isdir = self.isdir_patcher.start()
Expand Down Expand Up @@ -50,23 +46,6 @@ def test_default_args(self, check_output_mock, copy_mock, glob_mock):
check_output_mock.assert_has_calls(check_output_calls)
copy_mock.assert_has_calls(copy_mock_calls)

@patch("glob.glob")
@patch("shutil.copy")
@patch("subprocess.check_output")
def test_quiet(self, check_output_mock, copy_mock, glob_mock):
"""
should copy the latest screenshot to the current directory, without printing any messages
"""
check_output_mock.side_effect = [b"/tmp/tests\n"]
glob_mock.side_effect = [["/tmp/tests/first"]]

check_output_calls = [call(["defaults", "read", "com.apple.screencapture", "location"])]
copy_mock_calls = [call("/tmp/tests/first", ".")]

assert shot(q=True) == None
check_output_mock.assert_has_calls(check_output_calls)
copy_mock.assert_has_calls(copy_mock_calls)

@patch("glob.glob")
@patch("subprocess.check_output")
def test_dry_run(self, check_output_mock, glob_mock):
Expand Down

0 comments on commit 40366e6

Please sign in to comment.