This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ark3
Recipients JJeffries, ark3, jfinkels
Date 2010-11-20.21:07:01
SpamBayes Score 0.0047412273
Marked as misclassified No
Message-id <1290287222.9.0.718510011893.issue9909@psf.upfronthosting.co.za>
In-reply-to
Content
Quick hack alternative test. It would look nicer if the test used the datetime module, but I'm not sure that would be appropriate.


    def test_dayofyear(self):                                                                                                  
        """Test for the calendar.dayofyear() function, which computes the                                                      
        integer between 1 and 366 (inclusive) representing the specified day in                                                
        the specified month of the specified year.                                                                             
                                                                                                                               
        """                                                                                                                    
        for expected_total, year in (366, 2008), (365, 2010):                                                                  
            expected_day_of_year = 1                                                                                           
            for month in range(1, 13):                                                                                         
                lastDay = calendar.mdays[month]                                                                                
                if year == 2008 and month == 2:                                                                                
                    lastDay = 29                                                                                               
                for day in range(1, lastDay + 1):                                                                              
                    day_of_year = calendar.dayofyear(year, month, day)                                                         
                    self.assertEqual(expected_day_of_year, day_of_year)                                                        
                    # The computed day of the year must be between 1 and 366.                                                  
                    self.assertGreaterEqual(day_of_year, 1)                                                                    
                    self.assertLessEqual(day_of_year, 366)                                                                     
                    expected_day_of_year += 1                                                                                  
            self.assertEqual(expected_day_of_year - 1, expected_total)
History
Date User Action Args
2010-11-20 21:07:03ark3setrecipients: + ark3, jfinkels, JJeffries
2010-11-20 21:07:02ark3setmessageid: <1290287222.9.0.718510011893.issue9909@psf.upfronthosting.co.za>
2010-11-20 21:07:01ark3linkissue9909 messages
2010-11-20 21:07:01ark3create