Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/twisted_8_1/twisted/conch/test/test_text.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # -*- test-case-name: twisted.conch.test.test_text -*-
2 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3 # See LICENSE for details.
4
5 from twisted.trial import unittest
6
7 from twisted.conch.insults import helper, text
8
9 A = text.attributes
10
11 class Serialization(unittest.TestCase):
12 def setUp(self):
13 self.attrs = helper.CharacterAttribute()
14
15 def testTrivial(self):
16 self.assertEquals(
17 text.flatten(A.normal['Hello, world.'], self.attrs),
18 'Hello, world.')
19
20 def testBold(self):
21 self.assertEquals(
22 text.flatten(A.bold['Hello, world.'], self.attrs),
23 '\x1b[1mHello, world.')
24
25 def testUnderline(self):
26 self.assertEquals(
27 text.flatten(A.underline['Hello, world.'], self.attrs),
28 '\x1b[4mHello, world.')
29
30 def testBlink(self):
31 self.assertEquals(
32 text.flatten(A.blink['Hello, world.'], self.attrs),
33 '\x1b[5mHello, world.')
34
35 def testReverseVideo(self):
36 self.assertEquals(
37 text.flatten(A.reverseVideo['Hello, world.'], self.attrs),
38 '\x1b[7mHello, world.')
39
40 def testMinus(self):
41 self.assertEquals(
42 text.flatten(
43 A.bold[A.blink['Hello', -A.bold[' world'], '.']],
44 self.attrs),
45 '\x1b[1;5mHello\x1b[0;5m world\x1b[1;5m.')
46
47 def testForeground(self):
48 self.assertEquals(
49 text.flatten(
50 A.normal[A.fg.red['Hello, '], A.fg.green['world!']],
51 self.attrs),
52 '\x1b[31mHello, \x1b[32mworld!')
53
54 def testBackground(self):
55 self.assertEquals(
56 text.flatten(
57 A.normal[A.bg.red['Hello, '], A.bg.green['world!']],
58 self.attrs),
59 '\x1b[41mHello, \x1b[42mworld!')
60
61
62 class EfficiencyTestCase(unittest.TestCase):
63 todo = ("flatten() isn't quite stateful enough to avoid emitting a few extra bytes in "
64 "certain circumstances, so these tests fail. The failures take the form of "
65 "additional elements in the ;-delimited character attribute lists. For example, "
66 "\\x1b[0;31;46m might be emitted instead of \\x[46m, even if 31 has already been "
67 "activated and no conflicting attributes are set which need to be cl eared.")
68
69 def setUp(self):
70 self.attrs = helper.CharacterAttribute()
71
72 def testComplexStructure(self):
73 output = A.normal[
74 A.bold[
75 A.bg.cyan[
76 A.fg.red[
77 "Foreground Red, Background Cyan, Bold",
78 A.blink[
79 "Blinking"],
80 -A.bold[
81 "Foreground Red, Background Cyan, normal"]],
82 A.fg.green[
83 "Foreground Green, Background Cyan, Bold"]]]]
84
85 self.assertEquals(
86 text.flatten(output, self.attrs),
87 "\x1b[1;31;46mForeground Red, Background Cyan, Bold"
88 "\x1b[5mBlinking"
89 "\x1b[0;31;46mForeground Red, Background Cyan, normal"
90 "\x1b[1;32;46mForeground Green, Background Cyan, Bold")
91
92 def testNesting(self):
93 self.assertEquals(
94 text.flatten(A.bold['Hello, ', A.underline['world.']], self.attrs),
95 '\x1b[1mHello, \x1b[4mworld.')
96
97 self.assertEquals(
98 text.flatten(
99 A.bold[A.reverseVideo['Hello, ', A.normal['world'], '.']],
100 self.attrs),
101 '\x1b[1;7mHello, \x1b[0mworld\x1b[1;7m.')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698