@@ -78,7 +78,6 @@ def test_extend_match_init(self):
78
78
def test_extend_match (self ):
79
79
"""Check that argparse calls store_split correctly"""
80
80
namespace = argparse .Namespace ()
81
- namespace .passes = {}
82
81
83
82
parser = argparse .ArgumentParser ()
84
83
parser .add_argument (
@@ -101,6 +100,13 @@ def test_extend_match(self):
101
100
pattern = r"option_(\d+)" ,
102
101
dest = "passes" ,
103
102
)
103
+ parser .add_argument (
104
+ "--one" ,
105
+ "--two" ,
106
+ action = _ExtendMatchAction ,
107
+ pattern = r"option_(\d+)" ,
108
+ dest = "passes" ,
109
+ )
104
110
105
111
args , _ = parser .parse_known_args (
106
112
["--foo=option_1,option_2" ],
@@ -117,12 +123,20 @@ def test_extend_match(self):
117
123
with self .assertRaises (TypeError ):
118
124
args , _ = parser .parse_known_args (["--baz=1" ], namespace )
119
125
126
+ namespace .passes = {}
120
127
args , _ = parser .parse_known_args (
121
128
["--qux=option_1,option_2" ],
122
129
namespace ,
123
130
)
124
131
self .assertEqual (args .passes , {"--qux" : ["1" , "2" ]})
125
132
133
+ namespace .passes = {}
134
+ args , _ = parser .parse_known_args (
135
+ ["--one=option_1" , "--two=option_2" ],
136
+ namespace ,
137
+ )
138
+ self .assertEqual (args .passes , {"--one" : ["1" , "2" ]})
139
+
126
140
127
141
if __name__ == "__main__" :
128
142
unittest .main ()
0 commit comments