From 5e26675c06f3635df2f1b17c72957c07ec407493 Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Fri, 5 Jun 2020 12:20:31 -0700 Subject: [PATCH] add no_color test --- tests/test_main.py | 9 +++++++++ twine/__main__.py | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index 12808670..8308d061 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -10,6 +10,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys + import colorama import pretend @@ -25,3 +27,10 @@ def test_exception_handling(monkeypatch): dunder_main.main() == colorama.Fore.RED + "InvalidConfiguration: foo" + colorama.Style.RESET_ALL ) + + +def test_no_color_exception(monkeypatch): + replaced_dispatch = pretend.raiser(exceptions.InvalidConfiguration("foo")) + monkeypatch.setattr(cli, "dispatch", replaced_dispatch) + monkeypatch.setattr(sys, "argv", ["upload", "--no_color"]) + assert dunder_main.main() == "InvalidConfiguration: foo" diff --git a/twine/__main__.py b/twine/__main__.py index 1ccaa5ac..9e878c9b 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -27,7 +27,6 @@ def main() -> Any: try: return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: - # somehow parse args here parser = argparse.ArgumentParser() parser.add_argument( "--no_color", default=False, required=False, action="store_true",