From d6a17df3e6f77fbe534707869ac3df1354a2b125 Mon Sep 17 00:00:00 2001 From: Robert O'Shea Date: Sat, 30 Jul 2022 21:51:08 +0100 Subject: [PATCH] Updated tests for config to get more code coverage --- testing/test_config.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/testing/test_config.py b/testing/test_config.py index e5eeb7619..e796915b7 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1782,13 +1782,21 @@ def test_help_and_version_after_argument_error(pytester: Pytester) -> None: 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" + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ) - paths = path_str.split(" ") - result = pytester.runpytest(os.path.join(*paths)) + config = pytester.parseconfig() + config.known_args_namespace.file_or_dir.append(path_str) + pytest.raises( + UsageError, + config.pluginmanager._set_initial_conftests, + config.known_args_namespace, + rootpath=config.rootpath, + ) + result = pytester.runpytest(path_str) assert result.ret == ExitCode.USAGE_ERROR