def test_display(days): d = ttcal.Today() d.mark = 'foo' assert 'foo' in d.display noday = ttcal.Day.from_idtag('d201502011') assert 'noday' in noday.display assert noday.special is False
def setUp(self): """SetUp default data for the tests. """ self.day1 = ttcal.Day(date(2012, 4, 10)) self.day2 = ttcal.Day(2012, 4, 8) self.day3 = ttcal.Day() self.today = ttcal.Today()
def days(): return [ ttcal.Day(date(2012, 4, 10)), ttcal.Day(2012, 4, 8), ttcal.Day(), ttcal.Today(), ]
def test_ctor(months): assert ttcal.Month() == ttcal.Today().Month with pytest.raises(ValueError): ttcal.Month(2012, 15)
def test_contains(): assert ttcal.Today() in ttcal.Month() with pytest.raises(KeyError): (ttcal.Month() + 2)[ttcal.Today()]
def test_hash(months): assert hash(ttcal.Today().Month) == hash(ttcal.Month())
def test_index(week): today = ttcal.Today() assert today in today.week assert today.week[0] <= today
def test_hash(week): assert hash(week[0]) == hash(week[-1]) assert len(set(hash(w) for w in week)) == len(week) - 1 # first and last are equal assert hash(ttcal.Today() + 1) == hash(ttcal.Today().next())
def test_until_today(week): w = ttcal.Today().week assert len(list(w.until_today())) == ttcal.Today() - w.first assert len(list(week[0].until_today())) == 7
def test_current(week): assert week[0].current is False assert ttcal.Today().week.current
def test_timetuple(days): assert isinstance(days[0].timetuple(), datetime) assert ttcal.Today().timetuple() == ttcal.Day().timetuple()