mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Test syntax error on comma-less tuple-style sequence patterns (#115485)
Adds a test that length-1 tuple-style sequence patterns must end in a comma, since there isn't currently one. Spotted while reviewing Cython's proposed implementation of the pattern matching syntax (https://github.com/cython/cython/pull/4897#discussion_r1489177169) where there was a bug my the reimplementation that wasn't caught against the CPython tests here.
This commit is contained in:
		
							parent
							
								
									fc7e1aa3c0
								
							
						
					
					
						commit
						21c09d9f81
					
				
					 1 changed files with 8 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -2957,6 +2957,14 @@ def test_invalid_syntax_3(self):
 | 
			
		|||
                pass
 | 
			
		||||
        """)
 | 
			
		||||
 | 
			
		||||
    def test_len1_tuple_sequence_pattern_comma(self):
 | 
			
		||||
        # correct syntax would be `case(*x,):`
 | 
			
		||||
        self.assert_syntax_error("""
 | 
			
		||||
        match ...:
 | 
			
		||||
            case (*x):
 | 
			
		||||
                pass
 | 
			
		||||
        """)
 | 
			
		||||
 | 
			
		||||
    def test_mapping_pattern_keys_may_only_match_literals_and_attribute_lookups(self):
 | 
			
		||||
        self.assert_syntax_error("""
 | 
			
		||||
        match ...:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue