Merge branch 'a4tunado-753'
This commit is contained in:
		
							
								
								
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -211,3 +211,4 @@ that much better: | |||||||
|  * DavidBord (https://github.com/DavidBord) |  * DavidBord (https://github.com/DavidBord) | ||||||
|  * Axel Haustant (https://github.com/noirbizarre) |  * Axel Haustant (https://github.com/noirbizarre) | ||||||
|  * David Czarnecki (https://github.com/czarneckid) |  * David Czarnecki (https://github.com/czarneckid) | ||||||
|  |  * Vyacheslav Murashkin (https://github.com/a4tunado) | ||||||
|   | |||||||
| @@ -229,7 +229,7 @@ class BaseDocument(object): | |||||||
|             u = self.__str__() |             u = self.__str__() | ||||||
|         except (UnicodeEncodeError, UnicodeDecodeError): |         except (UnicodeEncodeError, UnicodeDecodeError): | ||||||
|             u = '[Bad Unicode data]' |             u = '[Bad Unicode data]' | ||||||
|         repr_type = type(u) |         repr_type = str if u is None else type(u) | ||||||
|         return repr_type('<%s: %s>' % (self.__class__.__name__, u)) |         return repr_type('<%s: %s>' % (self.__class__.__name__, u)) | ||||||
|  |  | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|   | |||||||
| @@ -112,6 +112,19 @@ class InstanceTest(unittest.TestCase): | |||||||
|  |  | ||||||
|         self.assertEqual('<Article: привет мир>', repr(doc)) |         self.assertEqual('<Article: привет мир>', repr(doc)) | ||||||
|  |  | ||||||
|  |     def test_repr_none(self): | ||||||
|  |         """Ensure None values handled correctly | ||||||
|  |         """ | ||||||
|  |         class Article(Document): | ||||||
|  |             title = StringField() | ||||||
|  |  | ||||||
|  |             def __str__(self): | ||||||
|  |                 return None | ||||||
|  |  | ||||||
|  |         doc = Article(title=u'привет мир') | ||||||
|  |  | ||||||
|  |         self.assertEqual('<Article: None>', repr(doc)) | ||||||
|  |  | ||||||
|     def test_queryset_resurrects_dropped_collection(self): |     def test_queryset_resurrects_dropped_collection(self): | ||||||
|         self.Person.drop_collection() |         self.Person.drop_collection() | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user