Skip to content

Commit

Permalink
Fix automated tests for py3
Browse files Browse the repository at this point in the history
  • Loading branch information
wojcikstefan committed Jun 25, 2019
1 parent 0578cdb commit fab441f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions mongoengine/base/metaclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ def __new__(mcs, name, bases, attrs):
# Set primary key
if not current_pk:
new_class._meta['id_field'] = field_name
new_class.id = field

# If the document doesn't explicitly define a primary key field, create
# one. Make it an ObjectIdField and give it a non-clashing name ("id"
Expand All @@ -394,7 +393,6 @@ def __new__(mcs, name, bases, attrs):
new_class._meta['id_field'] = id_name
new_class._fields[id_name] = ObjectIdField(db_field=id_db_name)
new_class._fields[id_name].name = id_name
new_class.id = new_class._fields[id_name]
new_class._db_field_map[id_name] = id_db_name
new_class._reverse_db_field_map[id_db_name] = id_name

Expand Down
8 changes: 4 additions & 4 deletions tests/document/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3137,7 +3137,7 @@ def test_positional_creation(self):
'Instantiating a document with positional arguments is not '
'supported. Please use `field_name=value` keyword arguments.'
)
self.assertEqual(e.exception.message, expected_msg)
self.assertEqual(str(e.exception), expected_msg)

def test_mixed_creation(self):
"""Document cannot be instantiated using mixed arguments."""
Expand All @@ -3147,7 +3147,7 @@ def test_mixed_creation(self):
'Instantiating a document with positional arguments is not '
'supported. Please use `field_name=value` keyword arguments.'
)
self.assertEqual(e.exception.message, expected_msg)
self.assertEqual(str(e.exception), expected_msg)

def test_positional_creation_embedded(self):
"""Embedded document cannot be created using positional arguments."""
Expand All @@ -3157,7 +3157,7 @@ def test_positional_creation_embedded(self):
'Instantiating a document with positional arguments is not '
'supported. Please use `field_name=value` keyword arguments.'
)
self.assertEqual(e.exception.message, expected_msg)
self.assertEqual(str(e.exception), expected_msg)

def test_mixed_creation_embedded(self):
"""Embedded document cannot be created using mixed arguments."""
Expand All @@ -3167,7 +3167,7 @@ def test_mixed_creation_embedded(self):
'Instantiating a document with positional arguments is not '
'supported. Please use `field_name=value` keyword arguments.'
)
self.assertEqual(e.exception.message, expected_msg)
self.assertEqual(str(e.exception), expected_msg)

def test_data_contains_id_field(self):
"""Ensure that asking for _data returns 'id'."""
Expand Down

0 comments on commit fab441f

Please sign in to comment.