Esempio n. 1
0
def test_bossfile_can_filter_out_defined_commands():
    bossfile_mod = make_bossfile_mod()
    # Commands
    bossfile_mod.foo = Command(lambda: 123, name='foo')
    bossfile_mod.bar = Command(lambda: 456, name='bar')
    bossfile_mod.baz = Command(lambda: 789, name='baz')
    # Scalar values
    bossfile_mod.spam = object()
    bossfile_mod.ham = 123
    bossfile_mod.eggs = 'abc'

    bossfile = Bossfile(bossfile_mod)

    assert bossfile.commands() == {'foo': bossfile_mod.foo,
                                   'bar': bossfile_mod.bar,
                                   'baz': bossfile_mod.baz}
Esempio n. 2
0
def test_bossfile_can_filter_out_defined_commands():
    bossfile_mod = make_bossfile_mod()
    # Commands
    bossfile_mod.foo = Command(lambda: 123, name='foo')
    bossfile_mod.bar = Command(lambda: 456, name='bar')
    bossfile_mod.baz = Command(lambda: 789, name='baz')
    # Scalar values
    bossfile_mod.spam = object()
    bossfile_mod.ham = 123
    bossfile_mod.eggs = 'abc'

    bossfile = Bossfile(bossfile_mod)

    assert bossfile.commands() == {
        'foo': bossfile_mod.foo,
        'bar': bossfile_mod.bar,
        'baz': bossfile_mod.baz
    }
Esempio n. 3
0
def main(args=None):
    pre_args, remaining_args = parser.parse_known_args()
    if pre_args.pdb:
        sys.excepthook = lambda *exc_info: pdb.pm()

    try:
        bossfile = Bossfile.load(pre_args.file)
    except Bossfile.LoadingError, exc:
        add_help(global_opts)
        # This will catch any -h/--help options.
        parser.parse_known_args(remaining_args)

        if isinstance(exc, Bossfile.NotFound):
            parser.error("Couldn't locate the Bossfile in the current directory.")

        error = "Error occurred loading the Bossfile:\n"
        for line in traceback.format_exception(*exc.args):
            error += "  " + line
        parser.error(error)