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",