mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user