@@ -20,18 +20,36 @@ def test_changing_the_kwlist_does_not_affect_iskeyword(self):
20
20
keyword .kwlist = ['its' , 'all' , 'eggs' , 'beans' , 'and' , 'a' , 'slice' ]
21
21
self .assertFalse (keyword .iskeyword ('eggs' ))
22
22
23
+ def test_changing_the_softkwlist_does_not_affect_issoftkeyword (self ):
24
+ oldlist = keyword .softkwlist
25
+ self .addCleanup (setattr , keyword , "softkwlist" , oldlist )
26
+ keyword .softkwlist = ["foo" , "bar" , "spam" , "egs" , "case" ]
27
+ self .assertFalse (keyword .issoftkeyword ("spam" ))
28
+
23
29
def test_all_keywords_fail_to_be_used_as_names (self ):
24
30
for key in keyword .kwlist :
25
31
with self .assertRaises (SyntaxError ):
26
32
exec (f"{ key } = 42" )
27
33
34
+ def test_all_soft_keywords_can_be_used_as_names (self ):
35
+ for key in keyword .softkwlist :
36
+ exec (f"{ key } = 42" )
37
+
28
38
def test_async_and_await_are_keywords (self ):
29
39
self .assertIn ("async" , keyword .kwlist )
30
40
self .assertIn ("await" , keyword .kwlist )
31
41
42
+ def test_match_and_case_are_soft_keywords (self ):
43
+ self .assertIn ("match" , keyword .softkwlist )
44
+ self .assertIn ("case" , keyword .softkwlist )
45
+ self .assertIn ("_" , keyword .softkwlist )
46
+
32
47
def test_keywords_are_sorted (self ):
33
48
self .assertListEqual (sorted (keyword .kwlist ), keyword .kwlist )
34
49
50
+ def test_softkeywords_are_sorted (self ):
51
+ self .assertListEqual (sorted (keyword .softkwlist ), keyword .softkwlist )
52
+
35
53
36
54
if __name__ == "__main__" :
37
55
unittest .main ()
0 commit comments