コード例 #1
0
def test_stringification():
    """Test stringified error messages from exceptions."""
    assert "random-description" in str(McuBootError("random-description"))
    assert "random-description" in str(
        McuBootConnectionError("random-description"))
    assert "random-command" in str(McuBootCommandError("random-command", 0))
    assert "Unknown Error" in str(McuBootCommandError("random-command", -1))
コード例 #2
0
def test_stringification():
    """Test stringified error messages from exceptions."""
    assert 'random-description' in str(McuBootError('random-description'))
    assert 'random-description' in str(McuBootConnectionError('random-description'))
    assert 'random-command' in str(McuBootCommandError('random-command', 0))
    assert 'Unknown Error' in str(McuBootCommandError('random-command', -1))
コード例 #3
0
def test_expect_fail():
    """Test Fail conditions, e.i.: can't fetch parent exc using child exception."""
    assert False == raise_and_catch(SPSDKError(), McuBootError)
    assert False == raise_and_catch(McuBootError(), McuBootConnectionError)
コード例 #4
0
def test_sdp_inheritance():
    """Test whether McuBootError is base for all SDP Exceptions."""
    assert raise_and_catch(McuBootError(), McuBootError)
    assert raise_and_catch(McuBootCommandError("cmd", 0), McuBootError)
    assert raise_and_catch(McuBootConnectionError("description"), McuBootError)
コード例 #5
0
def test_base_inheritance():
    """Test whether BootSdkError is base for all exceptions."""
    assert raise_and_catch(McuBootError(), SPSDKError)
    assert raise_and_catch(McuBootCommandError("cmd", 0), SPSDKError)
    assert raise_and_catch(McuBootConnectionError("description"), SPSDKError)