'Ensure a ValidationError handles error to_dict correctly.'

def test_to_dict(self):

    error = ValidationError('root')
    self.assertEqual(error.to_dict(), {})
    error.errors = {'1st': ValidationError('bad    1st')}
    self.assertTrue(('1st' in error.to_dict()))
    self.assertEqual(error.to_dict()['1st'], 'bad    1st')
    error.errors = {'1st': ValidationError('bad    1st', errors={'2nd': ValidationError('bad    2nd')})}
    self.assertTrue(('1st' in error.to_dict()))
    self.assertTrue(isinstance(error.to_dict()['1st'], dict))
    self.assertTrue(('2nd' in error.to_dict()['1st']))
    self.assertEqual(error.to_dict()['1st']['2nd'], 'bad    2nd')
    error.errors = {'1st': ValidationError('bad    1st', errors={'2nd': ValidationError('bad    2nd', errors={'3rd': ValidationError('bad    3rd', errors={'4th': ValidationError('Inception')})})})}
    self.assertTrue(('1st' in error.to_dict()))
    self.assertTrue(('2nd' in error.to_dict()['1st']))
    self.assertTrue(('3rd' in error.to_dict()['1st']['2nd']))
    self.assertTrue(('4th' in error.to_dict()['1st']['2nd']['3rd']))
    self.assertEqual(error.to_dict()['1st']['2nd']['3rd']['4th'], 'Inception')
    self.assertEqual(error.message, "root(2nd.3rd.4th.Inception:    ['1st'])")
