示例#1
0
def test():
    """
    Verify access to the channel properties
    """
    # access
    from journal import libjournal

    # make a channel
    channel = libjournal.Help("test.channel")

    # verify its name
    assert channel.name == "test.channel"
    # check that it is read-only
    try:
        # by attempting to modify
        channel.name = "foo"
        # hence, we can't get here
        assert False, "unreachable"
    # if all goes well
    except AttributeError as error:
        # no problem
        pass

    # verify its detail is at 1 by default
    assert channel.detail == 1
    # that it can be modified
    channel.detail = 5
    # and the assignment sticks
    assert channel.detail == 5

    # verify its activation state is off by default
    assert channel.active is True
    # that it can be modified
    channel.active = False
    # and the assignment sticks
    assert channel.active is False

    # verify it's not fatal
    assert channel.fatal is False
    # that it can be modified
    channel.fatal = True
    # and the assignment sticks
    assert channel.fatal is True

    # verify that the accessible device is the console
    assert channel.device.name == "cout"
    # make a trash can
    trash = libjournal.Trash()
    # register it as the device
    channel.device = trash
    # and verify that the assignment sticks
    assert channel.device is trash
    # check the name
    assert channel.device.name == "trash"
    # and verify that it's different from the default device held by the class
    assert channel.device is not channel.defaultDevice

    # all done
    return
示例#2
0
文件: trash.py 项目: jlmaurer/pyre
def test():
    """
    Verify that the trash can is accessible
    """
    # access
    from journal import libjournal

    # make a trash can
    trash = libjournal.Trash()
    # verify its name is what we expect
    assert trash.name == "trash"

    # all done
    return
示例#3
0
def test():
    """
    Verify that the debug channel wide defaults are as expected
    """
    # access
    from journal import libjournal

    # verify that debug channels are inactive by default
    assert libjournal.Debug.defaultActive is False
    # and non-fatal
    assert libjournal.Debug.defaultFatal is False
    # verify that the channel default device is not set
    assert libjournal.Debug.defaultDevice == None

    # make a trash can
    trash = libjournal.Trash()
    # make it the default device
    libjournal.Debug.defaultDevice = trash
    # and make sure the assignment sticks
    assert libjournal.Debug.defaultDevice is trash

    # make a debug channel
    channel = libjournal.Debug("test.channel")
    # verify that its view of its default state is consistent
    assert channel.defaultActive == libjournal.Debug.defaultActive
    assert channel.defaultFatal == libjournal.Debug.defaultFatal
    # similarly for the default device
    assert channel.defaultDevice == libjournal.Debug.defaultDevice

    # and now, the instance state
    assert channel.active == channel.defaultActive
    assert channel.fatal == channel.defaultFatal
    assert channel.device == channel.defaultDevice

    # all done
    return
示例#4
0
def test():
    """
    Verify that the device base class constructor is unavailable
    """
    # access
    from journal import libjournal

    # get the global state
    chronicler = libjournal.Chronicler

    # verify that the default device is the console
    assert chronicler.device.name == "cout"

    # make a trash can
    trash = libjournal.Trash()
    # set it as the device
    chronicler.device = trash
    # verify the assignment sticks
    assert chronicler.device is trash
    # and that the name is correct
    assert chronicler.device.name == "trash"

    # all done
    return