File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 11"""Test case for issue #13817: AttributeError with invalid flag in pytest_addoption."""
2-
32from __future__ import annotations
43
54from _pytest .config .argparsing import ArgumentError
5+ from _pytest .config .argparsing import NOT_SET
66from _pytest .config .argparsing import Parser
77import pytest
88
@@ -63,3 +63,17 @@ def test_repr_with_dest_set(self) -> None:
6363 # Should contain the dest
6464 assert "dest: 'valid_dest'" in repr_str
6565 assert "NOT_SET" not in repr_str
66+
67+ def test_repr_without_dest (self ) -> None :
68+ """Test that __repr__ works when dest is not set due to error."""
69+ from _pytest .config .argparsing import Argument
70+
71+ # Create an Argument that will fail during initialization
72+ # This triggers the code path where dest is not set
73+ try :
74+ Argument ("invalid" ) # No dashes, will fail
75+ except ArgumentError as exc :
76+ # The repr was called during error creation
77+ # Verify it contains NOT_SET representation
78+ assert "dest:" in str (exc )
79+ assert "NOT_SET" in str (exc ) or "<notset>" in str (exc )
You can’t perform that action at this time.
0 commit comments