# Path: rvic/core/log.py
# class StreamToFile(object):
#     '''
#     Fake file-like stream object that redirects writes to a logger instance.
#     http://www.electricmonk.nl/log/2011/08/14/redirect-stdout-and-stderr-to-a-logger-in-python/
#     '''
#     def __init__(self, logger_name=LOG_NAME, log_level=logging.INFO):
#         self.logger = logging.getLogger(logger_name)
#         self.log_level = log_level
#         self.linebuf = ''
# 
#     def write(self, buf):
#         for line in buf.rstrip().splitlines():
#             self.logger.log(self.log_level, line.rstrip())
# 
#     def flush(self):
#         pass


import pytest
from rvic.core.log import StreamToFile


def test_setup_stream():
    stream = StreamToFile()
    stream.write('buf')
    stream.flush()


def test_stream_raises_with_bad_log_level():
    with pytest.raises(TypeError):

# Path: rvic/core/log.py
# class StreamToFile(object):
#     '''
#     Fake file-like stream object that redirects writes to a logger instance.
#     http://www.electricmonk.nl/log/2011/08/14/redirect-stdout-and-stderr-to-a-logger-in-python/
#     '''
#     def __init__(self, logger_name=LOG_NAME, log_level=logging.INFO):
#         self.logger = logging.getLogger(logger_name)
#         self.log_level = log_level
#         self.linebuf = ''
# 
#     def write(self, buf):
#         for line in buf.rstrip().splitlines():
#             self.logger.log(self.log_level, line.rstrip())
# 
#     def flush(self):
#         pass


# Path: tests/unit/test_log.py
import pytest
from rvic.core.log import StreamToFile



def test_setup_stream():
    stream = StreamToFile()
    stream.write('buf')
    stream.flush()


def test_stream_raises_with_bad_log_level():
    with pytest.raises(TypeError):

        stream = StreamToFile(log_level='junk')