File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ def test_extend_match(self):
99
99
action = _ExtendMatchAction ,
100
100
pattern = r"option_(\d+)" ,
101
101
dest = "passes" ,
102
+ default = ["0" ],
103
+ override = True ,
102
104
)
103
105
parser .add_argument (
104
106
"--one" ,
@@ -123,7 +125,18 @@ def test_extend_match(self):
123
125
with self .assertRaises (TypeError ):
124
126
args , _ = parser .parse_known_args (["--baz=1" ], namespace )
125
127
126
- namespace .passes = {}
128
+ # Check that the default pass defined by --qux always exists.
129
+ # Note that the caller must initialize the default.
130
+ namespace .passes = {"--qux" : ["0" ]}
131
+ args , _ = parser .parse_known_args (
132
+ [],
133
+ namespace ,
134
+ )
135
+ self .assertEqual (args .passes , {"--qux" : ["0" ]})
136
+
137
+ # Check that the default pass is overridden by use of --qux.
138
+ # Note that the caller must initialize the default.
139
+ namespace .passes = {"--qux" : ["0" ]}
127
140
args , _ = parser .parse_known_args (
128
141
["--qux=option_1,option_2" ],
129
142
namespace ,
@@ -137,6 +150,8 @@ def test_extend_match(self):
137
150
)
138
151
self .assertEqual (args .passes , {"--one" : ["1" , "2" ]})
139
152
153
+ namespace .passes = {}
154
+
140
155
141
156
if __name__ == "__main__" :
142
157
unittest .main ()
You can’t perform that action at this time.
0 commit comments