Skip to content

Commit

Permalink
Fix unittest for local timezones
Browse files Browse the repository at this point in the history
The Unit Test (gramps.plugins.test.exports_test.test_ged) is broken when the
OS is not in UTC time zone. This patch improves the test filter to ignore
dates and times belonging to the last change (CHAN).

Also, the buffer for the previous tokens had to be increased.

Fixes #12902.
  • Loading branch information
toddy15 authored and Nick-Hall committed Jan 8, 2025
1 parent a6a1300 commit 8c6ac0a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions gramps/plugins/test/exports_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_prev_token(back):

# pylint: disable=unsubscriptable-object
if line.startswith("@@"):
gedfilt.prev = [None] * 8
gedfilt.prev = [None] * 16
gedfilt.indx = 0
return False
retval = True
Expand All @@ -125,21 +125,27 @@ def get_prev_token(back):
if diftyp == " ":
# save the line for later if needed to figure out the data element
gedfilt.prev[gedfilt.indx] = token, level, line
gedfilt.indx = (gedfilt.indx + 1) % 8
gedfilt.indx = (gedfilt.indx + 1) % 16
retval = False
elif diftyp == "-":
# save the line for later if needed to figure out the data element
gedfilt.prev[gedfilt.indx] = token, level, line
gedfilt.indx = (gedfilt.indx + 1) % 8
gedfilt.indx = (gedfilt.indx + 1) % 16
if token == "VERS" and get_prev_token(2) == "SOUR":
# we must have a header with Gramps version
retval = False
elif token == "DATE" and get_prev_token(2) == "NAME":
# we must have a header with file date
retval = False
elif token == "DATE" and get_prev_token(2) == "CHAN\n":
# probably have a timestamp of last change
retval = False
elif token == "TIME" and get_prev_token(2) == "DATE":
# probably have a header with file time
retval = False
elif token == "TIME" and get_prev_token(2) == "CHAN\n":
# probably have a timestamp of last change
retval = False
elif token == "FILE" and line.endswith(".ged\n"):
# probably have a header with file name
retval = False
Expand All @@ -158,6 +164,11 @@ def get_prev_token(back):
):
# we must have a header with file date
retval = False
elif token == "DATE" and (
get_prev_token(3) == "CHAN\n" or get_prev_token(4) == "CHAN\n"
):
# probably have a timestamp of last change
retval = False
elif token == "TIME" and (
get_prev_token(2) == "DATE" or get_prev_token(3) == "DATE"
):
Expand Down

0 comments on commit 8c6ac0a

Please sign in to comment.