from pytest import raises
from merfi import util


class TestGetPath(object):

    def test_no_last_argument(self):
        args = ['gpg', '--output', 'signed']
        with raises(RuntimeError) as error:
            util.infer_path(args)
        assert 'is not a valid path' in str(error.value)

    def test_last_argument(self):
        args = ['gpg', '--output', 'signed', '/']
        result = util.infer_path(args)
        assert result == '/'

    def test_no_arguments(self):
        # the parser engine pops the current command so we can
        # certainly end up with an empty argv list
        result = util.infer_path([])
        assert result.startswith('/')

@@ -58,11 +58,13 @@
 Test
-Get
+Infer
 Path
@@ -667,8 +667,592 @@
 th('/')%0A
+%0A%0Aclass TestDependencyCheck(object):%0A%0A    def test_silent_does_not_raise(self):%0A        result = util.check_dependency('ls', silent=True)%0A        assert result is None%0A%0A    def test_silent_does_not_output(self, capsys):%0A        util.check_dependency('ls', silent=True)%0A        out, err = capsys.readouterr()%0A        assert out == ''%0A        assert err == ''%0A%0A    def test_not_silent_prints_when_erroring(self, capsys):%0A        with raises(RuntimeError):%0A            util.check_dependency('ffffffffffffff')%0A        out, err = capsys.readouterr()%0A        assert 'could not find' in out%0A

add tests for dependency check util