message_ix_models.tests.util.test_logging.TestQueueListener

class message_ix_models.tests.util.test_logging.TestQueueListener[source]

Bases: object

__init__()

Methods

__init__()

test_flush(caplog, mix_models_cli, method, k)

Test logging in multiple processes, multiple threads, and with click.

Attributes

N

Number of log messages to emit.

k

Number of times to run the test.

N = 1000

Number of log messages to emit.

k = 4

Number of times to run the test.

test_flush(caplog, mix_models_cli, method, k)[source]

Test logging in multiple processes, multiple threads, and with click.

With pytest-xdist, these k test cases will run in multiple processes. Each process will have its main thread, and the thread of the QueueListener. The test ensures that all N log records emitted by the func() are “flushed” from the queue, transferred to stdout by the StreamHandler and captured by the CliRunner.