Ejemplo n.º 1
0
	def test_backToBack(self) :
		terminalInput = """\
Normal colors:
	\033[30mblack\033[0m\
	\033[31mred\033[0m\
	\033[32mgreen\033[0m\
	\033[33myellow\033[0m\
	\033[34mblue\033[0m\
	\033[35mmagenta\033[0m\
	\033[36mcyan\033[0m\
	\033[37mwhite\033[0m\
	\033[39mdefault\033[0m
Bright colors:
	\033[1;30mblack\033[0m\
	\033[1;31mred\033[0m\
	\033[1;32mgreen\033[0m\
	\033[1;33myellow\033[0m\
	\033[1;34mblue\033[0m\
	\033[1;35mmagenta\033[0m\
	\033[1;36mcyan\033[0m\
	\033[1;37mwhite\033[0m\
	\033[1;39mdefault\033[0m
Background colors:
	\033[40mblack\033[0m\
	\033[41mred\033[0m\
	\033[42mgreen\033[0m\
	\033[43myellow\033[0m\
	\033[44mblue\033[0m\
	\033[45mmagenta\033[0m\
	\033[46mcyan\033[0m\
	\033[47mwhite\033[0m\
	\033[49mdefault\033[0m
Attributes:
	\033[1mbright\033[0m
	\033[2mfaint\033[0m
	\033[3mitalic\033[0m
	\033[4munderscore\033[0m
	\033[5mblink\033[0m
	\033[6mdouble blink\033[0m <- not implemented
	\033[7mreverse\033[0m <- TODO: Find a better way to implement it
	\033[8mhide\033[0m <- It's hidden, you can still select and copy it
	\033[9mstrike\033[0m

Activating \033[31mred and then \033[43mdark yellow
background and then activating \033[32mgreen foreground
now changing attribute to \033[1mbright and then
\033[21mreseting it without changing colors.
\033[44mblue background and \033[5mblink attribute,
\033[49mdefault background, unsetting \033[25mblink,
unsetting \033[39m foreground and \033[0mall attribs.
"""
#		print (terminalInput)
		with open("deansi-b2b.html") as f:
			expected = f.read()
		result = html_template % (styleSheet(), deansi(terminalInput))

		if (result!=expected) :
			with open("deansi-failed.html","w") as f:
				f.write(result)
		self.assertMultiLineEqual(expected, result)
Ejemplo n.º 2
0
 def test_deansi_takesMultiline(self):
     self.assertEqual(
         'this should be <span class=\'ansi_red\'>\nred</span>'
         '<span class=\'ansi_bright ansi_red ansi_bggreen\'> and green \nbackground\n</span> and this not',
         deansi(
             'this should be \033[31m\nred\033[42;1m and green \nbackground\n\033[0m and this not'
         ),
     )
Ejemplo n.º 3
0
 def test_deansi_withComplexCodes(self):
     self.assertEqual(
         'this should be <span class=\'ansi_red\'>red</span>'
         '<span class=\'ansi_bright ansi_red ansi_bggreen\'> and green background</span> and this not',
         deansi(
             'this should be \033[31mred\033[42;1m and green background\033[0m and this not'
         ),
     )
Ejemplo n.º 4
0
	def test_backToBack(self) :
		terminalInput = """\
Normal colors:
	\033[30mblack\033[0m\
	\033[31mred\033[0m\
	\033[32mgreen\033[0m\
	\033[33myellow\033[0m\
	\033[34mblue\033[0m\
	\033[35mmagenta\033[0m\
	\033[36mcyan\033[0m\
	\033[37mwhite\033[0m\
	\033[39mdefault\033[0m
Bright colors:
	\033[1;30mblack\033[0m\
	\033[1;31mred\033[0m\
	\033[1;32mgreen\033[0m\
	\033[1;33myellow\033[0m\
	\033[1;34mblue\033[0m\
	\033[1;35mmagenta\033[0m\
	\033[1;36mcyan\033[0m\
	\033[1;37mwhite\033[0m\
	\033[1;39mdefault\033[0m
Background colors:
	\033[40mblack\033[0m\
	\033[41mred\033[0m\
	\033[42mgreen\033[0m\
	\033[43myellow\033[0m\
	\033[44mblue\033[0m\
	\033[45mmagenta\033[0m\
	\033[46mcyan\033[0m\
	\033[47mwhite\033[0m\
	\033[49mdefault\033[0m
Attributes:
	\033[1mbright\033[0m
	\033[2mfaint\033[0m
	\033[3mitalic\033[0m
	\033[4munderscore\033[0m
	\033[5mblink\033[0m
	\033[6mdouble blink\033[0m <- not implemented
	\033[7mreverse\033[0m <- TODO: Find a better way to implement it
	\033[8mhide\033[0m <- It's hidden, you can still select and copy it
	\033[9mstrike\033[0m

Activating \033[31mred and then \033[43mdark yellow
background and then activating \033[32mgreen foreground
now changing attribute to \033[1mbright and then
\033[21mreseting it without changing colors.
\033[44mblue background and \033[5mblink attribute,
\033[49mdefault background, unsetting \033[25mblink,
unsetting \033[39m foreground and \033[0mall attribs.
"""
#		print (terminalInput)
		expected = open("deansi-b2b.html").read()
		result = html_template % (styleSheet(), deansi(terminalInput))

		if (result!=expected) :
			open("deansi-failed.html","w").write(result)
		self.assertMultiLineEqual(expected, result)
Ejemplo n.º 5
0
	def assertDeansiEqual(self, expected, inputText) :
		return self.assertEqual(expected, deansi(inputText))
Ejemplo n.º 6
0
	def test_deansi_takesMultiline(self) :
		self.assertEqual(
			'this should be <span class=\'ansi_red\'>\nred</span>'
			'<span class=\'ansi_bright ansi_red ansi_bggreen\'> and green \nbackground\n</span> and this not',
			deansi('this should be \033[31m\nred\033[42;1m and green \nbackground\n\033[0m and this not'),
		)
Ejemplo n.º 7
0
	def test_deansi_withComplexCodes(self) :
		self.assertEqual(
			'this should be <span class=\'ansi_red\'>red</span>'
			'<span class=\'ansi_bright ansi_red ansi_bggreen\'> and green background</span> and this not',
			deansi('this should be \033[31mred\033[42;1m and green background\033[0m and this not'),
		)
Ejemplo n.º 8
0
	def test_deansi_emptyAttributeClears(self) :
		self.assertEqual(
			'this should be <span class=\'ansi_red\'>red</span> and this not',
			deansi('this should be \033[31mred\033[m and this not'),
		)
Ejemplo n.º 9
0
	def test_deansi_withCodes(self) :
		self.assertEqual(
			'this should be <span class=\'ansi_red\'>red</span> and this not',
			deansi('this should be \033[31mred\033[0m and this not'),
		)
Ejemplo n.º 10
0
	def assertDeansiEqual(self, expected, inputText) :
		return self.assertEqual(expected, deansi(inputText))
Ejemplo n.º 11
0
	def test_deansi_emptyAttributeClears(self) :
		self.assertEqual(
			'this should be <span class=\'ansi_red\'>red</span> and this not',
			deansi('this should be \033[31mred\033[m and this not'),
		)
Ejemplo n.º 12
0
	def test_deansi_withCodes(self) :
		self.assertEqual(
			'this should be <span class=\'ansi_red\'>red</span> and this not',
			deansi('this should be \033[31mred\033[0m and this not'),
		)