Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testRepresentations(self):
colors1 = colors.full(87)
assert colors1 == colors.DarkSlateGray2
assert colors1.basic == colors.DarkSlateGray2
assert str(colors1.basic) == str(colors.LightGray)
colors2 = colors.rgb(1,45,214)
assert str(colors2.full) == str(colors.Blue3A)
def testLoadColorByName(self):
assert colors['LightBlue'] == colors.fg['LightBlue']
assert colors.bg['light_green'] == colors.bg['LightGreen']
assert colors['DeepSkyBlue1'] == colors['#00afff']
assert colors['DeepSkyBlue1'] == colors.hex('#00afff')
assert colors['DeepSkyBlue1'] == colors[39]
assert colors.DeepSkyBlue1 == colors[39]
assert colors.deepskyblue1 == colors[39]
assert colors.Deep_Sky_Blue1 == colors[39]
assert colors.RED == colors.red
with pytest.raises(AttributeError):
colors.Notacolorsatall
def testLoadNumericalColor(self):
assert colors.full(2) == colors[2]
assert colors.simple(2) == colors(2)
assert colors(54) == colors[54]
assert colors(1,30,77) == colors.rgb(1,30,77)
assert colors[1,30,77] == colors.rgb(1,30,77)
def testRepresentations(self):
colors1 = colors.full(87)
assert colors1 == colors.DarkSlateGray2
assert colors1.basic == colors.DarkSlateGray2
assert str(colors1.basic) == str(colors.LightGray)
colors2 = colors.rgb(1,45,214)
assert str(colors2.full) == str(colors.Blue3A)
def testLoadColorByName(self):
assert colors['LightBlue'] == colors.fg['LightBlue']
assert colors.bg['light_green'] == colors.bg['LightGreen']
assert colors['DeepSkyBlue1'] == colors['#00afff']
assert colors['DeepSkyBlue1'] == colors.hex('#00afff')
assert colors['DeepSkyBlue1'] == colors[39]
assert colors.DeepSkyBlue1 == colors[39]
assert colors.deepskyblue1 == colors[39]
assert colors.Deep_Sky_Blue1 == colors[39]
assert colors.RED == colors.red
with pytest.raises(AttributeError):
colors.Notacolorsatall
def testLoadColorByName(self):
assert colors['LightBlue'] == colors.fg['LightBlue']
assert colors.bg['light_green'] == colors.bg['LightGreen']
assert colors['DeepSkyBlue1'] == colors['#00afff']
assert colors['DeepSkyBlue1'] == colors.hex('#00afff')
assert colors['DeepSkyBlue1'] == colors[39]
assert colors.DeepSkyBlue1 == colors[39]
assert colors.deepskyblue1 == colors[39]
assert colors.Deep_Sky_Blue1 == colors[39]
assert colors.RED == colors.red
with pytest.raises(AttributeError):
colors.Notacolorsatall
def testUndoColor(self):
assert '\033[39m' == ~colors.fg
assert '\033[49m' == ~colors.bg
assert '\033[22m' == ~colors.bold
assert '\033[22m' == ~colors.dim
for i in range(7):
assert '\033[39m' == ~colors(i)
assert '\033[49m' == ~colors.bg(i)
assert '\033[39m' == ~colors.fg(i)
assert '\033[49m' == ~colors.bg(i)
for i in range(256):
assert '\033[39m' == ~colors.fg[i]
assert '\033[49m' == ~colors.bg[i]
assert '\033[0m' == ~colors.reset
assert colors.do_nothing == ~colors.do_nothing
assert colors.bold.reset == ~colors.bold
def testEmptyStyle(self):
assert str(colors()) == ''
assert str(colors('')) == ''
assert str(colors(None)) == ''
def testToggleColors(self):
print()
print(colors.fg.red["This is in red"], "but this is not")
print(colors.fg.green + "Hi, " + colors.bg[23]
+ "This is on a BG" + ~colors.bg + " and this is not but is still green.")
colors.yellow.print("This is printed from color.")
colors.reset()
for attr in colors._style.attribute_names:
print("This is", attr | getattr(colors, attr), "and this is not.")
colors.reset()
msg = indentation.join(
wrapper.wrap(" ".join(
l.strip() for l in help.splitlines())))
if len(name) + wrapper.width >= cols:
padding = indentation
else:
padding = " " * max(
cols - wrapper.width - len(name) - 4, 1)
if colors.contains_colors(subcls.name):
bodycolor = colors.extract(subcls.name)
else:
bodycolor = gc
print(description_indent.format(
subcls.name, padding, bodycolor | colors.filter(msg)))