Give some colors names

This commit is contained in:
Foo 2017-04-30 02:34:20 +03:00
parent 4a3f098f22
commit b7a46eb7a8

View File

@ -12,6 +12,7 @@ from difflib import ndiff
from glob import glob1 from glob import glob1
from powerline.lib.unicode import u from powerline.lib.unicode import u
from powerline.lib.dict import updated
from powerline.bindings.tmux import get_tmux_version from powerline.bindings.tmux import get_tmux_version
from powerline import get_fallback_logger from powerline import get_fallback_logger
@ -167,6 +168,14 @@ def main(attempts=3):
with open(conf_file, 'w') as cf_fd: with open(conf_file, 'w') as cf_fd:
cf_fd.write(conf_line) cf_fd.write(conf_line)
base_attrs = {
((0, 0, 0), (243, 243, 243), 1, 0, 0): 'lead',
((243, 243, 243), (11, 11, 11), 0, 0, 0): 'leadsep',
((255, 255, 255), (11, 11, 11), 0, 0, 0): 'bg',
((199, 199, 199), (88, 88, 88), 0, 0, 0): 'cwd',
((88, 88, 88), (11, 11, 11), 0, 0, 0): 'cwdhsep',
}
try: try:
p = ExpectProcess( p = ExpectProcess(
lib=lib, lib=lib,
@ -197,61 +206,47 @@ def main(attempts=3):
expected_result = get_expected_result( expected_result = get_expected_result(
tmux_version, tmux_version,
expected_result_old=( expected_result_old=(
'{1: 0 }{2: }{3: S2 string here }{4: 0 }' '{lead: 0 }{leadsep: }{bg: S2 string here }'
'{5:| }{6:bash }{3: }{4: 1- }' '{4: 0 }{cwdhsep:| }{6:bash }'
'{5:| }{6:bash }{3: }{7: }' '{bg: }{4: 1- }{cwdhsep:| }{6:bash }'
'{8:2* | }{9:bash }{10: }' '{bg: }{7: }{8:2* | }{9:bash }{10: }'
'{3:' + (' ' * 124) + '}' '{bg:' + (' ' * 124) + '}'
'{5: }{11: S1 string here }', { '{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, {
((0, 0, 0), (243, 243, 243), 1, 0, 0): 1,
((243, 243, 243), (11, 11, 11), 0, 0, 0): 2,
((255, 255, 255), (11, 11, 11), 0, 0, 0): 3,
((133, 133, 133), (11, 11, 11), 0, 0, 0): 4, ((133, 133, 133), (11, 11, 11), 0, 0, 0): 4,
((88, 88, 88), (11, 11, 11), 0, 0, 0): 5,
((188, 188, 188), (11, 11, 11), 0, 0, 0): 6, ((188, 188, 188), (11, 11, 11), 0, 0, 0): 6,
((11, 11, 11), (0, 102, 153), 0, 0, 0): 7, ((11, 11, 11), (0, 102, 153), 0, 0, 0): 7,
((102, 204, 255), (0, 102, 153), 0, 0, 0): 8, ((102, 204, 255), (0, 102, 153), 0, 0, 0): 8,
((255, 255, 255), (0, 102, 153), 1, 0, 0): 9, ((255, 255, 255), (0, 102, 153), 1, 0, 0): 9,
((0, 102, 153), (11, 11, 11), 0, 0, 0): 10, ((0, 102, 153), (11, 11, 11), 0, 0, 0): 10,
((199, 199, 199), (88, 88, 88), 0, 0, 0): 11, })),
}),
expected_result_new=( expected_result_new=(
'{1: 0 }{2: }{3: S2 string here }{4: 0 }' '{lead: 0 }{leadsep: }{bg: S2 string here }'
'{5:| }{6:bash }{3: }{4: 1- }' '{4: 0 }{cwdhsep:| }{6:bash }'
'{5:| }{7:bash }{3: }{8: }' '{bg: }{4: 1- }{cwdhsep:| }{7:bash }'
'{9:2* | }{10:bash }{7: }' '{bg: }{8: }{9:2* | }{10:bash }{7: }'
'{3:' + (' ' * 124) + '}' '{bg:' + (' ' * 124) + '}'
'{5: }{11: S1 string here }', { '{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, {
((0, 0, 0), (243, 243, 243), 1, 0, 0): 1,
((243, 243, 243), (11, 11, 11), 0, 0, 0): 2,
((255, 255, 255), (11, 11, 11), 0, 0, 0): 3,
((133, 133, 133), (11, 11, 11), 0, 0, 0): 4, ((133, 133, 133), (11, 11, 11), 0, 0, 0): 4,
((88, 88, 88), (11, 11, 11), 0, 0, 0): 5,
((188, 188, 188), (11, 11, 11), 0, 0, 0): 6, ((188, 188, 188), (11, 11, 11), 0, 0, 0): 6,
((0, 102, 153), (11, 11, 11), 0, 0, 0): 7, ((0, 102, 153), (11, 11, 11), 0, 0, 0): 7,
((11, 11, 11), (0, 102, 153), 0, 0, 0): 8, ((11, 11, 11), (0, 102, 153), 0, 0, 0): 8,
((102, 204, 255), (0, 102, 153), 0, 0, 0): 9, ((102, 204, 255), (0, 102, 153), 0, 0, 0): 9,
((255, 255, 255), (0, 102, 153), 1, 0, 0): 10, ((255, 255, 255), (0, 102, 153), 1, 0, 0): 10,
((199, 199, 199), (88, 88, 88), 0, 0, 0): 11, })),
}),
expected_result_2_0=( expected_result_2_0=(
'{1: 0 }{2: }{3: S2 string here }{4: 0 }' '{lead: 0 }{leadsep: }{bg: S2 string here }'
'{5:| }{6:bash }{3: }{4: 1- }' '{4: 0 }{cwdhsep:| }{6:bash }'
'{5:| }{7:bash }{3: }{8: }' '{bg: }{4: 1- }{cwdhsep:| }{7:bash }'
'{9:2* | }{10:bash }{7: }' '{bg: }{8: }{9:2* | }{10:bash }{7: }'
'{3:' + (' ' * 125) + '}{5: }{11: S1 string here }', { '{bg:' + (' ' * 125) + '}'
((0, 0, 0), (243, 243, 243), 1, 0, 0): 1, '{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, {
((243, 243, 243), (11, 11, 11), 0, 0, 0): 2,
((255, 255, 255), (11, 11, 11), 0, 0, 0): 3,
((133, 133, 133), (11, 11, 11), 0, 0, 0): 4, ((133, 133, 133), (11, 11, 11), 0, 0, 0): 4,
((88, 88, 88), (11, 11, 11), 0, 0, 0): 5,
((188, 188, 188), (11, 11, 11), 0, 0, 0): 6, ((188, 188, 188), (11, 11, 11), 0, 0, 0): 6,
((0, 102, 153), (11, 11, 11), 0, 0, 0): 7, ((0, 102, 153), (11, 11, 11), 0, 0, 0): 7,
((11, 11, 11), (0, 102, 153), 0, 0, 0): 8, ((11, 11, 11), (0, 102, 153), 0, 0, 0): 8,
((102, 204, 255), (0, 102, 153), 0, 0, 0): 9, ((102, 204, 255), (0, 102, 153), 0, 0, 0): 9,
((255, 255, 255), (0, 102, 153), 1, 0, 0): 10, ((255, 255, 255), (0, 102, 153), 1, 0, 0): 10,
((199, 199, 199), (88, 88, 88), 0, 0, 0): 11, })),
}),
) )
ret = None ret = None
if not test_expected_result(p, expected_result, cols, rows, not attempts): if not test_expected_result(p, expected_result, cols, rows, not attempts):
@ -267,55 +262,38 @@ def main(attempts=3):
sleep(5) sleep(5)
expected_result = get_expected_result( expected_result = get_expected_result(
tmux_version, tmux_version,
expected_result_old=('{1:' + (' ' * cols) + '}', { expected_result_old=('{bg:' + (' ' * cols) + '}', base_attrs),
((255, 255, 255), (11, 11, 11), 0, 0, 0): 1,
}),
expected_result_1_7=( expected_result_1_7=(
'{1: 0 }' '{lead: 0 }'
'{2: }{3: <}{4:h }{3: }{5: }' '{leadsep: }{bg: <}{4:h }{bg: }{5: }'
'{6:2* | }{7:bash }{8: }{3: }{9: }' '{6:2* | }{7:bash }{8: }{bg: }{cwdhsep: }'
'{10: S1 string here }', { '{cwd: S1 string here }', updated(base_attrs, {
((0, 0, 0), (243, 243, 243), 1, 0, 0): 1,
((243, 243, 243), (11, 11, 11), 0, 0, 0): 2,
((255, 255, 255), (11, 11, 11), 0, 0, 0): 3,
((188, 188, 188), (11, 11, 11), 0, 0, 0): 4, ((188, 188, 188), (11, 11, 11), 0, 0, 0): 4,
((11, 11, 11), (0, 102, 153), 0, 0, 0): 5, ((11, 11, 11), (0, 102, 153), 0, 0, 0): 5,
((102, 204, 255), (0, 102, 153), 0, 0, 0): 6, ((102, 204, 255), (0, 102, 153), 0, 0, 0): 6,
((255, 255, 255), (0, 102, 153), 1, 0, 0): 7, ((255, 255, 255), (0, 102, 153), 1, 0, 0): 7,
((0, 102, 153), (11, 11, 11), 0, 0, 0): 8, ((0, 102, 153), (11, 11, 11), 0, 0, 0): 8,
((88, 88, 88), (11, 11, 11), 0, 0, 0): 9, })),
((199, 199, 199), (88, 88, 88), 0, 0, 0): 10,
}),
expected_result_new=( expected_result_new=(
'{1: 0 }' '{lead: 0 }'
'{2: }{3: <}{4:h }{3: }{5: }' '{leadsep: }{bg: <}{4:h }{bg: }{5: }'
'{6:2* | }{7:bash }{4: }{3: }{8: }' '{6:2* | }{7:bash }{4: }{bg: }{cwdhsep: }'
'{9: S1 string here }', { '{cwd: S1 string here }', updated(base_attrs, {
((0, 0, 0), (243, 243, 243), 1, 0, 0): 1,
((243, 243, 243), (11, 11, 11), 0, 0, 0): 2,
((255, 255, 255), (11, 11, 11), 0, 0, 0): 3,
((0, 102, 153), (11, 11, 11), 0, 0, 0): 4, ((0, 102, 153), (11, 11, 11), 0, 0, 0): 4,
((11, 11, 11), (0, 102, 153), 0, 0, 0): 5, ((11, 11, 11), (0, 102, 153), 0, 0, 0): 5,
((102, 204, 255), (0, 102, 153), 0, 0, 0): 6, ((102, 204, 255), (0, 102, 153), 0, 0, 0): 6,
((255, 255, 255), (0, 102, 153), 1, 0, 0): 7, ((255, 255, 255), (0, 102, 153), 1, 0, 0): 7,
((88, 88, 88), (11, 11, 11), 0, 0, 0): 8, })),
((199, 199, 199), (88, 88, 88), 0, 0, 0): 9,
}),
expected_result_2_0=( expected_result_2_0=(
'{1: 0 }' '{lead: 0 }'
'{2: }{3:<}{4:ash }{3: }{5: }' '{leadsep: }{bg:<}{4:ash }{bg: }{5: }'
'{6:2* | }{7:bash }{4: }{8: }' '{6:2* | }{7:bash }{4: }{cwdhsep: }'
'{9: S1 string here }', { '{cwd: S1 string here }', updated(base_attrs, {
((0, 0, 0), (243, 243, 243), 1, 0, 0): 1,
((243, 243, 243), (11, 11, 11), 0, 0, 0): 2,
((255, 255, 255), (11, 11, 11), 0, 0, 0): 3,
((0, 102, 153), (11, 11, 11), 0, 0, 0): 4, ((0, 102, 153), (11, 11, 11), 0, 0, 0): 4,
((11, 11, 11), (0, 102, 153), 0, 0, 0): 5, ((11, 11, 11), (0, 102, 153), 0, 0, 0): 5,
((102, 204, 255), (0, 102, 153), 0, 0, 0): 6, ((102, 204, 255), (0, 102, 153), 0, 0, 0): 6,
((255, 255, 255), (0, 102, 153), 1, 0, 0): 7, ((255, 255, 255), (0, 102, 153), 1, 0, 0): 7,
((88, 88, 88), (11, 11, 11), 0, 0, 0): 8, })),
((199, 199, 199), (88, 88, 88), 0, 0, 0): 9,
}),
) )
if not test_expected_result(p, expected_result, cols, rows, not attempts): if not test_expected_result(p, expected_result, cols, rows, not attempts):
if attempts: if attempts: