def test_guess_error(pb_odd_resources):
    # File path
    with pytest.raises(br.GuessError):
        PhyloBuddy(pb_odd_resources["unrecognizable"])

    with open(pb_odd_resources["unrecognizable"], 'r') as ifile:
        # Raw
        with pytest.raises(br.GuessError):
            PhyloBuddy(ifile.read())

        # Handle
        with pytest.raises(br.GuessError):
            ifile.seek(0)
            PhyloBuddy(ifile)

    # GuessError output
    test_error = br.GuessError("This is a test")
    assert str(test_error) == "This is a test"

    try:
        PhyloBuddy(pb_odd_resources["unrecognizable"])
    except br.GuessError as e:
        assert "Could not automatically determine the format of" in str(e.value) and \
               "\nTry explicitly setting it with the -f flag." in str(e.value)
예제 #2
0
def test_guesserror():
    with pytest.raises(br.GuessError):
        error = br.GuessError("test")
        assert str(error) == "test"
        raise error
예제 #3
0
def mock_guesserror(*args, **kwargs):
    raise br.GuessError("%s, %s" % (args, kwargs))