forked from streamlink/streamlink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_log.py
More file actions
36 lines (27 loc) · 976 Bytes
/
Copy pathtest_log.py
File metadata and controls
36 lines (27 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest
from streamlink.logger import Logger
from streamlink.compat import is_py2
# Docs says StringIO is suppose to take non-unicode strings
# but it doesn't, so let's use BytesIO instead there...
if is_py2:
from io import BytesIO as StringIO
else:
from io import StringIO
class TestSession(unittest.TestCase):
def setUp(self):
self.output = StringIO()
self.manager = Logger()
self.manager.set_output(self.output)
self.logger = self.manager.new_module("test")
def test_level(self):
self.logger.debug("test")
self.assertEqual(self.output.tell(), 0)
self.manager.set_level("debug")
self.logger.debug("test")
self.assertNotEqual(self.output.tell(), 0)
def test_output(self):
self.manager.set_level("debug")
self.logger.debug("test")
self.assertEqual(self.output.getvalue(), "[test][debug] test\n")
if __name__ == "__main__":
unittest.main()