Exemple #1
0
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()
Exemple #2
0
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()
Exemple #3
0
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()
Exemple #4
0
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()
Exemple #5
0
 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
Exemple #6
0
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()
Exemple #7
0
 def __init__(self,
              transformer=IdentityTransformer(),
              encoding=sys.getdefaultencoding()):
     self.transformer = transformer
     self.encoding = encoding
Exemple #8
0
def test_identity():
    assert IdentityTransformer().transform("test") == "test"
Exemple #9
0
def test_transformer_identity_eq():
    assert IdentityTransformer() == IdentityTransformer()
Exemple #10
0
def test_transformer_identity_str():
    assert IdentityTransformer().__str__() == 'identity'
Exemple #11
0
def test_empty_args():
    (command, errors) = parse([])
    assert not errors
    assert isinstance(command, STDINCommand)
    assert command.transformer == IdentityTransformer()