FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: circumvent a sometimes impossible test · python-metar/python-metar@b675f48 · GitHub

Commit b675f48

Browse files
committed
test: circumvent a sometimes impossible test
1 parent c4298c5 commit b675f48

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

‎test/test_metar.py‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,17 @@ def test_032_parseTime_specify_month():
199199

200200
def test_033_parseTime_auto_month():
201201
"""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
206207

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
216213

217214

218215
def test_034_parseTime_auto_year():

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL