mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Modified admindocs tests to work with unittest2 discovery.
This commit is contained in:
		
				
					committed by
					
						 Carl Meyer
						Carl Meyer
					
				
			
			
				
	
			
			
			
						parent
						
							8ce46375ae
						
					
				
				
					commit
					7fd1571b2e
				
			| @@ -1,36 +1 @@ | ||||
| from __future__ import absolute_import, unicode_literals | ||||
|  | ||||
| from django.contrib.admindocs import views | ||||
| from django.db.models import fields as builtin_fields | ||||
| from django.utils import unittest | ||||
| from django.utils.translation import ugettext as _ | ||||
|  | ||||
| from . import fields | ||||
|  | ||||
|  | ||||
| class TestFieldType(unittest.TestCase): | ||||
|     def setUp(self): | ||||
|         pass | ||||
|  | ||||
|     def test_field_name(self): | ||||
|         self.assertRaises(AttributeError, | ||||
|             views.get_readable_field_data_type, "NotAField" | ||||
|         ) | ||||
|  | ||||
|     def test_builtin_fields(self): | ||||
|         self.assertEqual( | ||||
|             views.get_readable_field_data_type(builtin_fields.BooleanField()), | ||||
|             _('Boolean (Either True or False)') | ||||
|         ) | ||||
|  | ||||
|     def test_custom_fields(self): | ||||
|         self.assertEqual( | ||||
|             views.get_readable_field_data_type(fields.CustomField()), | ||||
|             'A custom field type' | ||||
|         ) | ||||
|         self.assertEqual( | ||||
|             views.get_readable_field_data_type(fields.DescriptionLackingField()), | ||||
|             _('Field of type: %(field_type)s') % { | ||||
|                 'field_type': 'DescriptionLackingField' | ||||
|             } | ||||
|         ) | ||||
| from .test_fields import TestFieldType | ||||
|   | ||||
| @@ -1,7 +0,0 @@ | ||||
| from django.db import models | ||||
|  | ||||
| class CustomField(models.Field): | ||||
|     description = "A custom field type" | ||||
|  | ||||
| class DescriptionLackingField(models.Field): | ||||
|     pass | ||||
							
								
								
									
										42
									
								
								django/contrib/admindocs/tests/test_fields.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								django/contrib/admindocs/tests/test_fields.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| from __future__ import absolute_import, unicode_literals | ||||
|  | ||||
| from django.contrib.admindocs import views | ||||
| from django.db import models | ||||
| from django.db.models import fields | ||||
| from django.utils import unittest | ||||
| from django.utils.translation import ugettext as _ | ||||
|  | ||||
|  | ||||
| class CustomField(models.Field): | ||||
|     description = "A custom field type" | ||||
|  | ||||
| class DescriptionLackingField(models.Field): | ||||
|     pass | ||||
|  | ||||
|  | ||||
| class TestFieldType(unittest.TestCase): | ||||
|     def setUp(self): | ||||
|         pass | ||||
|  | ||||
|     def test_field_name(self): | ||||
|         self.assertRaises(AttributeError, | ||||
|             views.get_readable_field_data_type, "NotAField" | ||||
|         ) | ||||
|  | ||||
|     def test_builtin_fields(self): | ||||
|         self.assertEqual( | ||||
|             views.get_readable_field_data_type(fields.BooleanField()), | ||||
|             _('Boolean (Either True or False)') | ||||
|         ) | ||||
|  | ||||
|     def test_custom_fields(self): | ||||
|         self.assertEqual( | ||||
|             views.get_readable_field_data_type(CustomField()), | ||||
|             'A custom field type' | ||||
|         ) | ||||
|         self.assertEqual( | ||||
|             views.get_readable_field_data_type(DescriptionLackingField()), | ||||
|             _('Field of type: %(field_type)s') % { | ||||
|                 'field_type': 'DescriptionLackingField' | ||||
|             } | ||||
|         ) | ||||
		Reference in New Issue
	
	Block a user