-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: deprecate outdated constant * docs: list deprecated items * test: cover argh.assembling.add_subcommands() * test: cover overrides in add_commands() * test: 100% coverage for assembling and interaction * feat: deprecate `safe_input()` The function used to be helpful in the py2/py3 world with all the bytes vs Unicode strings mess. In 2023 this is not relevant anymore. * docs: deprecation of `dispatch(..., pre_call=...)` This is not in fact deprecation per se but merely an attempt to draw attention to a fact that was mentioned almost ten years ago in the discussion (#63): the `pre_call` argument in `dispatch()` is not a feature but a hack which is not recommended and will be removed. This commit makes it clear when precisely it is going to be removed and what actions are expected from the user. * test: 100% coverage of dispatching * chore: drop the old encoding declaration Let's just agree that it's 2023 and move on. * test: 100% coverage of completion * test: require 100% coverage
- Loading branch information
Showing
21 changed files
with
497 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding: utf-8 | ||
# | ||
# Copyright © 2010—2023 Andrey Mikhaylenko and contributors | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding: utf-8 | ||
# | ||
# Copyright © 2010—2023 Andrey Mikhaylenko and contributors | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding: utf-8 | ||
# | ||
# Copyright © 2010—2023 Andrey Mikhaylenko and contributors | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding: utf-8 | ||
# | ||
# Copyright © 2010—2023 Andrey Mikhaylenko and contributors | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding: utf-8 | ||
""" | ||
Common stuff for tests | ||
~~~~~~~~~~~~~~~~~~~~~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Unit Tests For Autocompletion | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
""" | ||
from unittest.mock import patch | ||
|
||
import argh | ||
|
||
|
||
@patch("argh.completion.COMPLETION_ENABLED", True) | ||
@patch("argh.completion.argcomplete") | ||
def test_enabled(mock_argcomplete): | ||
parser = argh.ArghParser() | ||
|
||
parser.autocomplete() | ||
|
||
mock_argcomplete.autocomplete.assert_called_with(parser) | ||
|
||
|
||
@patch("argh.completion.COMPLETION_ENABLED", False) | ||
@patch("argh.completion.argcomplete") | ||
@patch("argh.completion.logger") | ||
def test_disabled_without_bash(mock_logger, mock_argcomplete): | ||
parser = argh.ArghParser() | ||
|
||
parser.autocomplete() | ||
|
||
mock_argcomplete.assert_not_called() | ||
mock_logger.debug.assert_not_called() | ||
|
||
|
||
@patch("argh.completion.COMPLETION_ENABLED", False) | ||
@patch("argh.completion.argcomplete") | ||
@patch("argh.completion.os.getenv") | ||
@patch("argh.completion.logger") | ||
def test_disabled_with_bash(mock_logger, mock_getenv, mock_argcomplete): | ||
mock_getenv.return_value = "/bin/bash" | ||
parser = argh.ArghParser() | ||
|
||
parser.autocomplete() | ||
|
||
mock_argcomplete.assert_not_called() | ||
mock_getenv.assert_called_with("SHELL", "") | ||
mock_logger.debug.assert_called_with( | ||
"Bash completion is not available. Please install argcomplete." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding: utf-8 | ||
""" | ||
Unit Tests For Decorators | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
Oops, something went wrong.