gh-138970: Adjust tests for pegen rule flags (#139107)

This commit is contained in:
Petr Viktorin 2025-09-18 13:08:44 +02:00 committed by GitHub
parent 49f1c302df
commit 36ec60fb43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1131,24 +1131,28 @@ def test_rule_flags(self) -> None:
# Test memo-only rule
simple_rule = rules['simple_rule']
self.assertTrue(simple_rule.memo, "simple_rule should have memo=True")
self.assertTrue('memo' in simple_rule.flags,
"simple_rule should have memo")
self.assertEqual(simple_rule.flags, frozenset(['memo']),
f"simple_rule flags should be {'memo'}, got {simple_rule.flags}")
# Test multi-flag rule
multi_flag_rule = rules['multi_flag_rule']
self.assertTrue(multi_flag_rule.memo, "multi_flag_rule should have memo=True")
self.assertTrue('memo' in simple_rule.flags,
"multi_flag_rule should have memo")
self.assertEqual(multi_flag_rule.flags, frozenset({'memo', 'custom', 'test'}),
f"multi_flag_rule flags should contain memo, custom, test, got {multi_flag_rule.flags}")
# Test single custom flag rule
single_custom_rule = rules['single_custom_flag']
self.assertFalse(single_custom_rule.memo, "single_custom_flag should have memo=False")
self.assertFalse('memo' not in simple_rule.flags,
"single_custom_flag should not have memo")
self.assertEqual(single_custom_rule.flags, frozenset(['custom']),
f"single_custom_flag flags should be {'custom'}, got {single_custom_rule.flags}")
# Test no flags rule
no_flags_rule = rules['no_flags_rule']
self.assertFalse(no_flags_rule.memo, "no_flags_rule should have memo=False")
self.assertEqual(no_flags_rule.flags, [],
self.assertFalse('memo' not in simple_rule.flags,
"no_flags_rule should not have memo")
self.assertEqual(no_flags_rule.flags, frozenset(),
f"no_flags_rule flags should be the empty set, got {no_flags_rule.flags}")