Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Grub4K committed Feb 12, 2024
1 parent 3b39138 commit 1be36c9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/utils/test_logging_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ def test_write(self):
log = StreamLogWriter(logger, 1)

msg = "test_message"
log.write(msg)
length = log.write(msg)

assert length == len(msg)
assert log._buffer == msg

log.write(" \n")
length = log.write(" \n")
assert length == 0
logger.log.assert_called_once_with(1, msg)

assert log._buffer == ""
Expand Down Expand Up @@ -168,7 +170,7 @@ def test_encoding(self):
logger.log = mock.MagicMock()

log = StreamLogWriter(logger, 1)
assert log.encoding is None
assert log.encoding == "None"

def test_iobase_compatibility(self):
log = StreamLogWriter(None, 1)
Expand All @@ -177,6 +179,13 @@ def test_iobase_compatibility(self):
# has no specific effect
log.close()

def test_textio_compatibility(self):
log = StreamLogWriter(None, 1)

# Make sure some common operations don't fail
assert "b" not in log.mode
assert log.name.partition(".")[0] == "<logger>"


@pytest.mark.parametrize(["maintain_propagate"], [[SetContextPropagate.MAINTAIN_PROPAGATE], [None]])
def test_set_context_propagation(parent_child_handlers, child_logger, maintain_propagate):
Expand Down

0 comments on commit 1be36c9

Please sign in to comment.