def testTagDates(): tag = Tag() tag.release_date = 2004 assert tag.release_date == Date(2004) tag.release_date = None assert tag.release_date is None tag = Tag() for date in [ Date(2002), Date(2002, 11, 26), Date(2002, 11, 26), Date(2002, 11, 26, 4), Date(2002, 11, 26, 4, 20), Date(2002, 11, 26, 4, 20), Date(2002, 11, 26, 4, 20, 10) ]: tag.encoding_date = date assert (tag.encoding_date == date) tag.encoding_date = str(date) assert (tag.encoding_date == date) tag.release_date = date assert (tag.release_date == date) tag.release_date = str(date) assert (tag.release_date == date) tag.original_release_date = date assert (tag.original_release_date == date) tag.original_release_date = str(date) assert (tag.original_release_date == date) tag.recording_date = date assert (tag.recording_date == date) tag.recording_date = str(date) assert (tag.recording_date == date) tag.tagging_date = date assert (tag.tagging_date == date) tag.tagging_date = str(date) assert (tag.tagging_date == date) try: tag._setDate(2.4) except TypeError: pass # expected else: assert not ("Invalid date type, expected TypeError")
def testTagDates(): tag = Tag() tag.release_date = 2004 assert tag.release_date == Date(2004) tag.release_date = None assert tag.release_date is None tag = Tag() for date in [Date(2002), Date(2002, 11, 26), Date(2002, 11, 26), Date(2002, 11, 26, 4), Date(2002, 11, 26, 4, 20), Date(2002, 11, 26, 4, 20), Date(2002, 11, 26, 4, 20, 10)]: tag.encoding_date = date assert (tag.encoding_date == date) tag.encoding_date = str(date) assert (tag.encoding_date == date) tag.release_date = date assert (tag.release_date == date) tag.release_date = str(date) assert (tag.release_date == date) tag.original_release_date = date assert (tag.original_release_date == date) tag.original_release_date = str(date) assert (tag.original_release_date == date) tag.recording_date = date assert (tag.recording_date == date) tag.recording_date = str(date) assert (tag.recording_date == date) tag.tagging_date = date assert (tag.tagging_date == date) tag.tagging_date = str(date) assert (tag.tagging_date == date) try: tag._setDate(2.4) except TypeError: pass # expected else: assert not("Invalid date type, expected TypeError")