get rid of six
This commit is contained in:
		| @@ -3,13 +3,12 @@ import uuid | ||||
|  | ||||
| from bson import Binary | ||||
| import pytest | ||||
| import six | ||||
|  | ||||
| from mongoengine import * | ||||
| from tests.utils import MongoDBTestCase | ||||
|  | ||||
| BIN_VALUE = six.b( | ||||
|     "\xa9\xf3\x8d(\xd7\x03\x84\xb4k[\x0f\xe3\xa2\x19\x85p[J\xa3\xd2>\xde\xe6\x87\xb1\x7f\xc6\xe6\xd9r\x18\xf5" | ||||
| BIN_VALUE = "\xa9\xf3\x8d(\xd7\x03\x84\xb4k[\x0f\xe3\xa2\x19\x85p[J\xa3\xd2>\xde\xe6\x87\xb1\x7f\xc6\xe6\xd9r\x18\xf5".encode( | ||||
|     "latin-1" | ||||
| ) | ||||
|  | ||||
|  | ||||
| @@ -22,7 +21,7 @@ class TestBinaryField(MongoDBTestCase): | ||||
|             content_type = StringField() | ||||
|             blob = BinaryField() | ||||
|  | ||||
|         BLOB = six.b("\xe6\x00\xc4\xff\x07") | ||||
|         BLOB = "\xe6\x00\xc4\xff\x07".encode("latin-1") | ||||
|         MIME_TYPE = "application/octet-stream" | ||||
|  | ||||
|         Attachment.drop_collection() | ||||
| @@ -32,7 +31,7 @@ class TestBinaryField(MongoDBTestCase): | ||||
|  | ||||
|         attachment_1 = Attachment.objects().first() | ||||
|         assert MIME_TYPE == attachment_1.content_type | ||||
|         assert BLOB == six.binary_type(attachment_1.blob) | ||||
|         assert BLOB == bytes(attachment_1.blob) | ||||
|  | ||||
|     def test_validation_succeeds(self): | ||||
|         """Ensure that valid values can be assigned to binary fields. | ||||
| @@ -47,11 +46,11 @@ class TestBinaryField(MongoDBTestCase): | ||||
|         attachment_required = AttachmentRequired() | ||||
|         with pytest.raises(ValidationError): | ||||
|             attachment_required.validate() | ||||
|         attachment_required.blob = Binary(six.b("\xe6\x00\xc4\xff\x07")) | ||||
|         attachment_required.blob = Binary("\xe6\x00\xc4\xff\x07".encode("latin-1")) | ||||
|         attachment_required.validate() | ||||
|  | ||||
|         _5_BYTES = six.b("\xe6\x00\xc4\xff\x07") | ||||
|         _4_BYTES = six.b("\xe6\x00\xc4\xff") | ||||
|         _5_BYTES = "\xe6\x00\xc4\xff\x07".encode("latin-1") | ||||
|         _4_BYTES = "\xe6\x00\xc4\xff".encode("latin-1") | ||||
|         with pytest.raises(ValidationError): | ||||
|             AttachmentSizeLimit(blob=_5_BYTES).validate() | ||||
|         AttachmentSizeLimit(blob=_4_BYTES).validate() | ||||
| @@ -133,7 +132,7 @@ class TestBinaryField(MongoDBTestCase): | ||||
|  | ||||
|         MyDocument.drop_collection() | ||||
|  | ||||
|         bin_data = six.b("\xe6\x00\xc4\xff\x07") | ||||
|         bin_data = "\xe6\x00\xc4\xff\x07".encode("latin-1") | ||||
|         doc = MyDocument(bin_field=bin_data).save() | ||||
|  | ||||
|         n_updated = MyDocument.objects(bin_field=bin_data).update_one( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user