mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-10-31 07:57:26 +03:00 
			
		
		
		
	Merge pull request #360 from timothyjlaurent/#359-fix-index-error-on-enum-functions
Add test for _is_sunder and _is_dunder array.py functions.
This commit is contained in:
		
						commit
						6c7cd4e4fa
					
				|  | @ -71,18 +71,18 @@ def _is_descriptor(obj): | ||||||
| 
 | 
 | ||||||
| def _is_dunder(name): | def _is_dunder(name): | ||||||
|     """Returns True if a __dunder__ name, False otherwise.""" |     """Returns True if a __dunder__ name, False otherwise.""" | ||||||
|     return (name[:2] == name[-2:] == '__' and |     return (len(name) > 4 and | ||||||
|  |             name[:2] == name[-2:] == '__' and | ||||||
|             name[2:3] != '_' and |             name[2:3] != '_' and | ||||||
|             name[-3:-2] != '_' and |             name[-3:-2] != '_') | ||||||
|             len(name) > 4) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def _is_sunder(name): | def _is_sunder(name): | ||||||
|     """Returns True if a _sunder_ name, False otherwise.""" |     """Returns True if a _sunder_ name, False otherwise.""" | ||||||
|     return (name[0] == name[-1] == '_' and |     return (len(name) > 2 and | ||||||
|  |             name[0] == name[-1] == '_' and | ||||||
|             name[1:2] != '_' and |             name[1:2] != '_' and | ||||||
|             name[-2:-1] != '_' and |             name[-2:-1] != '_') | ||||||
|             len(name) > 2) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def _make_class_unpicklable(cls): | def _make_class_unpicklable(cls): | ||||||
|  |  | ||||||
							
								
								
									
										0
									
								
								graphene/pyutils/tests/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								graphene/pyutils/tests/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										41
									
								
								graphene/pyutils/tests/test_enum.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								graphene/pyutils/tests/test_enum.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | ||||||
|  | from ..enum import _is_dunder, _is_sunder | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def test__is_dunder(): | ||||||
|  |     dunder_names = [ | ||||||
|  |         '__i__', | ||||||
|  |         '__test__', | ||||||
|  |     ] | ||||||
|  |     non_dunder_names = [ | ||||||
|  |         'test', | ||||||
|  |         '__test', | ||||||
|  |         '_test', | ||||||
|  |         '_test_', | ||||||
|  |         'test__', | ||||||
|  |         '', | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     for name in dunder_names: | ||||||
|  |         assert _is_dunder(name) is True | ||||||
|  | 
 | ||||||
|  |     for name in non_dunder_names: | ||||||
|  |         assert _is_dunder(name) is False | ||||||
|  | 
 | ||||||
|  | def test__is_sunder(): | ||||||
|  |     sunder_names = [ | ||||||
|  |         '_i_', | ||||||
|  |         '_test_', | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     non_sunder_names = [ | ||||||
|  |         '__i__', | ||||||
|  |         '_i__', | ||||||
|  |         '__i_', | ||||||
|  |         '', | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     for name in sunder_names: | ||||||
|  |         assert _is_sunder(name) is True | ||||||
|  | 
 | ||||||
|  |     for name in non_sunder_names: | ||||||
|  |         assert _is_sunder(name) is False | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user