Ejemplo n.º 1
0
    def core_help_option_prints_core_help(self):
        # TODO: change dynamically based on parser contents?
        # e.g. no core args == no [--core-opts],
        # no tasks == no task stuff?
        # NOTE: test will trigger default pty size of 80x24, so the below
        # string is formatted appropriately.
        # TODO: add more unit-y tests for specific behaviors:
        # * fill terminal w/ columns + spacing
        # * line-wrap help text in its own column
        expected = """
Usage: inv[oke] [--core-opts] task1 [--task1-opts] ... taskN [--taskN-opts]

Core options:
  --no-dedupe                      Disable task deduplication.
  -c STRING, --collection=STRING   Specify collection name to load.
  -d, --debug                      Enable debug output.
  -e, --echo                       Echo executed commands before running.
  -f STRING, --config=STRING       Runtime configuration file to use.
  -h [STRING], --help[=STRING]     Show core or per-task help and exit.
  -H STRING, --hide=STRING         Set default value of run()'s 'hide' kwarg.
  -l, --list                       List available tasks.
  -p, --pty                        Use a pty when executing shell commands.
  -r STRING, --root=STRING         Change root directory used for finding task
                                   modules.
  -V, --version                    Show version and exit.
  -w, --warn-only                  Warn, instead of failing, when shell
                                   commands fail.

""".lstrip()
        for flag in ['-h', '--help']:
            _output_eq(flag, expected)
Ejemplo n.º 2
0
        def core_help_option_prints_core_help(self):
            # TODO: change dynamically based on parser contents?
            # e.g. no core args == no [--core-opts],
            # no tasks == no task stuff?
            # NOTE: test will trigger default pty size of 80x24, so the below
            # string is formatted appropriately.
            # TODO: add more unit-y tests for specific behaviors:
            # * fill terminal w/ columns + spacing
            # * line-wrap help text in its own column
            expected = """
Usage: inv[oke] [--core-opts] task1 [--task1-opts] ... taskN [--taskN-opts]

Core options:
  --complete                       Print tab-completion candidates for given
                                   parse remainder.
  --no-dedupe                      Disable task deduplication.
  -c STRING, --collection=STRING   Specify collection name to load.
  -d, --debug                      Enable debug output.
  -e, --echo                       Echo executed commands before running.
  -f STRING, --config=STRING       Runtime configuration file to use.
  -h [STRING], --help[=STRING]     Show core or per-task help and exit.
  -H STRING, --hide=STRING         Set default value of run()'s 'hide' kwarg.
  -l, --list                       List available tasks.
  -p, --pty                        Use a pty when executing shell commands.
  -r STRING, --root=STRING         Change root directory used for finding task
                                   modules.
  -V, --version                    Show version and exit.
  -w, --warn-only                  Warn, instead of failing, when shell
                                   commands fail.

""".lstrip()
            for flag in ['-h', '--help']:
                _output_eq(flag, expected)
Ejemplo n.º 3
0
        def tasks_dedupe_honors_configuration(self):
            # Kinda-sorta duplicates some tests in executor.py, but eh.
            with cd('configs'):
                # Runtime conf file
                _output_eq(
                    '-c integration -f no-dedupe.yaml biz',
                    """
foo
foo
bar
biz
post1
post2
post2
""".lstrip())
                # Flag beats runtime
                _output_eq(
                    '-c integration -f dedupe.yaml --no-dedupe biz',
                    """
foo
foo
bar
biz
post1
post2
post2
""".lstrip())
Ejemplo n.º 4
0
 def missing_default_collection_doesnt_say_None(self):
     with cd('/'):
         _output_eq(
             '-l',
             stderr="Can't find any collection named 'tasks'!\n",
             code=1
         )
Ejemplo n.º 5
0
        def chaining_is_depth_first(self):
            _output_eq('-c depth_first deploy', """
Cleaning HTML
Cleaning .tar.gz files
Cleaned everything
Making directories
Building
Deploying
Preparing for testing
Testing
""".lstrip())
Ejemplo n.º 6
0
        def chaining_is_depth_first(self):
            _output_eq('-c depth_first deploy', """
Cleaning HTML
Cleaning .tar.gz files
Cleaned everything
Making directories
Building
Deploying
Preparing for testing
Testing
""".lstrip())
Ejemplo n.º 7
0
        def per_task_help_works_for_unparameterized_tasks(self):
            expected = """
Usage: inv[oke] [--core-opts] biz [other tasks here ...]

Docstring:
  none

Options:
  none

""".lstrip()
            _output_eq('-c decorator -h biz', expected)
Ejemplo n.º 8
0
    def per_task_help_displays_docstrings_if_given(self):
        expected = """
Usage: inv[oke] [--core-opts] foo [other tasks here ...]

Docstring:
  Foo the bar.

Options:
  none

""".lstrip()
        _output_eq('-c decorator -h foo', expected)
Ejemplo n.º 9
0
        def per_task_help_displays_docstrings_if_given(self):
            expected = """
Usage: inv[oke] [--core-opts] foo [other tasks here ...]

Docstring:
  Foo the bar.

Options:
  none

""".lstrip()
            _output_eq('-c decorator -h foo', expected)
Ejemplo n.º 10
0
    def per_task_help_works_for_unparameterized_tasks(self):
        expected = """
Usage: inv[oke] [--core-opts] biz [other tasks here ...]

Docstring:
  none

Options:
  none

""".lstrip()
        _output_eq('-c decorator -h biz', expected)
Ejemplo n.º 11
0
        def per_task_help_prints_help_for_task_only(self):
            expected = """
Usage: inv[oke] [--core-opts] punch [--options] [other tasks here ...]

Docstring:
  none

Options:
  -h STRING, --why=STRING   Motive
  -w STRING, --who=STRING   Who to punch

""".lstrip()
            for flag in ['-h', '--help']:
                _output_eq('-c decorator {0} punch'.format(flag), expected)
Ejemplo n.º 12
0
 def simple_output(self):
     expected = self._listing((
         'bar',
         'biz',
         'boz',
         'foo',
         'post1',
         'post2',
         'print_foo',
         'print_name',
         'print_underscored_arg',
     ))
     for flag in ('-l', '--list'):
         _output_eq('-c integration {0}'.format(flag), expected)
Ejemplo n.º 13
0
 def simple_output(self):
     expected = self._listing((
         'bar',
         'biz',
         'boz',
         'foo',
         'post1',
         'post2',
         'print_foo',
         'print_name',
         'print_underscored_arg',
     ))
     for flag in ('-l', '--list'):
         _output_eq('-c integration {0}'.format(flag), expected)
Ejemplo n.º 14
0
    def per_task_help_prints_help_for_task_only(self):
        expected = """
Usage: inv[oke] [--core-opts] punch [--options] [other tasks here ...]

Docstring:
  none

Options:
  -h STRING, --why=STRING   Motive
  -w STRING, --who=STRING   Who to punch

""".lstrip()
        for flag in ['-h', '--help']:
            _output_eq('-c decorator {0} punch'.format(flag), expected)
Ejemplo n.º 15
0
    def per_task_help_dedents_correctly_for_alternate_docstring_style(self):
        expected = """
Usage: inv[oke] [--core-opts] foo3 [other tasks here ...]

Docstring:
  Foo the other bar:

    example code

  Added in 1.1

Options:
  none

""".lstrip()
        _output_eq('-c decorator -h foo3', expected)
Ejemplo n.º 16
0
    def per_task_help_dedents_correctly(self):
        expected = """
Usage: inv[oke] [--core-opts] foo2 [other tasks here ...]

Docstring:
  Foo the bar:

    example code

  Added in 1.0

Options:
  none

""".lstrip()
        _output_eq('-c decorator -h foo2', expected)
Ejemplo n.º 17
0
        def per_task_help_dedents_correctly_for_alt_docstring_style(self):
            expected = """
Usage: inv[oke] [--core-opts] foo3 [other tasks here ...]

Docstring:
  Foo the other bar:

    example code

  Added in 1.1

Options:
  none

""".lstrip()
            _output_eq('-c decorator -h foo3', expected)
Ejemplo n.º 18
0
        def per_task_help_dedents_correctly(self):
            expected = """
Usage: inv[oke] [--core-opts] foo2 [other tasks here ...]

Docstring:
  Foo the bar:

    example code

  Added in 1.0

Options:
  none

""".lstrip()
            _output_eq('-c decorator -h foo2', expected)
Ejemplo n.º 19
0
        def tasks_dedupe_honors_configuration(self):
            # Kinda-sorta duplicates some tests in executor.py, but eh.
            with cd('configs'):
                # Runtime conf file
                _output_eq('-c integration -f no-dedupe.yaml biz', """foo
foo
bar
biz
post1
post2
post2
""")
                # Flag beats runtime
                _output_eq('-c integration -f dedupe.yaml --no-dedupe biz',
                           """foo
foo
bar
biz
post1
post2
post2
""")
Ejemplo n.º 20
0
 def empty_collections_say_no_tasks(self):
     _output_eq("-c empty -l",
                "No tasks found in collection 'empty'!\n")
Ejemplo n.º 21
0
Archivo: cli.py Proyecto: B-Rich/invoke
 def missing_default_collection_doesnt_say_None(self):
     os.chdir('/')
     _output_eq('-l', stderr="Can't find any collection named 'tasks'!\n")
Ejemplo n.º 22
0
Archivo: cli.py Proyecto: B-Rich/invoke
 def version_info(self):
     _output_eq('-V', "Invoke %s\n" % invoke.__version__)
Ejemplo n.º 23
0
 def _expect(self, args, expected):
     _output_eq('-c integration {0}'.format(args), expected.lstrip())
Ejemplo n.º 24
0
Archivo: cli.py Proyecto: melor/invoke
 def version_info(self):
     _output_eq('-V', "Invoke {0}\n".format(invoke.__version__))
Ejemplo n.º 25
0
 def prints_return_value_to_stdout_when_on_and_in_collection(self):
     _output_eq("-c autoprint sub.yup", "It's alive!\n")
Ejemplo n.º 26
0
 def prints_return_value_to_stdout_when_on_and_in_collection(self):
     _output_eq("-c autoprint sub.yup", "It's alive!\n")
Ejemplo n.º 27
0
 def defaults_to_off_and_no_output(self):
     _output_eq("-c autoprint nope", "")
Ejemplo n.º 28
0
 def defaults_to_off_and_no_output(self):
     _output_eq("-c autoprint nope", "")
Ejemplo n.º 29
0
 def version_info(self):
     _output_eq('-V', "Invoke {0}\n".format(invoke.__version__))
Ejemplo n.º 30
0
 def does_not_fire_on_post_tasks(self):
     _output_eq("-c autoprint post_check", "")
Ejemplo n.º 31
0
 def _list_eq(self, collection, listing):
     cmd = '-c {0} --list'.format(collection)
     _output_eq(cmd, self._listing(listing))
Ejemplo n.º 32
0
 def no_input_means_just_task_names(self):
     _output_eq('-c simple_ns_list --complete', "z_toplevel\na.b.subtask\n")
Ejemplo n.º 33
0
 def version_info(self):
     _output_eq('-V', "Invoke %s\n" % invoke.__version__)
Ejemplo n.º 34
0
 def underscored_args(self):
     _output_eq(
         '-c integration print_underscored_arg --my-option whatevs',
         "whatevs\n",
     )
Ejemplo n.º 35
0
 def args(self):
     _output_eq('-c integration print_name --name inigo', "inigo\n")
Ejemplo n.º 36
0
 def prints_return_value_to_stdout_when_on(self):
     _output_eq("-c autoprint yup", "It's alive!\n")
Ejemplo n.º 37
0
 def _list_eq(self, collection, listing):
     cmd = '-c {0} --list'.format(collection)
     _output_eq(cmd, self._listing(listing))
Ejemplo n.º 38
0
 def underscored_args(self):
     _output_eq(
         '-c integration print_underscored_arg --my-option whatevs',
         "whatevs\n",
     )
Ejemplo n.º 39
0
 def empty_collections_say_no_tasks(self):
     _output_eq(
         "-c empty -l",
         "No tasks found in collection 'empty'!\n"
     )
Ejemplo n.º 40
0
 def missing_collection_yields_useful_error(self):
     _output_eq('-c huhwhat -l',
                stderr="Can't find any collection named 'huhwhat'!\n",
                code=1)
Ejemplo n.º 41
0
 def prints_return_value_to_stdout_when_on(self):
     _output_eq("-c autoprint yup", "It's alive!\n")
Ejemplo n.º 42
0
 def missing_default_collection_doesnt_say_None(self):
     with cd('/'):
         _output_eq('-l',
                    stderr="Can't find any collection named 'tasks'!\n",
                    code=1)
Ejemplo n.º 43
0
 def does_not_fire_on_post_tasks(self):
     _output_eq("-c autoprint post_check", "")
Ejemplo n.º 44
0
Archivo: cli.py Proyecto: vhbit/invoke
 def missing_default_collection_doesnt_say_None(self):
     os.chdir('/')
     _output_eq('-l', stderr="Can't find any collection named 'tasks'!\n")
Ejemplo n.º 45
0
 def args(self):
     _output_eq('-c integration print_name --name inigo', "inigo\n")
Ejemplo n.º 46
0
 def _expect(self, args, expected):
     _output_eq('-c integration {0}'.format(args), expected.lstrip())
Ejemplo n.º 47
0
 def missing_collection_yields_useful_error(self):
     _output_eq(
         '-c huhwhat -l',
         stderr="Can't find any collection named 'huhwhat'!\n",
         code=1
     )
Ejemplo n.º 48
0
 def no_input_means_just_task_names(self):
     _output_eq('-c simple_ns_list --complete', "z_toplevel\na.b.subtask\n")
Ejemplo n.º 49
0
 def no_input_with_no_tasks_yields_empty_response(self):
     _output_eq('-c empty --complete', "")
Ejemplo n.º 50
0
 def no_input_with_no_tasks_yields_empty_response(self):
     _output_eq('-c empty --complete', "")