@@ -58,6 +58,8 @@ def test_helpers_fsutil_year_rollover_helper() -> None:
5858 mocked_stat = fsutil .stat_result ([stat .S_IFREG , 1337 , id (vfs ), 0 , 0 , 0 , len (content ), 0 , 3384460800 , 0 ])
5959 with patch .object (path , "stat" , return_value = mocked_stat ):
6060 result = list (utils .year_rollover_helper (path , re_ts , ts_fmt ))
61+ assert len (result ) == 10
62+
6163 year_line = [(ts .year , line ) for ts , line in result ]
6264
6365 assert result [0 ][0 ].tzinfo == datetime .timezone .utc
@@ -78,3 +80,26 @@ def test_helpers_fsutil_year_rollover_helper() -> None:
7880
7981 assert year_line [0 ] == (2022 , "Jan 1 13:21:34 Line 10" )
8082 assert year_line [- 1 ] == (2018 , "Dec 31 03:14:15 Line 1" )
83+
84+
85+ def test_helpers_fsutil_year_rollover_helper_leap_day () -> None :
86+ """test if we correctly handle leap days such as 2024-02-29."""
87+
88+ content = """
89+ Feb 28 11:00:00 Line 1
90+ Feb 29 12:00:00 Line 2
91+ Mar 1 13:00:00 Line 3
92+ """
93+ fs = VirtualFilesystem ()
94+ fs .map_file_fh ("file" , io .BytesIO (textwrap .dedent (content ).encode ()))
95+ path = fs .path ("file" )
96+
97+ re_ts = r"(\w+\s{1,2}\d+\s\d{2}:\d{2}:\d{2})"
98+ ts_fmt = "%b %d %H:%M:%S"
99+ mocked_stat = fsutil .stat_result (
100+ [stat .S_IFREG , 1337 , id (fs ), 0 , 0 , 0 , len (content ), 0 , 1709294400 , 0 ]
101+ ) # mtime is set to 2024-03-01.
102+
103+ with patch .object (path , "stat" , return_value = mocked_stat ):
104+ result = list (utils .year_rollover_helper (path , re_ts , ts_fmt ))
105+ assert len (result ) == 3
0 commit comments