def test_escape_output(self): e = Event() e.name = "Hello, with \\ special; chars and \n newlines" e.location = "Here; too" e.description = "Every\nwhere ! Yes, yes !" e.dtstamp = dt(2013, 1, 1) e.uid = "empty-uid" eq = list( sorted([ "BEGIN:VEVENT", "DTSTAMP:20130101T000000", "DESCRIPTION:Every\\nwhere ! Yes\\, yes !", "LOCATION:Here\\; too", "SUMMARY:Hello\\, with \\\\ special\\; chars and \\n newlines", "UID:empty-uid", "END:VEVENT" ])) self.assertEqual(list(sorted(str(e).splitlines())), eq)