| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -199,20 +199,17 @@ def test_032_parseTime_specify_month(): | |||
| 199 | 199 | ||
| 200 | 200 | def test_033_parseTime_auto_month(): | |
| 201 | 201 | """Test assignment of time to previous month.""" | |
| 202 | - next_day = tomorrow.day | ||
| 203 | - if next_day > today.day: | ||
| 204 | - last_month = ((today.month - 2) % 12) + 1 | ||
| 205 | - last_year = today.year - 1 | ||
| 202 | + # To test this, we need a date last month that is with a greater day | ||
| 203 | + # than today, which does not always exist! | ||
| 204 | + last_month = today.replace(day=1) - timedelta(days=1) | ||
| 205 | + if last_month.day <= today.day: | ||
| 206 | + return | ||
| 206 | 207 | ||
| 207 | - timestr = "%02d1651Z" % (next_day) | ||
| 208 | - report = Metar.Metar("KEWR " + timestr) | ||
| 209 | - assert report.decode_completed | ||
| 210 | - assert report.time.day == next_day | ||
| 211 | - assert report.time.month == last_month | ||
| 212 | - if today.month > 1: | ||
| 213 | - assert report.time.year == today.year | ||
| 214 | - else: | ||
| 215 | - assert report.time.year == last_year | ||
| 208 | + report = Metar.Metar(f"KEWR {last_month.day:02.0f}1651Z") | ||
| 209 | + assert report.decode_completed | ||
| 210 | + assert report.time.day == last_month.day | ||
| 211 | + assert report.time.month == last_month.month | ||
| 212 | + assert report.time.year == last_month.year | ||
| 216 | 213 | ||
| 217 | 214 | ||
| 218 | 215 | def test_034_parseTime_auto_year(): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments