def _doNonEquality(caldata): card1 = Card() card1.parse(StringIO.StringIO(caldata)) card2 = Card() card2.parse(StringIO.StringIO(caldata)) card2.addProperty(Property("X-FOO", "BAR")) self.assertNotEqual(card1, card2)
def _doDuplicateRoundtrip(caldata, result): card = Card() card.parse(StringIO.StringIO(caldata)) card = card.duplicate() s = StringIO.StringIO() card.generate(s) test = s.getvalue() self.assertEqual(test, result, "\n".join(difflib.unified_diff(test.splitlines(), result.splitlines())))
def _doEquality(caldata): card1 = Card() card1.parse(StringIO.StringIO(caldata)) card2 = Card() card2.parse(StringIO.StringIO(caldata)) self.assertEqual( card1, card2, "\n".join(difflib.unified_diff(str(card1).splitlines(), str(card2).splitlines())) )
def _doRoundtrip(caldata, resultdata=None): test1 = resultdata if resultdata is not None else caldata card = Card() card.parse(StringIO.StringIO(caldata)) s = StringIO.StringIO() card.generate(s) test2 = s.getvalue() self.assertEqual(test1, test2, "\n".join(difflib.unified_diff(test1.splitlines(), test2.splitlines())))
def _doEquality(caldata): card1 = Card() card1.parse(StringIO.StringIO(caldata)) card2 = Card() card2.parse(StringIO.StringIO(caldata)) self.assertEqual( card1, card2, "\n".join( difflib.unified_diff( str(card1).splitlines(), str(card2).splitlines())))
def _doDuplicateRoundtrip(caldata, result): card = Card() card.parse(StringIO.StringIO(caldata)) card = card.duplicate() s = StringIO.StringIO() card.generate(s) test = s.getvalue() self.assertEqual( test, result, "\n".join( difflib.unified_diff(test.splitlines(), result.splitlines())))
def _doRoundtrip(caldata, resultdata=None): test1 = resultdata if resultdata is not None else caldata card = Card() card.parse(StringIO.StringIO(caldata)) s = StringIO.StringIO() card.generate(s) test2 = s.getvalue() self.assertEqual( test1, test2, "\n".join( difflib.unified_diff(test1.splitlines(), test2.splitlines())), )
def fromStream(clazz, stream): """ Construct a L{Component} from a stream. @param stream: a C{read()}able stream containing vCard data. @return: a L{Component} representing the first component described by C{stream}. """ cal = Card() try: result = cal.parse(stream) except PyCalendarError: result = None if not result: stream.seek(0) raise InvalidVCardDataError("%s" % (stream.read(),)) return clazz(None, pycard=cal)