Skip to content

Commit a6ba12b

Browse files
committed
Add test of override option for ExtendMatch
Signed-off-by: John Pennycook <john.pennycook@intel.com>
1 parent f1806b1 commit a6ba12b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/compilers/test_actions.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ def test_extend_match(self):
9999
action=_ExtendMatchAction,
100100
pattern=r"option_(\d+)",
101101
dest="passes",
102+
default=["0"],
103+
override=True,
102104
)
103105
parser.add_argument(
104106
"--one",
@@ -123,7 +125,18 @@ def test_extend_match(self):
123125
with self.assertRaises(TypeError):
124126
args, _ = parser.parse_known_args(["--baz=1"], namespace)
125127

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"]}
127140
args, _ = parser.parse_known_args(
128141
["--qux=option_1,option_2"],
129142
namespace,
@@ -137,6 +150,8 @@ def test_extend_match(self):
137150
)
138151
self.assertEqual(args.passes, {"--one": ["1", "2"]})
139152

153+
namespace.passes = {}
154+
140155

141156
if __name__ == "__main__":
142157
unittest.main()

0 commit comments

Comments
 (0)