def test(): """ Verify that channels lower in the hierarchy inherit the default state of their parent """ # get the channel from journal.Warning import Warning # and the trash can from journal.Trash import Trash # make a channel parent = Warning(name="test.index.parent") # verify that the state is on assert parent.active is True # that it is 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 # 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 it's 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
def test(): """ Suppress all warnings """ # get the channel from journal.Warning import Warning as warning # suppress the 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 channel output to a log file """ # get the channel from journal.Warning import Warning as warning # send the 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