/usr/lib/python3/dist-packages/celery/tests/utils/test_term.py is in python3-celery 3.1.20-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | # -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
import sys
from celery.utils import term
from celery.utils.term import colored, fg
from celery.five import text_t
from celery.tests.case import Case, SkipTest
class test_colored(Case):
def setUp(self):
if sys.platform == 'win32':
raise SkipTest('Colors not supported on Windows')
self._prev_encoding = sys.getdefaultencoding
def getdefaultencoding():
return 'utf-8'
sys.getdefaultencoding = getdefaultencoding
def tearDown(self):
sys.getdefaultencoding = self._prev_encoding
def test_colors(self):
colors = (
('black', term.BLACK),
('red', term.RED),
('green', term.GREEN),
('yellow', term.YELLOW),
('blue', term.BLUE),
('magenta', term.MAGENTA),
('cyan', term.CYAN),
('white', term.WHITE),
)
for name, key in colors:
self.assertIn(fg(30 + key), str(colored().names[name]('foo')))
self.assertTrue(str(colored().bold('f')))
self.assertTrue(str(colored().underline('f')))
self.assertTrue(str(colored().blink('f')))
self.assertTrue(str(colored().reverse('f')))
self.assertTrue(str(colored().bright('f')))
self.assertTrue(str(colored().ired('f')))
self.assertTrue(str(colored().igreen('f')))
self.assertTrue(str(colored().iyellow('f')))
self.assertTrue(str(colored().iblue('f')))
self.assertTrue(str(colored().imagenta('f')))
self.assertTrue(str(colored().icyan('f')))
self.assertTrue(str(colored().iwhite('f')))
self.assertTrue(str(colored().reset('f')))
self.assertTrue(text_t(colored().green('∂bar')))
self.assertTrue(
colored().red('éefoo') + colored().green('∂bar'))
self.assertEqual(
colored().red('foo').no_color(), 'foo')
self.assertTrue(
repr(colored().blue('åfoo')))
self.assertIn("''", repr(colored()))
c = colored()
s = c.red('foo', c.blue('bar'), c.green('baz'))
self.assertTrue(s.no_color())
c._fold_no_color(s, 'øfoo')
c._fold_no_color('fooå', s)
c = colored().red('åfoo')
self.assertEqual(
c._add(c, 'baræ'),
'\x1b[1;31m\xe5foo\x1b[0mbar\xe6',
)
c2 = colored().blue('ƒƒz')
c3 = c._add(c, c2)
self.assertEqual(
c3,
'\x1b[1;31m\xe5foo\x1b[0m\x1b[1;34m\u0192\u0192z\x1b[0m',
)
|