From fc54667f3476942624c0d22877edf7bf6bacd4d5 Mon Sep 17 00:00:00 2001 From: Andrew Scheller Date: Sun, 18 Dec 2016 03:33:50 +0000 Subject: [PATCH] More small tidyups - switch to using sys.exit instead of exit - always exit with error-code 1 - don't bother testing error-codes - documentation wording tweak --- docs/cli_tools.rst | 2 +- gpiozero/cli/pinout.py | 4 ++-- tests/cli/test_pinout.py | 5 ----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/docs/cli_tools.rst b/docs/cli_tools.rst index 1d6c5e2..1b1443d 100644 --- a/docs/cli_tools.rst +++ b/docs/cli_tools.rst @@ -7,7 +7,7 @@ Pinout The gpiozero package contains a database of information about the various revisions of Raspberry Pi. This is queried by the ``pinout`` command-line -tool to write details of the GPIO pins available. +tool to output details of the GPIO pins available. Unless specified, the revision of the current device will be detected. A particular revision may be selected with the --revision command-line diff --git a/gpiozero/cli/pinout.py b/gpiozero/cli/pinout.py index d28cc1c..70b84c8 100755 --- a/gpiozero/cli/pinout.py +++ b/gpiozero/cli/pinout.py @@ -45,7 +45,7 @@ def parse_args(args): except argparse.ArgumentError as ex: print('Error parsing arguments.') parser.error(str(ex.message)) - exit(-1) + sys.exit(1) return args @@ -57,7 +57,7 @@ def main(): pi_info().pprint(color=args.color) except IOError: print('This device is not a Raspberry Pi') - exit(2) + sys.exit(1) else: pi_info(args.revision).pprint(color=args.color) diff --git a/tests/cli/test_pinout.py b/tests/cli/test_pinout.py index afc52f6..7e47b1e 100644 --- a/tests/cli/test_pinout.py +++ b/tests/cli/test_pinout.py @@ -15,8 +15,6 @@ from gpiozero.cli import pinout def test_args_incorrect(): with pytest.raises(SystemExit) as ex: pinout.parse_args(['--nonexistentarg']) - assert ex.value.code == 2 - def test_args_color(): args = pinout.parse_args([]) @@ -26,15 +24,12 @@ def test_args_color(): args = pinout.parse_args(['--monochrome']) assert args.color is False - def test_args_revision(): args = pinout.parse_args(['--revision', '000d']) assert args.revision == '000d' - def test_help(capsys): with pytest.raises(SystemExit) as ex: pinout.parse_args(['--help']) out, err = capsys.readouterr() assert 'GPIO pinout' in out - assert ex.value.code == 0