def test_command(): (command, errors) = parse(['true']) assert not errors assert isinstance(command, ExecuteCommand) assert command.args == ['true'] assert command.stdout_transformer == IdentityTransformer() assert command.stderr_transformer == IdentityTransformer()
def test_command_with_same_option_as_rainbow_remaining_args_separator(): (command, errors) = parse(['command', '--red', 'test']) assert not errors assert isinstance(command, ExecuteCommand) assert command.args == ['command', '--red', 'test'] assert command.stdout_transformer == IdentityTransformer() assert command.stderr_transformer == IdentityTransformer()
def test_command_that_looks_like_a_long_option_remaining_args_separator(): (command, errors) = parse(['--', '--true']) assert not errors assert isinstance(command, ExecuteCommand) assert command.args == ['--true'] assert command.stdout_transformer == IdentityTransformer() assert command.stderr_transformer == IdentityTransformer()
def test_command_that_looks_like_a_short_option(): (command, errors) = parse(['-a']) assert not errors assert isinstance(command, ExecuteCommand) assert command.args == ['-a'] assert command.stdout_transformer == IdentityTransformer() assert command.stderr_transformer == IdentityTransformer()
def __init__(self, args, stdout_transformer=IdentityTransformer(), stderr_transformer=IdentityTransformer(), encoding=sys.getdefaultencoding()): self.args = args self.stdout_transformer = stdout_transformer self.stderr_transformer = stderr_transformer self.encoding = encoding
def test_dummy_transfomer_builder(): (command, errors) = parse(['true'], stdout_builder=DummyTransformerBuilder(), stderr_builder=DummyTransformerBuilder()) assert not errors assert isinstance(command, ExecuteCommand) assert command.args == ['true'] assert command.stdout_transformer == IdentityTransformer() assert command.stderr_transformer == IdentityTransformer()
def __init__(self, transformer=IdentityTransformer(), encoding=sys.getdefaultencoding()): self.transformer = transformer self.encoding = encoding
def test_identity(): assert IdentityTransformer().transform("test") == "test"
def test_transformer_identity_eq(): assert IdentityTransformer() == IdentityTransformer()
def test_transformer_identity_str(): assert IdentityTransformer().__str__() == 'identity'
def test_empty_args(): (command, errors) = parse([]) assert not errors assert isinstance(command, STDINCommand) assert command.transformer == IdentityTransformer()