From 2fb06f2dbf68fbb2de096dfe52583c068f779818 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 7 Sep 2023 09:53:03 -0300 Subject: [PATCH] Fix crash when passing a very long cmdline argument Fixes #11394 --- testing/test_main.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/testing/test_main.py b/testing/test_main.py index 71597626790..a3dffbbc953 100644 --- a/testing/test_main.py +++ b/testing/test_main.py @@ -262,3 +262,27 @@ def test(fix): "* 1 passed in *", ] ) + + +def test_very_long_cmdline_arg(pytester: Pytester) -> None: + pytester.makeconftest( + """ + import pytest + + def pytest_addoption(parser): + parser.addoption("--long-list", dest="long_list", action="store", default="all", help="List of things") + + @pytest.fixture(scope="module") + def specified_feeds(request): + list_string = request.config.getoption("--long-list") + return list_string.split(',') + """ + ) + pytester.makepyfile( + """ + def test_foo(specified_feeds): + assert len(specified_feeds) == 100 + """ + ) + result = pytester.runpytest("--long-list", ",".join(["helloworld"] * 100)) + result.stdout.fnmatch_lines("* 1 passed *")