Added conftest.py for pytest
File contains a fixture which must be present for test_logger module to work functionally. Fixture relates to a monkeypatch implementation for capturing standard PIPEs and storing their results in a buffer. This buffer can then be read after a call to send data on a PIPE stream has been called, via a key lookup on the appropriate stream.
This commit is contained in:
parent
693f516f58
commit
6cd0024113
23
conftest.py
Normal file
23
conftest.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# flake8: noqa
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def capture_stdpipe(monkeypatch):
|
||||
stream_buf = {"stdout": "", "stderr": "", "writes": 0}
|
||||
|
||||
def mimic_stdout(chars):
|
||||
stream_buf['stdout'] += chars
|
||||
stream_buf['writes'] += 1
|
||||
|
||||
def mimic_stderr(chars):
|
||||
stream_buf['stderr'] += chars
|
||||
stream_buf['writes'] += 1
|
||||
|
||||
|
||||
monkeypatch.setattr(sys.stdout, 'write', mimic_stdout)
|
||||
monkeypatch.setattr(sys.stderr, 'write', mimic_stderr)
|
||||
|
||||
return stream_buf
|
||||
Loading…
Reference in New Issue
Block a user