Fred Drake | d077ca1 | 2001-12-12 05:38:08 +0000 | [diff] [blame] | 1 | import calendar |
| 2 | import unittest |
| 3 | |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 4 | from test import support |
Senthil Kumaran | 962fed9 | 2011-08-11 09:22:52 +0800 | [diff] [blame] | 5 | from test.script_helper import assert_python_ok |
Alexander Belopolsky | 43ca710 | 2010-06-14 17:32:03 +0000 | [diff] [blame] | 6 | import time |
Georg Brandl | 7004bd1 | 2010-10-19 18:54:25 +0000 | [diff] [blame] | 7 | import locale |
Ezio Melotti | 85710a4 | 2012-09-21 17:26:35 +0300 | [diff] [blame^] | 8 | import datetime |
Fred Drake | d077ca1 | 2001-12-12 05:38:08 +0000 | [diff] [blame] | 9 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 10 | result_2004_text = """ |
| 11 | 2004 |
| 12 | |
| 13 | January February March |
| 14 | Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su |
| 15 | 1 2 3 4 1 1 2 3 4 5 6 7 |
| 16 | 5 6 7 8 9 10 11 2 3 4 5 6 7 8 8 9 10 11 12 13 14 |
| 17 | 12 13 14 15 16 17 18 9 10 11 12 13 14 15 15 16 17 18 19 20 21 |
| 18 | 19 20 21 22 23 24 25 16 17 18 19 20 21 22 22 23 24 25 26 27 28 |
| 19 | 26 27 28 29 30 31 23 24 25 26 27 28 29 29 30 31 |
| 20 | |
| 21 | April May June |
| 22 | Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su |
| 23 | 1 2 3 4 1 2 1 2 3 4 5 6 |
| 24 | 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13 |
| 25 | 12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20 |
| 26 | 19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27 |
| 27 | 26 27 28 29 30 24 25 26 27 28 29 30 28 29 30 |
| 28 | 31 |
| 29 | |
| 30 | July August September |
| 31 | Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su |
| 32 | 1 2 3 4 1 1 2 3 4 5 |
| 33 | 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12 |
| 34 | 12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19 |
| 35 | 19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26 |
| 36 | 26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 |
| 37 | 30 31 |
| 38 | |
| 39 | October November December |
| 40 | Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su |
| 41 | 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 |
| 42 | 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12 |
| 43 | 11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19 |
| 44 | 18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26 |
| 45 | 25 26 27 28 29 30 31 29 30 27 28 29 30 31 |
| 46 | """ |
| 47 | |
| 48 | result_2004_html = """ |
| 49 | <?xml version="1.0" encoding="ascii"?> |
| 50 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 51 | <html> |
| 52 | <head> |
| 53 | <meta http-equiv="Content-Type" content="text/html; charset=ascii" /> |
| 54 | <link rel="stylesheet" type="text/css" href="calendar.css" /> |
Thomas Wouters | 47b49bf | 2007-08-30 22:15:33 +0000 | [diff] [blame] | 55 | <title>Calendar for 2004</title> |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 56 | </head> |
| 57 | <body> |
| 58 | <table border="0" cellpadding="0" cellspacing="0" class="year"> |
| 59 | <tr><th colspan="3" class="year">2004</th></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 60 | <tr><th colspan="7" class="month">January</th></tr> |
| 61 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 62 | <tr><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="thu">1</td><td class="fri">2</td><td class="sat">3</td><td class="sun">4</td></tr> |
| 63 | <tr><td class="mon">5</td><td class="tue">6</td><td class="wed">7</td><td class="thu">8</td><td class="fri">9</td><td class="sat">10</td><td class="sun">11</td></tr> |
| 64 | <tr><td class="mon">12</td><td class="tue">13</td><td class="wed">14</td><td class="thu">15</td><td class="fri">16</td><td class="sat">17</td><td class="sun">18</td></tr> |
| 65 | <tr><td class="mon">19</td><td class="tue">20</td><td class="wed">21</td><td class="thu">22</td><td class="fri">23</td><td class="sat">24</td><td class="sun">25</td></tr> |
| 66 | <tr><td class="mon">26</td><td class="tue">27</td><td class="wed">28</td><td class="thu">29</td><td class="fri">30</td><td class="sat">31</td><td class="noday"> </td></tr> |
| 67 | </table> |
| 68 | </td><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 69 | <tr><th colspan="7" class="month">February</th></tr> |
| 70 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 71 | <tr><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="sun">1</td></tr> |
| 72 | <tr><td class="mon">2</td><td class="tue">3</td><td class="wed">4</td><td class="thu">5</td><td class="fri">6</td><td class="sat">7</td><td class="sun">8</td></tr> |
| 73 | <tr><td class="mon">9</td><td class="tue">10</td><td class="wed">11</td><td class="thu">12</td><td class="fri">13</td><td class="sat">14</td><td class="sun">15</td></tr> |
| 74 | <tr><td class="mon">16</td><td class="tue">17</td><td class="wed">18</td><td class="thu">19</td><td class="fri">20</td><td class="sat">21</td><td class="sun">22</td></tr> |
| 75 | <tr><td class="mon">23</td><td class="tue">24</td><td class="wed">25</td><td class="thu">26</td><td class="fri">27</td><td class="sat">28</td><td class="sun">29</td></tr> |
| 76 | </table> |
| 77 | </td><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 78 | <tr><th colspan="7" class="month">March</th></tr> |
| 79 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 80 | <tr><td class="mon">1</td><td class="tue">2</td><td class="wed">3</td><td class="thu">4</td><td class="fri">5</td><td class="sat">6</td><td class="sun">7</td></tr> |
| 81 | <tr><td class="mon">8</td><td class="tue">9</td><td class="wed">10</td><td class="thu">11</td><td class="fri">12</td><td class="sat">13</td><td class="sun">14</td></tr> |
| 82 | <tr><td class="mon">15</td><td class="tue">16</td><td class="wed">17</td><td class="thu">18</td><td class="fri">19</td><td class="sat">20</td><td class="sun">21</td></tr> |
| 83 | <tr><td class="mon">22</td><td class="tue">23</td><td class="wed">24</td><td class="thu">25</td><td class="fri">26</td><td class="sat">27</td><td class="sun">28</td></tr> |
| 84 | <tr><td class="mon">29</td><td class="tue">30</td><td class="wed">31</td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td></tr> |
| 85 | </table> |
| 86 | </td></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 87 | <tr><th colspan="7" class="month">April</th></tr> |
| 88 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 89 | <tr><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="thu">1</td><td class="fri">2</td><td class="sat">3</td><td class="sun">4</td></tr> |
| 90 | <tr><td class="mon">5</td><td class="tue">6</td><td class="wed">7</td><td class="thu">8</td><td class="fri">9</td><td class="sat">10</td><td class="sun">11</td></tr> |
| 91 | <tr><td class="mon">12</td><td class="tue">13</td><td class="wed">14</td><td class="thu">15</td><td class="fri">16</td><td class="sat">17</td><td class="sun">18</td></tr> |
| 92 | <tr><td class="mon">19</td><td class="tue">20</td><td class="wed">21</td><td class="thu">22</td><td class="fri">23</td><td class="sat">24</td><td class="sun">25</td></tr> |
| 93 | <tr><td class="mon">26</td><td class="tue">27</td><td class="wed">28</td><td class="thu">29</td><td class="fri">30</td><td class="noday"> </td><td class="noday"> </td></tr> |
| 94 | </table> |
| 95 | </td><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 96 | <tr><th colspan="7" class="month">May</th></tr> |
| 97 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 98 | <tr><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="sat">1</td><td class="sun">2</td></tr> |
| 99 | <tr><td class="mon">3</td><td class="tue">4</td><td class="wed">5</td><td class="thu">6</td><td class="fri">7</td><td class="sat">8</td><td class="sun">9</td></tr> |
| 100 | <tr><td class="mon">10</td><td class="tue">11</td><td class="wed">12</td><td class="thu">13</td><td class="fri">14</td><td class="sat">15</td><td class="sun">16</td></tr> |
| 101 | <tr><td class="mon">17</td><td class="tue">18</td><td class="wed">19</td><td class="thu">20</td><td class="fri">21</td><td class="sat">22</td><td class="sun">23</td></tr> |
| 102 | <tr><td class="mon">24</td><td class="tue">25</td><td class="wed">26</td><td class="thu">27</td><td class="fri">28</td><td class="sat">29</td><td class="sun">30</td></tr> |
| 103 | <tr><td class="mon">31</td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td></tr> |
| 104 | </table> |
| 105 | </td><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 106 | <tr><th colspan="7" class="month">June</th></tr> |
| 107 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 108 | <tr><td class="noday"> </td><td class="tue">1</td><td class="wed">2</td><td class="thu">3</td><td class="fri">4</td><td class="sat">5</td><td class="sun">6</td></tr> |
| 109 | <tr><td class="mon">7</td><td class="tue">8</td><td class="wed">9</td><td class="thu">10</td><td class="fri">11</td><td class="sat">12</td><td class="sun">13</td></tr> |
| 110 | <tr><td class="mon">14</td><td class="tue">15</td><td class="wed">16</td><td class="thu">17</td><td class="fri">18</td><td class="sat">19</td><td class="sun">20</td></tr> |
| 111 | <tr><td class="mon">21</td><td class="tue">22</td><td class="wed">23</td><td class="thu">24</td><td class="fri">25</td><td class="sat">26</td><td class="sun">27</td></tr> |
| 112 | <tr><td class="mon">28</td><td class="tue">29</td><td class="wed">30</td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td></tr> |
| 113 | </table> |
| 114 | </td></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 115 | <tr><th colspan="7" class="month">July</th></tr> |
| 116 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 117 | <tr><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="thu">1</td><td class="fri">2</td><td class="sat">3</td><td class="sun">4</td></tr> |
| 118 | <tr><td class="mon">5</td><td class="tue">6</td><td class="wed">7</td><td class="thu">8</td><td class="fri">9</td><td class="sat">10</td><td class="sun">11</td></tr> |
| 119 | <tr><td class="mon">12</td><td class="tue">13</td><td class="wed">14</td><td class="thu">15</td><td class="fri">16</td><td class="sat">17</td><td class="sun">18</td></tr> |
| 120 | <tr><td class="mon">19</td><td class="tue">20</td><td class="wed">21</td><td class="thu">22</td><td class="fri">23</td><td class="sat">24</td><td class="sun">25</td></tr> |
| 121 | <tr><td class="mon">26</td><td class="tue">27</td><td class="wed">28</td><td class="thu">29</td><td class="fri">30</td><td class="sat">31</td><td class="noday"> </td></tr> |
| 122 | </table> |
| 123 | </td><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 124 | <tr><th colspan="7" class="month">August</th></tr> |
| 125 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 126 | <tr><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="sun">1</td></tr> |
| 127 | <tr><td class="mon">2</td><td class="tue">3</td><td class="wed">4</td><td class="thu">5</td><td class="fri">6</td><td class="sat">7</td><td class="sun">8</td></tr> |
| 128 | <tr><td class="mon">9</td><td class="tue">10</td><td class="wed">11</td><td class="thu">12</td><td class="fri">13</td><td class="sat">14</td><td class="sun">15</td></tr> |
| 129 | <tr><td class="mon">16</td><td class="tue">17</td><td class="wed">18</td><td class="thu">19</td><td class="fri">20</td><td class="sat">21</td><td class="sun">22</td></tr> |
| 130 | <tr><td class="mon">23</td><td class="tue">24</td><td class="wed">25</td><td class="thu">26</td><td class="fri">27</td><td class="sat">28</td><td class="sun">29</td></tr> |
| 131 | <tr><td class="mon">30</td><td class="tue">31</td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td></tr> |
| 132 | </table> |
| 133 | </td><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 134 | <tr><th colspan="7" class="month">September</th></tr> |
| 135 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 136 | <tr><td class="noday"> </td><td class="noday"> </td><td class="wed">1</td><td class="thu">2</td><td class="fri">3</td><td class="sat">4</td><td class="sun">5</td></tr> |
| 137 | <tr><td class="mon">6</td><td class="tue">7</td><td class="wed">8</td><td class="thu">9</td><td class="fri">10</td><td class="sat">11</td><td class="sun">12</td></tr> |
| 138 | <tr><td class="mon">13</td><td class="tue">14</td><td class="wed">15</td><td class="thu">16</td><td class="fri">17</td><td class="sat">18</td><td class="sun">19</td></tr> |
| 139 | <tr><td class="mon">20</td><td class="tue">21</td><td class="wed">22</td><td class="thu">23</td><td class="fri">24</td><td class="sat">25</td><td class="sun">26</td></tr> |
| 140 | <tr><td class="mon">27</td><td class="tue">28</td><td class="wed">29</td><td class="thu">30</td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td></tr> |
| 141 | </table> |
| 142 | </td></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 143 | <tr><th colspan="7" class="month">October</th></tr> |
| 144 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 145 | <tr><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="fri">1</td><td class="sat">2</td><td class="sun">3</td></tr> |
| 146 | <tr><td class="mon">4</td><td class="tue">5</td><td class="wed">6</td><td class="thu">7</td><td class="fri">8</td><td class="sat">9</td><td class="sun">10</td></tr> |
| 147 | <tr><td class="mon">11</td><td class="tue">12</td><td class="wed">13</td><td class="thu">14</td><td class="fri">15</td><td class="sat">16</td><td class="sun">17</td></tr> |
| 148 | <tr><td class="mon">18</td><td class="tue">19</td><td class="wed">20</td><td class="thu">21</td><td class="fri">22</td><td class="sat">23</td><td class="sun">24</td></tr> |
| 149 | <tr><td class="mon">25</td><td class="tue">26</td><td class="wed">27</td><td class="thu">28</td><td class="fri">29</td><td class="sat">30</td><td class="sun">31</td></tr> |
| 150 | </table> |
| 151 | </td><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 152 | <tr><th colspan="7" class="month">November</th></tr> |
| 153 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 154 | <tr><td class="mon">1</td><td class="tue">2</td><td class="wed">3</td><td class="thu">4</td><td class="fri">5</td><td class="sat">6</td><td class="sun">7</td></tr> |
| 155 | <tr><td class="mon">8</td><td class="tue">9</td><td class="wed">10</td><td class="thu">11</td><td class="fri">12</td><td class="sat">13</td><td class="sun">14</td></tr> |
| 156 | <tr><td class="mon">15</td><td class="tue">16</td><td class="wed">17</td><td class="thu">18</td><td class="fri">19</td><td class="sat">20</td><td class="sun">21</td></tr> |
| 157 | <tr><td class="mon">22</td><td class="tue">23</td><td class="wed">24</td><td class="thu">25</td><td class="fri">26</td><td class="sat">27</td><td class="sun">28</td></tr> |
| 158 | <tr><td class="mon">29</td><td class="tue">30</td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td></tr> |
| 159 | </table> |
| 160 | </td><td><table border="0" cellpadding="0" cellspacing="0" class="month"> |
| 161 | <tr><th colspan="7" class="month">December</th></tr> |
| 162 | <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr> |
| 163 | <tr><td class="noday"> </td><td class="noday"> </td><td class="wed">1</td><td class="thu">2</td><td class="fri">3</td><td class="sat">4</td><td class="sun">5</td></tr> |
| 164 | <tr><td class="mon">6</td><td class="tue">7</td><td class="wed">8</td><td class="thu">9</td><td class="fri">10</td><td class="sat">11</td><td class="sun">12</td></tr> |
| 165 | <tr><td class="mon">13</td><td class="tue">14</td><td class="wed">15</td><td class="thu">16</td><td class="fri">17</td><td class="sat">18</td><td class="sun">19</td></tr> |
| 166 | <tr><td class="mon">20</td><td class="tue">21</td><td class="wed">22</td><td class="thu">23</td><td class="fri">24</td><td class="sat">25</td><td class="sun">26</td></tr> |
| 167 | <tr><td class="mon">27</td><td class="tue">28</td><td class="wed">29</td><td class="thu">30</td><td class="fri">31</td><td class="noday"> </td><td class="noday"> </td></tr> |
| 168 | </table> |
| 169 | </td></tr></table></body> |
| 170 | </html> |
| 171 | """ |
| 172 | |
| 173 | |
| 174 | class OutputTestCase(unittest.TestCase): |
| 175 | def normalize_calendar(self, s): |
Mark Dickinson | 934896d | 2009-02-21 20:59:32 +0000 | [diff] [blame] | 176 | # Filters out locale dependent strings |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 177 | def neitherspacenordigit(c): |
| 178 | return not c.isspace() and not c.isdigit() |
| 179 | |
| 180 | lines = [] |
| 181 | for line in s.splitlines(False): |
| 182 | # Drop texts, as they are locale dependent |
| 183 | if line and not filter(neitherspacenordigit, line): |
| 184 | lines.append(line) |
| 185 | return lines |
| 186 | |
| 187 | def test_output(self): |
| 188 | self.assertEqual( |
| 189 | self.normalize_calendar(calendar.calendar(2004)), |
| 190 | self.normalize_calendar(result_2004_text) |
| 191 | ) |
| 192 | |
| 193 | def test_output_textcalendar(self): |
| 194 | self.assertEqual( |
| 195 | calendar.TextCalendar().formatyear(2004).strip(), |
| 196 | result_2004_text.strip() |
| 197 | ) |
| 198 | |
| 199 | def test_output_htmlcalendar(self): |
Walter Dörwald | c49ebc0 | 2007-05-22 17:03:39 +0000 | [diff] [blame] | 200 | encoding = 'ascii' |
| 201 | cal = calendar.HTMLCalendar() |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 202 | self.assertEqual( |
Walter Dörwald | c49ebc0 | 2007-05-22 17:03:39 +0000 | [diff] [blame] | 203 | cal.formatyearpage(2004, encoding=encoding).strip(b' \t\n'), |
| 204 | result_2004_html.strip(' \t\n').encode(encoding) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 205 | ) |
| 206 | |
| 207 | |
Fred Drake | d077ca1 | 2001-12-12 05:38:08 +0000 | [diff] [blame] | 208 | class CalendarTestCase(unittest.TestCase): |
| 209 | def test_isleap(self): |
| 210 | # Make sure that the return is right for a few years, and |
| 211 | # ensure that the return values are 1 or 0, not just true or |
| 212 | # false (see SF bug #485794). Specific additional tests may |
| 213 | # be appropriate; this tests a single "cycle". |
| 214 | self.assertEqual(calendar.isleap(2000), 1) |
| 215 | self.assertEqual(calendar.isleap(2001), 0) |
| 216 | self.assertEqual(calendar.isleap(2002), 0) |
| 217 | self.assertEqual(calendar.isleap(2003), 0) |
| 218 | |
| 219 | def test_setfirstweekday(self): |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 220 | self.assertRaises(TypeError, calendar.setfirstweekday, 'flabber') |
Fred Drake | d077ca1 | 2001-12-12 05:38:08 +0000 | [diff] [blame] | 221 | self.assertRaises(ValueError, calendar.setfirstweekday, -1) |
| 222 | self.assertRaises(ValueError, calendar.setfirstweekday, 200) |
| 223 | orig = calendar.firstweekday() |
| 224 | calendar.setfirstweekday(calendar.SUNDAY) |
| 225 | self.assertEqual(calendar.firstweekday(), calendar.SUNDAY) |
| 226 | calendar.setfirstweekday(calendar.MONDAY) |
| 227 | self.assertEqual(calendar.firstweekday(), calendar.MONDAY) |
| 228 | calendar.setfirstweekday(orig) |
| 229 | |
Skip Montanaro | 693c6c4 | 2002-03-15 03:57:04 +0000 | [diff] [blame] | 230 | def test_enumerateweekdays(self): |
| 231 | self.assertRaises(IndexError, calendar.day_abbr.__getitem__, -10) |
| 232 | self.assertRaises(IndexError, calendar.day_name.__getitem__, 10) |
| 233 | self.assertEqual(len([d for d in calendar.day_abbr]), 7) |
Fred Drake | d077ca1 | 2001-12-12 05:38:08 +0000 | [diff] [blame] | 234 | |
Tim Peters | 0c2c8e7 | 2002-03-23 03:26:53 +0000 | [diff] [blame] | 235 | def test_days(self): |
| 236 | for attr in "day_name", "day_abbr": |
| 237 | value = getattr(calendar, attr) |
| 238 | self.assertEqual(len(value), 7) |
| 239 | self.assertEqual(len(value[:]), 7) |
| 240 | # ensure they're all unique |
Tim Peters | bbc0d44 | 2004-11-13 16:18:32 +0000 | [diff] [blame] | 241 | self.assertEqual(len(set(value)), 7) |
| 242 | # verify it "acts like a sequence" in two forms of iteration |
| 243 | self.assertEqual(value[::-1], list(reversed(value))) |
Tim Peters | 0c2c8e7 | 2002-03-23 03:26:53 +0000 | [diff] [blame] | 244 | |
| 245 | def test_months(self): |
| 246 | for attr in "month_name", "month_abbr": |
| 247 | value = getattr(calendar, attr) |
| 248 | self.assertEqual(len(value), 13) |
| 249 | self.assertEqual(len(value[:]), 13) |
| 250 | self.assertEqual(value[0], "") |
| 251 | # ensure they're all unique |
Tim Peters | bbc0d44 | 2004-11-13 16:18:32 +0000 | [diff] [blame] | 252 | self.assertEqual(len(set(value)), 13) |
| 253 | # verify it "acts like a sequence" in two forms of iteration |
| 254 | self.assertEqual(value[::-1], list(reversed(value))) |
Tim Peters | 0c2c8e7 | 2002-03-23 03:26:53 +0000 | [diff] [blame] | 255 | |
Georg Brandl | 7004bd1 | 2010-10-19 18:54:25 +0000 | [diff] [blame] | 256 | def test_localecalendars(self): |
| 257 | # ensure that Locale{Text,HTML}Calendar resets the locale properly |
| 258 | # (it is still not thread-safe though) |
Georg Brandl | 7004bd1 | 2010-10-19 18:54:25 +0000 | [diff] [blame] | 259 | old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) |
Georg Brandl | 9450cc0 | 2010-10-20 06:50:19 +0000 | [diff] [blame] | 260 | try: |
| 261 | calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10) |
| 262 | except locale.Error: |
| 263 | # cannot set the system default locale -- skip rest of test |
| 264 | return |
| 265 | calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10) |
Georg Brandl | 7004bd1 | 2010-10-19 18:54:25 +0000 | [diff] [blame] | 266 | new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) |
Ezio Melotti | b3aedd4 | 2010-11-20 19:04:17 +0000 | [diff] [blame] | 267 | self.assertEqual(old_october, new_october) |
Georg Brandl | 7004bd1 | 2010-10-19 18:54:25 +0000 | [diff] [blame] | 268 | |
Ezio Melotti | 85710a4 | 2012-09-21 17:26:35 +0300 | [diff] [blame^] | 269 | def test_itermonthdates(self): |
| 270 | # ensure itermonthdates doesn't overflow after datetime.MAXYEAR |
| 271 | # see #15421 |
| 272 | list(calendar.Calendar().itermonthdates(datetime.MAXYEAR, 12)) |
| 273 | |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 274 | |
| 275 | class MonthCalendarTestCase(unittest.TestCase): |
| 276 | def setUp(self): |
| 277 | self.oldfirstweekday = calendar.firstweekday() |
| 278 | calendar.setfirstweekday(self.firstweekday) |
| 279 | |
| 280 | def tearDown(self): |
| 281 | calendar.setfirstweekday(self.oldfirstweekday) |
| 282 | |
| 283 | def check_weeks(self, year, month, weeks): |
| 284 | cal = calendar.monthcalendar(year, month) |
| 285 | self.assertEqual(len(cal), len(weeks)) |
Guido van Rossum | 805365e | 2007-05-07 22:24:25 +0000 | [diff] [blame] | 286 | for i in range(len(weeks)): |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 287 | self.assertEqual(weeks[i], sum(day != 0 for day in cal[i])) |
| 288 | |
| 289 | |
| 290 | class MondayTestCase(MonthCalendarTestCase): |
| 291 | firstweekday = calendar.MONDAY |
| 292 | |
| 293 | def test_february(self): |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 294 | # A 28-day february starting on monday (7+7+7+7 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 295 | self.check_weeks(1999, 2, (7, 7, 7, 7)) |
| 296 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 297 | # A 28-day february starting on tuesday (6+7+7+7+1 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 298 | self.check_weeks(2005, 2, (6, 7, 7, 7, 1)) |
| 299 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 300 | # A 28-day february starting on sunday (1+7+7+7+6 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 301 | self.check_weeks(1987, 2, (1, 7, 7, 7, 6)) |
| 302 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 303 | # A 29-day february starting on monday (7+7+7+7+1 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 304 | self.check_weeks(1988, 2, (7, 7, 7, 7, 1)) |
| 305 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 306 | # A 29-day february starting on tuesday (6+7+7+7+2 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 307 | self.check_weeks(1972, 2, (6, 7, 7, 7, 2)) |
| 308 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 309 | # A 29-day february starting on sunday (1+7+7+7+7 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 310 | self.check_weeks(2004, 2, (1, 7, 7, 7, 7)) |
| 311 | |
| 312 | def test_april(self): |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 313 | # A 30-day april starting on monday (7+7+7+7+2 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 314 | self.check_weeks(1935, 4, (7, 7, 7, 7, 2)) |
| 315 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 316 | # A 30-day april starting on tuesday (6+7+7+7+3 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 317 | self.check_weeks(1975, 4, (6, 7, 7, 7, 3)) |
| 318 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 319 | # A 30-day april starting on sunday (1+7+7+7+7+1 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 320 | self.check_weeks(1945, 4, (1, 7, 7, 7, 7, 1)) |
| 321 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 322 | # A 30-day april starting on saturday (2+7+7+7+7 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 323 | self.check_weeks(1995, 4, (2, 7, 7, 7, 7)) |
| 324 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 325 | # A 30-day april starting on friday (3+7+7+7+6 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 326 | self.check_weeks(1994, 4, (3, 7, 7, 7, 6)) |
| 327 | |
| 328 | def test_december(self): |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 329 | # A 31-day december starting on monday (7+7+7+7+3 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 330 | self.check_weeks(1980, 12, (7, 7, 7, 7, 3)) |
| 331 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 332 | # A 31-day december starting on tuesday (6+7+7+7+4 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 333 | self.check_weeks(1987, 12, (6, 7, 7, 7, 4)) |
| 334 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 335 | # A 31-day december starting on sunday (1+7+7+7+7+2 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 336 | self.check_weeks(1968, 12, (1, 7, 7, 7, 7, 2)) |
| 337 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 338 | # A 31-day december starting on thursday (4+7+7+7+6 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 339 | self.check_weeks(1988, 12, (4, 7, 7, 7, 6)) |
| 340 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 341 | # A 31-day december starting on friday (3+7+7+7+7 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 342 | self.check_weeks(2017, 12, (3, 7, 7, 7, 7)) |
| 343 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 344 | # A 31-day december starting on saturday (2+7+7+7+7+1 days) |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 345 | self.check_weeks(2068, 12, (2, 7, 7, 7, 7, 1)) |
| 346 | |
| 347 | |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 348 | class SundayTestCase(MonthCalendarTestCase): |
| 349 | firstweekday = calendar.SUNDAY |
| 350 | |
| 351 | def test_february(self): |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 352 | # A 28-day february starting on sunday (7+7+7+7 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 353 | self.check_weeks(2009, 2, (7, 7, 7, 7)) |
| 354 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 355 | # A 28-day february starting on monday (6+7+7+7+1 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 356 | self.check_weeks(1999, 2, (6, 7, 7, 7, 1)) |
| 357 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 358 | # A 28-day february starting on saturday (1+7+7+7+6 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 359 | self.check_weeks(1997, 2, (1, 7, 7, 7, 6)) |
| 360 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 361 | # A 29-day february starting on sunday (7+7+7+7+1 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 362 | self.check_weeks(2004, 2, (7, 7, 7, 7, 1)) |
| 363 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 364 | # A 29-day february starting on monday (6+7+7+7+2 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 365 | self.check_weeks(1960, 2, (6, 7, 7, 7, 2)) |
| 366 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 367 | # A 29-day february starting on saturday (1+7+7+7+7 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 368 | self.check_weeks(1964, 2, (1, 7, 7, 7, 7)) |
| 369 | |
| 370 | def test_april(self): |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 371 | # A 30-day april starting on sunday (7+7+7+7+2 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 372 | self.check_weeks(1923, 4, (7, 7, 7, 7, 2)) |
| 373 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 374 | # A 30-day april starting on monday (6+7+7+7+3 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 375 | self.check_weeks(1918, 4, (6, 7, 7, 7, 3)) |
| 376 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 377 | # A 30-day april starting on saturday (1+7+7+7+7+1 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 378 | self.check_weeks(1950, 4, (1, 7, 7, 7, 7, 1)) |
| 379 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 380 | # A 30-day april starting on friday (2+7+7+7+7 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 381 | self.check_weeks(1960, 4, (2, 7, 7, 7, 7)) |
| 382 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 383 | # A 30-day april starting on thursday (3+7+7+7+6 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 384 | self.check_weeks(1909, 4, (3, 7, 7, 7, 6)) |
| 385 | |
| 386 | def test_december(self): |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 387 | # A 31-day december starting on sunday (7+7+7+7+3 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 388 | self.check_weeks(2080, 12, (7, 7, 7, 7, 3)) |
| 389 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 390 | # A 31-day december starting on monday (6+7+7+7+4 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 391 | self.check_weeks(1941, 12, (6, 7, 7, 7, 4)) |
| 392 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 393 | # A 31-day december starting on saturday (1+7+7+7+7+2 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 394 | self.check_weeks(1923, 12, (1, 7, 7, 7, 7, 2)) |
| 395 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 396 | # A 31-day december starting on wednesday (4+7+7+7+6 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 397 | self.check_weeks(1948, 12, (4, 7, 7, 7, 6)) |
| 398 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 399 | # A 31-day december starting on thursday (3+7+7+7+7 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 400 | self.check_weeks(1927, 12, (3, 7, 7, 7, 7)) |
| 401 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 402 | # A 31-day december starting on friday (2+7+7+7+7+1 days) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 403 | self.check_weeks(1995, 12, (2, 7, 7, 7, 7, 1)) |
| 404 | |
Alexander Belopolsky | 43ca710 | 2010-06-14 17:32:03 +0000 | [diff] [blame] | 405 | class TimegmTestCase(unittest.TestCase): |
| 406 | TIMESTAMPS = [0, 10, 100, 1000, 10000, 100000, 1000000, |
| 407 | 1234567890, 1262304000, 1275785153,] |
| 408 | def test_timegm(self): |
| 409 | for secs in self.TIMESTAMPS: |
| 410 | tuple = time.gmtime(secs) |
| 411 | self.assertEqual(secs, calendar.timegm(tuple)) |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 412 | |
Brett Cannon | cfae36f | 2010-07-23 13:54:14 +0000 | [diff] [blame] | 413 | class MonthRangeTestCase(unittest.TestCase): |
| 414 | def test_january(self): |
| 415 | # Tests valid lower boundary case. |
| 416 | self.assertEqual(calendar.monthrange(2004,1), (3,31)) |
| 417 | |
| 418 | def test_february_leap(self): |
| 419 | # Tests February during leap year. |
| 420 | self.assertEqual(calendar.monthrange(2004,2), (6,29)) |
| 421 | |
| 422 | def test_february_nonleap(self): |
| 423 | # Tests February in non-leap year. |
| 424 | self.assertEqual(calendar.monthrange(2010,2), (0,28)) |
| 425 | |
| 426 | def test_december(self): |
| 427 | # Tests valid upper boundary case. |
| 428 | self.assertEqual(calendar.monthrange(2004,12), (2,31)) |
| 429 | |
| 430 | def test_zeroth_month(self): |
| 431 | # Tests low invalid boundary case. |
| 432 | with self.assertRaises(calendar.IllegalMonthError): |
| 433 | calendar.monthrange(2004, 0) |
| 434 | |
| 435 | def test_thirteenth_month(self): |
| 436 | # Tests high invalid boundary case. |
| 437 | with self.assertRaises(calendar.IllegalMonthError): |
| 438 | calendar.monthrange(2004, 13) |
| 439 | |
R. David Murray | 1daaf9e | 2010-12-31 19:21:14 +0000 | [diff] [blame] | 440 | class LeapdaysTestCase(unittest.TestCase): |
| 441 | def test_no_range(self): |
| 442 | # test when no range i.e. two identical years as args |
| 443 | self.assertEqual(calendar.leapdays(2010,2010), 0) |
| 444 | |
| 445 | def test_no_leapdays(self): |
| 446 | # test when no leap years in range |
| 447 | self.assertEqual(calendar.leapdays(2010,2011), 0) |
| 448 | |
| 449 | def test_no_leapdays_upper_boundary(self): |
| 450 | # test no leap years in range, when upper boundary is a leap year |
| 451 | self.assertEqual(calendar.leapdays(2010,2012), 0) |
| 452 | |
| 453 | def test_one_leapday_lower_boundary(self): |
| 454 | # test when one leap year in range, lower boundary is leap year |
| 455 | self.assertEqual(calendar.leapdays(2012,2013), 1) |
| 456 | |
| 457 | def test_several_leapyears_in_range(self): |
| 458 | self.assertEqual(calendar.leapdays(1997,2020), 5) |
| 459 | |
Brett Cannon | cfae36f | 2010-07-23 13:54:14 +0000 | [diff] [blame] | 460 | |
Senthil Kumaran | 962fed9 | 2011-08-11 09:22:52 +0800 | [diff] [blame] | 461 | class ConsoleOutputTestCase(unittest.TestCase): |
| 462 | def test_outputs_bytes(self): |
| 463 | (return_code, stdout, stderr) = assert_python_ok('-m', 'calendar', '--type=html', '2010') |
| 464 | self.assertEqual(stdout[:6], b'<?xml ') |
| 465 | |
Fred Drake | d077ca1 | 2001-12-12 05:38:08 +0000 | [diff] [blame] | 466 | def test_main(): |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 467 | support.run_unittest( |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 468 | OutputTestCase, |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 469 | CalendarTestCase, |
Walter Dörwald | 302fa6d | 2004-07-08 17:14:17 +0000 | [diff] [blame] | 470 | MondayTestCase, |
Alexander Belopolsky | 43ca710 | 2010-06-14 17:32:03 +0000 | [diff] [blame] | 471 | SundayTestCase, |
| 472 | TimegmTestCase, |
Brett Cannon | cfae36f | 2010-07-23 13:54:14 +0000 | [diff] [blame] | 473 | MonthRangeTestCase, |
R. David Murray | 1daaf9e | 2010-12-31 19:21:14 +0000 | [diff] [blame] | 474 | LeapdaysTestCase, |
Senthil Kumaran | 962fed9 | 2011-08-11 09:22:52 +0800 | [diff] [blame] | 475 | ConsoleOutputTestCase |
Walter Dörwald | 59ad456 | 2004-07-02 19:00:09 +0000 | [diff] [blame] | 476 | ) |
| 477 | |
Fred Drake | d077ca1 | 2001-12-12 05:38:08 +0000 | [diff] [blame] | 478 | |
| 479 | if __name__ == "__main__": |
| 480 | test_main() |