mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-10-31 16:07:38 +03:00 
			
		
		
		
	Weakened to PendingDeprecationWarning for base_name
				
					
				
			cc @rpkilby.
This commit is contained in:
		
							parent
							
								
									cfd73825a8
								
							
						
					
					
						commit
						06d89441a6
					
				|  | @ -77,7 +77,7 @@ def flatten(list_of_lists): | |||
| 
 | ||||
| class RenameRouterMethods(RenameMethodsBase): | ||||
|     renamed_methods = ( | ||||
|         ('get_default_base_name', 'get_default_basename', DeprecationWarning), | ||||
|         ('get_default_base_name', 'get_default_basename', PendingDeprecationWarning), | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -87,8 +87,8 @@ class BaseRouter(six.with_metaclass(RenameRouterMethods)): | |||
| 
 | ||||
|     def register(self, prefix, viewset, basename=None, base_name=None): | ||||
|         if base_name is not None: | ||||
|             msg = "The `base_name` argument has been deprecated in favor of `basename`." | ||||
|             warnings.warn(msg, DeprecationWarning, 2) | ||||
|             msg = "The `base_name` argument is pending deprecation in favor of `basename`." | ||||
|             warnings.warn(msg, PendingDeprecationWarning, 2) | ||||
| 
 | ||||
|         assert not (basename and base_name), ( | ||||
|             "Do not provide both the `basename` and `base_name` arguments.") | ||||
|  |  | |||
|  | @ -495,18 +495,18 @@ class TestBaseNameRename(TestCase): | |||
|             warnings.simplefilter('always') | ||||
|             router.register('mock', MockViewSet, 'mock', base_name='mock') | ||||
| 
 | ||||
|         msg = "The `base_name` argument has been deprecated in favor of `basename`." | ||||
|         msg = "The `base_name` argument is pending deprecation in favor of `basename`." | ||||
|         assert len(w) == 1 | ||||
|         assert str(w[0].message) == msg | ||||
| 
 | ||||
|     def test_base_name_argument_deprecation(self): | ||||
|         router = SimpleRouter() | ||||
| 
 | ||||
|         with warnings.catch_warnings(record=True) as w: | ||||
|         with pytest.warns(PendingDeprecationWarning) as w: | ||||
|             warnings.simplefilter('always') | ||||
|             router.register('mock', MockViewSet, base_name='mock') | ||||
| 
 | ||||
|         msg = "The `base_name` argument has been deprecated in favor of `basename`." | ||||
|         msg = "The `base_name` argument is pending deprecation in favor of `basename`." | ||||
|         assert len(w) == 1 | ||||
|         assert str(w[0].message) == msg | ||||
|         assert router.registry == [ | ||||
|  | @ -529,7 +529,7 @@ class TestBaseNameRename(TestCase): | |||
|         msg = "`CustomRouter.get_default_base_name` method should be renamed `get_default_basename`." | ||||
| 
 | ||||
|         # Class definition should raise a warning | ||||
|         with warnings.catch_warnings(record=True) as w: | ||||
|         with pytest.warns(PendingDeprecationWarning) as w: | ||||
|             warnings.simplefilter('always') | ||||
| 
 | ||||
|             class CustomRouter(SimpleRouter): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user