Skip to content

Commit

Permalink
test version printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Lostanlen committed Nov 29, 2018
1 parent 437b0f9 commit 2007576
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 1 addition & 2 deletions birdvoxdetect/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ def main():
"""
args = parse_args(sys.argv[1:])

if args.inputs[0] == "-V":
if args.inputs[0] == "-V" or args.inputs[0] == "--version":
print(birdvoxdetect.version.version)
return


run(args.inputs,
Expand Down
16 changes: 13 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@


from birdvoxdetect.birdvoxdetect_exceptions import BirdVoxDetectError
from birdvoxdetect.cli import positive_float, get_file_list, run
from birdvoxdetect.cli import parse_args
from birdvoxdetect.cli import get_file_list, main
from birdvoxdetect.cli import parse_args, positive_float, run


TEST_DIR = os.path.dirname(__file__)
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_run(capsys):
pytest.raises(BirdVoxDetectError, get_file_list, ['/fake/path/to/file'])


def test_script_main():
def test_script_main(capsys):
# Duplicate regression test from test_run just to hit coverage
tempdir = tempfile.mkdtemp()
with patch(
Expand All @@ -162,3 +162,13 @@ def test_script_main():
outfile = os.path.join(
tempdir, 'BirdVox-scaper_example_foreground_timestamps.csv')
assert os.path.isfile(outfile)

# Print version
with patch(
'sys.argv',
['birdvoxdetect', '--V']):
import birdvoxdetect.__main__

# Check version printed
out, err = capsys.readouterr()
assert len(out) > 0

0 comments on commit 2007576

Please sign in to comment.