Skip to content
Snippets Groups Projects
Unverified Commit b495a6ba authored by Feanil Patel's avatar Feanil Patel
Browse files

NoneType not in types module in python3.

Change our tests to use type(None) instead which works in both python2 and python3.
parent 9076b5d3
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,6 @@ Custom field types for mongoengine
"""
from __future__ import absolute_import
from types import NoneType
import mongoengine
import six
......@@ -38,7 +36,7 @@ class CourseKeyField(mongoengine.StringField):
"""
# calling super b/c it decodes utf (and doesn't have circularity of from_python)
course_key = super(CourseKeyField, self).to_python(course_key)
assert isinstance(course_key, (NoneType, six.string_types, CourseKey))
assert isinstance(course_key, (type(None), six.string_types, CourseKey))
if course_key == '':
return None
if isinstance(course_key, six.string_types):
......@@ -47,7 +45,7 @@ class CourseKeyField(mongoengine.StringField):
return course_key
def validate(self, value):
assert isinstance(value, (NoneType, six.string_types, CourseKey))
assert isinstance(value, (type(None), six.string_types, CourseKey))
if isinstance(value, CourseKey):
return super(CourseKeyField, self).validate(text_type(value))
else:
......@@ -74,7 +72,7 @@ class UsageKeyField(mongoengine.StringField):
"""
Deserialize to a UsageKey instance: for now it's a location missing the run
"""
assert isinstance(location, (NoneType, six.string_types, UsageKey))
assert isinstance(location, (type(None), six.string_types, UsageKey))
if location == '':
return None
if isinstance(location, six.string_types):
......@@ -84,7 +82,7 @@ class UsageKeyField(mongoengine.StringField):
return location
def validate(self, value):
assert isinstance(value, (NoneType, six.string_types, UsageKey))
assert isinstance(value, (type(None), six.string_types, UsageKey))
if isinstance(value, UsageKey):
return super(UsageKeyField, self).validate(text_type(value))
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment