@@ -1200,96 +1200,6 @@ def test_help_via_addopts(testdir):
1200
1200
)
1201
1201
1202
1202
1203
- def test_help_and_version_after_argument_error (testdir ):
1204
- testdir .makeconftest (
1205
- """
1206
- def validate(arg):
1207
- raise argparse.ArgumentTypeError("argerror")
1208
-
1209
- def pytest_addoption(parser):
1210
- group = parser.getgroup('cov')
1211
- group.addoption(
1212
- "--invalid-option-should-allow-for-help",
1213
- type=validate,
1214
- )
1215
- """
1216
- )
1217
- testdir .makeini (
1218
- """
1219
- [pytest]
1220
- addopts = --invalid-option-should-allow-for-help
1221
- """
1222
- )
1223
- result = testdir .runpytest ("--help" )
1224
- result .stdout .fnmatch_lines (
1225
- [
1226
- "usage: *" ,
1227
- "positional arguments:" ,
1228
- "NOTE: displaying only minimal help due to UsageError." ,
1229
- ]
1230
- )
1231
- result .stderr .fnmatch_lines (
1232
- [
1233
- "ERROR: usage: *" ,
1234
- "%s: error: argument --invalid-option-should-allow-for-help: expected one argument"
1235
- % (testdir .request .config ._parser .optparser .prog ,),
1236
- ]
1237
- )
1238
- # Does not display full/default help.
1239
- assert "to see available markers type: pytest --markers" not in result .stdout .lines
1240
- assert result .ret == ExitCode .USAGE_ERROR
1241
-
1242
- result = testdir .runpytest ("--version" )
1243
- result .stderr .fnmatch_lines (["pytest {}" .format (pytest .__version__ )])
1244
- assert result .ret == ExitCode .USAGE_ERROR
1245
-
1246
-
1247
- def test_help_and_version_verbose_after_argument_error (testdir ):
1248
- testdir .makeconftest (
1249
- """
1250
- def validate(arg):
1251
- raise argparse.ArgumentTypeError("argerror")
1252
-
1253
- def pytest_addoption(parser):
1254
- group = parser.getgroup('cov')
1255
- group.addoption(
1256
- "--invalid-option-should-allow-for-help",
1257
- type=validate,
1258
- )
1259
- """
1260
- )
1261
- testdir .makeini (
1262
- """
1263
- [pytest]
1264
- addopts = --invalid-option-should-allow-for-help
1265
- """
1266
- )
1267
- result = testdir .runpytest ("--help" )
1268
- result .stdout .fnmatch_lines (
1269
- [
1270
- "usage: *" ,
1271
- "positional arguments:" ,
1272
- "NOTE: displaying only minimal help due to UsageError." ,
1273
- ]
1274
- )
1275
- result .stderr .fnmatch_lines (
1276
- [
1277
- "ERROR: usage: *" ,
1278
- "%s: error: argument --invalid-option-should-allow-for-help: expected one argument"
1279
- % (testdir .request .config ._parser .optparser .prog ,),
1280
- ]
1281
- )
1282
- # Does not display full/default help.
1283
- assert "to see available markers type: pytest --markers" not in result .stdout .lines
1284
- assert result .ret == ExitCode .USAGE_ERROR
1285
-
1286
- result = testdir .runpytest ("--version" , "--version" )
1287
- result .stderr .fnmatch_lines (
1288
- ["*pytest*{}*imported from*" .format (pytest .__version__ )]
1289
- )
1290
- assert result .ret == ExitCode .USAGE_ERROR
1291
-
1292
-
1293
1203
def test_help_formatter_uses_py_get_terminal_width (monkeypatch ):
1294
1204
from _pytest .config .argparsing import DropShorterLongHelpFormatter
1295
1205
0 commit comments