def test_lscolors_events(key_in, old_in, new_in, test, xonsh_builtins): lsc = LsColors.fromstring("rs=0:di=01;34:pi=40;33") # corresponding colors: [('NO_COLOR',), ('BOLD_CYAN',), ('BOLD_CYAN',), ('BACKGROUND_BLACK', 'YELLOW')] event_fired = False @xonsh_builtins.events.on_lscolors_change def handler(key, oldvalue, newvalue, **kwargs): nonlocal old_in, new_in, key_in, event_fired assert ( key == key_in and oldvalue == old_in and newvalue == new_in ), "Old and new event values match" event_fired = True xonsh_builtins.__xonsh__.env["LS_COLORS"] = lsc if new_in is None: old = lsc.pop(key_in, "argle") else: lsc[key_in] = new_in if old_in == new_in: assert not event_fired, "No event if value doesn't change" else: assert event_fired
def test_lscolors_target(xonsh_builtins): lsc = LsColors.fromstring("ln=target") assert lsc["ln"] == ("NO_COLOR", ) assert lsc.is_target("ln") assert lsc.detype() == "ln=target" assert not (lsc.is_target("mi"))
def test_lscolors_target(): lsc = LsColors.fromstring("ln=target") assert lsc["ln"] == ("TARGET",) assert lsc.detype() == "ln=target"
def test_lscolors_target(xession): lsc = LsColors.fromstring("ln=target") assert lsc["ln"] == ("RESET", ) assert lsc.is_target("ln") assert lsc.detype() == "ln=target" assert not (lsc.is_target("mi"))