Skip to content

Commit 2d96bc0

Browse files
committed
Add test for ExtendMatch with multiple flags
Signed-off-by: John Pennycook <john.pennycook@intel.com>
1 parent 2b1650f commit 2d96bc0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/compilers/test_actions.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def test_extend_match_init(self):
7878
def test_extend_match(self):
7979
"""Check that argparse calls store_split correctly"""
8080
namespace = argparse.Namespace()
81-
namespace.passes = {}
8281

8382
parser = argparse.ArgumentParser()
8483
parser.add_argument(
@@ -101,6 +100,13 @@ def test_extend_match(self):
101100
pattern=r"option_(\d+)",
102101
dest="passes",
103102
)
103+
parser.add_argument(
104+
"--one",
105+
"--two",
106+
action=_ExtendMatchAction,
107+
pattern=r"option_(\d+)",
108+
dest="passes",
109+
)
104110

105111
args, _ = parser.parse_known_args(
106112
["--foo=option_1,option_2"],
@@ -117,12 +123,20 @@ def test_extend_match(self):
117123
with self.assertRaises(TypeError):
118124
args, _ = parser.parse_known_args(["--baz=1"], namespace)
119125

126+
namespace.passes = {}
120127
args, _ = parser.parse_known_args(
121128
["--qux=option_1,option_2"],
122129
namespace,
123130
)
124131
self.assertEqual(args.passes, {"--qux": ["1", "2"]})
125132

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+
126140

127141
if __name__ == "__main__":
128142
unittest.main()

0 commit comments

Comments
 (0)