コード例 #1
0
    def test_writeln_with_default_verbosity(self):
        with mocked_ctx() as mctx:
            msg = "test message"

            writeln(msg)

            mctx.output_stream.write.assert_called_with(msg + "\n")
            assert mctx.output_stream.flush.called
コード例 #2
0
    def test_writeln_with_default_verbosity(self):
        with mocked_ctx() as mctx:
            msg = "test message"

            writeln(msg)

            mctx.output_stream.write.assert_called_with(msg + "\n")
            assert mctx.output_stream.flush.called
コード例 #3
0
    def test_writeln_with_verbosity_verbose_in_silent_context(self):
        with mocked_ctx() as mctx:
            # when the context is defined as silent, verbose level
            # messages should be ignored.
            mctx.output_verbosity = T.test_logger.VERBOSITY_SILENT
            msg = "test message"

            writeln(msg, T.test_logger.VERBOSITY_VERBOSE)

            T.assert_equal(mctx.output_stream.flush.called, False)
コード例 #4
0
    def test_writeln_with_verbosity_verbose_in_silent_context(self):
        with mocked_ctx() as mctx:
            # when the context is defined as silent, verbose level
            # messages should be ignored.
            mctx.output_verbosity = T.test_logger.VERBOSITY_SILENT
            msg = "test message"

            writeln(msg, T.test_logger.VERBOSITY_VERBOSE)

            T.assert_equal(mctx.output_stream.flush.called, False)
コード例 #5
0
    def test_writeln_with_verbosity_verbose(self):
        with mocked_ctx() as mctx:
            # should see verbose messages in a verbose context.
            verbosity = T.test_logger.VERBOSITY_VERBOSE
            msg = "test message"
            mctx.output_verbosity = verbosity

            writeln(msg, verbosity)

            mctx.output_stream.write.assert_called_with(msg + "\n")
            assert mctx.output_stream.flush.called
コード例 #6
0
    def test_writeln_with_verbosity_verbose(self):
        with mocked_ctx() as mctx:
            # should see verbose messages in a verbose context.
            verbosity = T.test_logger.VERBOSITY_VERBOSE
            msg = "test message"
            mctx.output_verbosity = verbosity

            writeln(msg, verbosity)

            mctx.output_stream.write.assert_called_with(msg + "\n")
            assert mctx.output_stream.flush.called
コード例 #7
0
    def test_writeln_with_verbosity_silent(self):
        with mocked_ctx() as mctx:
            # when ctx.output_verbosity is defined as silent and we
            # want to write a message in in VERBOSITY_SILENT, we
            # should still see the message.
            verbosity = T.test_logger.VERBOSITY_SILENT
            mctx.output_verbosity = T.test_logger.VERBOSITY_SILENT
            msg = "test message"

            writeln(msg, verbosity)

            mctx.output_stream.write.assert_called_with(msg + "\n")
            assert mctx.output_stream.flush.called
コード例 #8
0
    def test_writeln_with_verbosity_silent(self):
        with mocked_ctx() as mctx:
            # when ctx.output_verbosity is defined as silent and we
            # want to write a message in in VERBOSITY_SILENT, we
            # should still see the message.
            verbosity = T.test_logger.VERBOSITY_SILENT
            mctx.output_verbosity = T.test_logger.VERBOSITY_SILENT
            msg = "test message"

            writeln(msg, verbosity)

            mctx.output_stream.write.assert_called_with(msg + "\n")
            assert mctx.output_stream.flush.called