def test(): """ Verify we an suppress all channel output """ # get the channel from journal.ext.journal import Warning as warning # suppress all output warning.quiet() # make a warning channel channel = warning(name="tests.journal.warning") # add some metadata channel.notes["time"] = "now" # inject channel.line("warning channel:") channel.log(" hello world!") # all done return
def test(): """ Send all warnings to a log file """ # get the channel from journal.ext.journal import Warning as warning # send output to a log file warning.logfile("warning_file.log") # make a warning channel channel = warning(name="tests.journal.warning") # add some metadata channel.notes["time"] = "now" # inject channel.line("warning channel:") channel.log(" hello world!") # all done return
def test(): """ Verify that channels lower in the hierarchy inherit the default state of their parent """ # get the channel from journal.ext.journal import Warning # and the trash can from journal.ext.journal import Trash # make a channel parent = Warning(name="test.index.parent") # verify that the state is on assert parent.active is True # it's non-fatal assert parent.fatal is False # and the device is at the default value assert parent.device is Warning.chronicler.device # activate it parent.active = True # make it fatal parent.fatal = True # and set the device to a trash can parent.device = Trash() # lookup a name that is lower in the hierarchy child = Warning(name="test.index.parent.blah.blah.child") # that its state is the same as the parent assert child.active == parent.active assert child.fatal == parent.fatal # and that it inherited the device correctly assert child.device is parent.device # all done return