Skip to content

Commit

Permalink
fix tests for python 2.6
Browse files Browse the repository at this point in the history
list.index has a different native error message in 2.6 and 2.7
  • Loading branch information
dannyroberts committed Sep 2, 2013
1 parent 0e7ecc3 commit 337f1cf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,6 @@ class B(Document):
{'doc_type': 'A', 's': unicode(a2.s)}]
})


def testSchemaListPropertyIndex(self):
"""SchemaListProperty index method
"""
Expand All @@ -1164,8 +1163,10 @@ class B(Document):
self.assertEqual(b.slm.index(a1, 1, -2), 2)
with self.assertRaises(ValueError) as cm:
b.slm.index(a3)
self.assertEqual(str(cm.exception), '{0} is not in list'.format(a3))

self.assertIn(str(cm.exception), (
'{0!r} is not in list'.format(a3),
'list.index(x): x not in list'
))

def testSchemaListPropertyInsert(self):
"""SchemaListProperty insert method
Expand Down Expand Up @@ -1256,8 +1257,10 @@ class B(Document):
})
with self.assertRaises(ValueError) as cm:
b.slm.remove(a1)
self.assertEqual(str(cm.exception), '{0} is not in list'.format(a1))

self.assertIn(str(cm.exception), (
'{0!r} is not in list'.format(a1),
'list.index(x): x not in list'
))

def testSchemaListPropertyReverse(self):
"""SchemaListProperty reverse method
Expand Down

0 comments on commit 337f1cf

Please sign in to comment.