-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_syncdir_Tracer.py
41 lines (35 loc) · 1.26 KB
/
test_syncdir_Tracer.py
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
37
38
39
40
41
import io
import syncdir
import unittest
class TracerTestCase(unittest.TestCase):
def setUp(self):
self.out = io.StringIO()
self.t = syncdir.Tracer(self.out)
def tearDown(self):
self.out.close()
def runTest(self):
self.assertEqual(self.out.getvalue(), "")
class TracerTestCase_report(TracerTestCase):
def runTest(self):
self.t.report("hi!")
self.assertEqual(self.out.getvalue(), "hi!\n")
class TracerTestCase_trace_twice(TracerTestCase):
def runTest(self):
self.t.trace("hello!")
self.assertEqual(self.out.getvalue(), "\rhello!")
self.t.trace("bye!")
self.assertEqual(self.out.getvalue(), "\rhello!\rbye! \b\b")
class TracerTest_trace_many(TracerTestCase):
def runTest(self):
for l in range(82):
with self.subTest(length=l):
start = len(self.out.getvalue())
self.t.trace("." * l)
self.assertEqual(self.out.getvalue()[start:], "\r" + "." * min(l, 79))
class TracerTestCase_trace_and_report(TracerTestCase):
def runTest(self):
self.t.trace("hello!")
self.t.report("bye!")
self.assertEqual(self.out.getvalue(), "\rhello!\r \rbye!\n")
if __name__ == '__main__':
unittest.main()