Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init(self):
style = OutputFormatterStyle('green', 'black', ['bold', 'underscore'])
self.assertEqual('\033[32;40;1;4mfoo\033[0m', style.apply('foo'))
style = OutputFormatterStyle('red', None, ['blink'])
self.assertEqual('\033[31;5mfoo\033[0m', style.apply('foo'))
style = OutputFormatterStyle(None, 'white')
self.assertEqual('\033[47mfoo\033[0m', style.apply('foo'))
def test_init(self):
style = OutputFormatterStyle('green', 'black', ['bold', 'underscore'])
self.assertEqual('\033[32;40;1;4mfoo\033[0m', style.apply('foo'))
style = OutputFormatterStyle('red', None, ['blink'])
self.assertEqual('\033[31;5mfoo\033[0m', style.apply('foo'))
style = OutputFormatterStyle(None, 'white')
self.assertEqual('\033[47mfoo\033[0m', style.apply('foo'))
def test_init(self):
style = OutputFormatterStyle('green', 'black', ['bold', 'underscore'])
self.assertEqual('\033[32;40;1;4mfoo\033[0m', style.apply('foo'))
style = OutputFormatterStyle('red', None, ['blink'])
self.assertEqual('\033[31;5mfoo\033[0m', style.apply('foo'))
style = OutputFormatterStyle(None, 'white')
self.assertEqual('\033[47mfoo\033[0m', style.apply('foo'))
def test_invalid_pop(self):
stack = OutputFormatterStyleStack()
s1 = OutputFormatterStyle('white', 'black')
s2 = OutputFormatterStyle('yellow', 'blue')
stack.push(s1)
self.assertRaises(
Exception,
stack.pop,
s2
)
def test_pop(self):
stack = OutputFormatterStyleStack()
s1 = OutputFormatterStyle('white', 'black')
s2 = OutputFormatterStyle('yellow', 'blue')
stack.push(s1)
stack.push(s2)
self.assertEqual(s2, stack.pop())
self.assertEqual(s1, stack.pop())
def test_push(self):
stack = OutputFormatterStyleStack()
s1 = OutputFormatterStyle('white', 'black')
s2 = OutputFormatterStyle('yellow', 'blue')
stack.push(s1)
stack.push(s2)
self.assertEqual(s2, stack.get_current())
s3 = OutputFormatterStyle('green', 'red')
stack.push(s3)
self.assertEqual(s3, stack.get_current())
def test_pop_not_last(self):
stack = OutputFormatterStyleStack()
s1 = OutputFormatterStyle('white', 'black')
s2 = OutputFormatterStyle('yellow', 'blue')
s3 = OutputFormatterStyle('green', 'red')
stack.push(s1)
stack.push(s2)
stack.push(s3)
self.assertEqual(s2, stack.pop(s2))
self.assertEqual(s1, stack.pop())
def test_push(self):
stack = OutputFormatterStyleStack()
s1 = OutputFormatterStyle('white', 'black')
s2 = OutputFormatterStyle('yellow', 'blue')
stack.push(s1)
stack.push(s2)
self.assertEqual(s2, stack.get_current())
s3 = OutputFormatterStyle('green', 'red')
stack.push(s3)
self.assertEqual(s3, stack.get_current())
def test_pop_not_last(self):
stack = OutputFormatterStyleStack()
s1 = OutputFormatterStyle('white', 'black')
s2 = OutputFormatterStyle('yellow', 'blue')
s3 = OutputFormatterStyle('green', 'red')
stack.push(s1)
stack.push(s2)
stack.push(s3)
self.assertEqual(s2, stack.pop(s2))
self.assertEqual(s1, stack.pop())
def test_invalid_pop(self):
stack = OutputFormatterStyleStack()
s1 = OutputFormatterStyle('white', 'black')
s2 = OutputFormatterStyle('yellow', 'blue')
stack.push(s1)
self.assertRaises(
Exception,
stack.pop,
s2
)