From 64fc3212bad2dba17c54f27f6e7ac7378af31a3e Mon Sep 17 00:00:00 2001 From: Robert O'Shea Date: Sat, 30 Jul 2022 16:40:45 +0100 Subject: [PATCH] Added test to check for UsageError --- testing/test_config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/testing/test_config.py b/testing/test_config.py index c2e3fe5bb..e5eeb7619 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1780,6 +1780,18 @@ def test_help_and_version_after_argument_error(pytester: Pytester) -> None: assert result.ret == ExitCode.USAGE_ERROR +def test_filename_too_long(pytester: Pytester) -> None: + path_str = ( + "this is an extremely long path that should cause the runtime to complain and give" + + " an error of the type UsageError despite make this path pretty long before I" + + " still have to keep going to make sure that this usage error pops so the code" + + " coverage captures it xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + ) + paths = path_str.split(" ") + result = pytester.runpytest(os.path.join(*paths)) + assert result.ret == ExitCode.USAGE_ERROR + + def test_help_formatter_uses_py_get_terminal_width(monkeypatch: MonkeyPatch) -> None: from _pytest.config.argparsing import DropShorterLongHelpFormatter