m.return_value.readlines.return_value=['this is line 1\n']
withpatch('__builtin__.open',m):
# this line will be found in the file
self.obj._data_source='foo.yml'
self.obj._line_number=1
self.obj._column_number=1
e=AnsibleError(self.message,self.obj)
self.assertEqual(e.message,'this is the error message\nThe error occurred on line 1 of the file foo.yml:\nthis is line 1\n^')
# this line will not be found, as it is out of the index range
self.obj._data_source='foo.yml'
self.obj._line_number=2
self.obj._column_number=1
e=AnsibleError(self.message,self.obj)
self.assertEqual(e.message,'this is the error message\nThe error occurred on line 2 of the file foo.yml:\n\n(specified line no longer in file, maybe it changed?)')